Skip to content

larmic-iot/sonnenBatterie-api

Repository files navigation

sonnenBatterie-api

License Go build Docker build and push Docker hub image Docker Image Version (latest by date)

A REST api client (adapter) for the SonnenBatterie. The default Sonnen-Battery-API (with token) provides too little information. This application does not need the token, but use the normal access to the SonnenBatterie. REST endpoints documented in open api 3.1.

This project inspired by tp-link-hs110-api written in go and improves my Go knowledge.

Versioning

Semantic Versioning 2.x is used. Version number MAJOR.MINOR.PATCH with

  • MAJOR version increase on incompatible API changes
  • MINOR version increase on adding new functionality in a backwards compatible manner
  • PATCH version increase on backwards compatible bug fixes or documentation

Usage

The easiest way is to use the docker image. Otherwise, the artifact will have to be built by yourself.

$ docker pull larmic/sonnen-batterie-api
$ docker run -d -p 8080:8080 --rm \
 -e SONNENBATTERIE_IP='<my-battery-ip>' \
 -e SONNENBATTERIE_USER_NAME='User' \
 -e SONNENBATTERIE_USER_PASSWORD='<my-password>' \
 --name larmic-sonnen-batterie-api larmic/sonnen-batterie-api

Example requests

See open api 3 specification for further information.

$ curl http://localhost:8080/sonnen-battery-api                    # Open Api 3.1 specification
$ curl http://localhost:8080/sonnen-battery-api/api/consumption    # Energy consumption
$ curl http://localhost:8080/sonnen-battery-api/api/status         # Battery status (incl. greed feed in, production and charge level)

Build application by yourself

Requirements

  • Docker
  • Go 1.21.x (if you want to build it without using docker builder)

Build and run it

See Makefile!

$ make              # prints available make goals