"Access Sonnenbatterie REST API"
Project description
python_sonnenbatterie
Python module to access the REST API of a Sonnenbatterie.
This modules contains two distinct sets of APIs:
- the original sonnen API (v1)
- the new v2 API
Both are available in a synchronous and an asynchronous version:
sonnenbatterie- SonnenAPI v1, synchronousAsyncSonnenBatterie- SonnenAPI v1, asynchronousSonnenBatterieV2- SonnenAPI v2, synchronousAsyncSonnenBatterieV2- SonnenAPI v2, asynchronous
The major difference between those two is the method to authenticate. With API v1 you need to login using a username and a password. The newer API requires a token that can be found in the web UI of your Sonnenbatterie. Also, the v2 API provides a unified view across the different Sonnenbatterie models wheres the v1 API may provide more details in specific setups.
When using the v1 API you'll autmatically get access to the v2 API by using the sb2
attribute of the v1 client object.
Installation
Using pip
pip3 install sonnenbatterie
Manual installation
Download the archive from pypi.org and unpack where needed ;)
Usage
SonnenAPI v1 - sync
# API v1
from sonnenbatterie import sonnenbatterie
sb_host = '192.168.1.2'
sb_user = 'User'
sb_pass = 'Password'
# Init class, establish connection
sb = sonnenbatterie(sb_host, sb_user, sb_pass)
print(sb.get_status()) # retrieve general information
print(sb.get_powermeter()) # retrieive power meter details
print(sb.get_batterysystem()) # retrieve battery system data
print(sb.get_inverter()) # retrieve inverter status
print(sb.get_systemdata()) # retrieve system data
print(sb.get_battery()) # get battery information
print(sb.get_api_configuration()) # get api configuration
print(sb.get_commissioning_settings()) # get commissioning settings
SonnenAPI v1 - async
# API v1
from sonnenbatterie import AsyncSonnenBatterie
sb_host = '192.168.1.2'
sb_user = 'User'
sb_pass = 'Password'
# Init class, establish connection
sb = AsyncSonnenBatterie(sb_host, sb_user, sb_pass)
print(await sb.get_status()) # retrieve general information
print(await sb.get_powermeter()) # retrieive power meter details
print(await sb.get_batterysystem()) # retrieve battery system data
print(await sb.get_inverter()) # retrieve inverter status
print(await sb.get_systemdata()) # retrieve system data
print(await sb.get_battery()) # get battery information
print(await sb.get_api_configuration()) # get api configuration
print(await sb.get_commissioning_settings()) # get commissioning settings
# Async needs to close the connection!
await sb.logout()
SonnenAPI v2 - sync
# API v2
# can either be access directly, see below, or
# via sb.sb2 (gets initialiazed automatically when creating a V1 object)
from sonnebatterie2 import SonnenBatterieV2
sb_host = '192.168.1.2'
sb_token = 'SeCrEtToKeN' # retrieve via Web UI of SonnenBatterie
sb2 = SonnenBatterieV2(sb_host, sb_token)
print(sb2.get_configurations()) # retrieve configuration overview
print(sb2.get_battery_module_data()) # get battery module data
print(sb2.get_inverter_data()) # retrieve inverter data
print(sb2.get_latest_data()) # get latest date from sonnenbatterie
print(sb2.get_powermeter_data()) # get data from power meters
print(sb2.get_status()) # get overall status information
print(sb2.get_io_data()) # get io status
SonnenAPI v2 - async
# API v2
# can either be access directly, see below, or
# via sb.sb2 (gets initialiazed automatically when creating a V1 object)
from sonnebatterie2 import AsyncSonnenBatterieV2
sb_host = '192.168.1.2'
sb_token = 'SeCrEtToKeN' # retrieve via Web UI of SonnenBatterie
sb2 = AsyncSonnenBatterieV2(sb_host, sb_token)
print(await sb2.get_configurations()) # retrieve configuration overview
print(await sb2.get_battery_module_data()) # get battery module data
print(await sb2.get_inverter_data()) # retrieve inverter data
print(await sb2.get_latest_data()) # get latest date from sonnenbatterie
print(await sb2.get_powermeter_data()) # get data from power meters
print(await sb2.get_status()) # get overall status information
print(await sb2.get_io_data()) # get io status
# Async needs to close the connection!
await sb.logout()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sonnenbatterie-0.7.dev5.tar.gz.
File metadata
- Download URL: sonnenbatterie-0.7.dev5.tar.gz
- Upload date:
- Size: 32.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d924a3b5c64dff3204fcfd5a430eda6c4bd2def5dc90ca2c35e284ca8cf590b8
|
|
| MD5 |
00e8cd50eee7dcd9b4220b64bf75e5b2
|
|
| BLAKE2b-256 |
0869d7fa1d0e45b4172ee7828a5f0634c989082cd679f9cffcf7fcaea2be20d7
|
File details
Details for the file sonnenbatterie-0.7.dev5-py3-none-any.whl.
File metadata
- Download URL: sonnenbatterie-0.7.dev5-py3-none-any.whl
- Upload date:
- Size: 26.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2eebc9794059fce2cd184eb58e872199ee259680ba33f9d2524bce7bcd96dc6c
|
|
| MD5 |
cdff610e30678af4158326a7d282a780
|
|
| BLAKE2b-256 |
085e0f7bf3f1053f1456b2fc0450ac2ad54845a9cb41e35da99ac59cbb753da9
|