Python wrapper for getting data asynchronously
Project description
GrowattClient
Python wrapper for getting data asynchronously from Growatt inverters via serial RS232/RS485 connection and modbus RTU protocol.
The implementation is based on Growatt Inverter Modbus RTU Protocol V1.20.
Tested with inverters:
- SPH 10000 TL3 BH
Attributes
Depending on the firmware version of your inverter, not all attributes might be available
Holding register attributes
- serial_number
- model_number
- firmware
Input register attributes
| Attribute | Register | Unit | Description | Misc |
|---|---|---|---|---|
| battery_charge | 1011 | kW | Battery charging | |
| battery_charge_lifetime | 1058 | kWh | Battery charged total | |
| battery_charge_today | 1056 | kWh | Battery charged today | |
| battery_discharge | 1009 | kW | Battery discharging | |
| battery_discharge_lifetime | 1054 | kWh | Battery discharged total | |
| battery_discharge_today | 1052 | kWh | Battery discharged today | |
| battery_voltage | 1013 | V | Battery voltage | |
| consumption | Calc | kW | Consumption | {photovoltaics} + {battery_discharge} + {import_from_grid} - {export_to_grid} - {battery_charge} |
| consumption_lifetime | Calc | kWh | Consumption total | {photovoltaics_lifetime} + {battery_discharge_lifetime} + {import_from_grid_lifetime} - {export_to_grid_lifetime} - {battery_charge_lifetime} |
| consumption_today | Calc | kWh | Consumption today | {photovoltaics_today} + {battery_discharge_today} + {import_from_grid_today} - {export_to_grid_today} - {battery_charge_today} |
| export_to_grid | 1029 | kW | Export to grid | |
| export_to_grid_lifetime | 1050 | kWh | Export to grid total | |
| export_to_grid_today | 1048 | kWh | Export to grid today | |
| grid_frequency | 37 | Hz | Grid frequency | |
| grid_voltage | 38 | V | Grid voltage | |
| import_from_grid | 1021 | kW | Import from grid | |
| import_from_grid_lifetime | 1046 | kWh | Import from grid total | |
| import_from_grid_today | 1044 | kWh | Import from grid today | |
| inverter_temperature_1 | 93 | °C | Inverter temperature | |
| inverter_temperature_2 | 94 | °C | The inside IPM in inverter Temperature | |
| inverter_temperature_3 | 1040 | °C | Battery temperature | |
| local_load | 1037 | kW | Inverter local load | |
| local_load_lifetime | 1062 | kWh | Inverter local load total | |
| local_load_today | 1060 | kWh | Inverter local load today | |
| photovoltaics | 1 | kW | Photovoltaics (PV) generation | |
| photovoltaics_1 | 5 | kW | Photovoltaics (PV) 1 | |
| photovoltaics_1_lifetime | 61 | kWh | Photovoltaics (PV) 1 total | |
| photovoltaics_1_today | 59 | kWh | Photovoltaics (PV) 1 today | |
| photovoltaics_1_voltage | 3 | V | Photovoltaics (PV) 1 voltage | |
| photovoltaics_2 | 9 | kW | Photovoltaics (PV) 2 | |
| photovoltaics_2_lifetime | 65 | kWh | Photovoltaics (PV) 2 total | |
| photovoltaics_2_today | 63 | kWh | Photovoltaics (PV) 2 today | |
| photovoltaics_2_voltage | 7 | V | Photovoltaics (PV) 2 voltage | |
| photovoltaics_lifetime | 91 | kWh | Photovoltaics (PV) generation total | |
| photovoltaics_today | Calc | kWh | Photovoltaics (PV) generation today | {photovoltaics_2_today} + {photovoltaics_1_today} |
| self_consumption | Calc | kW | Self Consumption | {consumption} if {export_to_grid} > 0 else {system_production} |
| statement_of_charge | 1014 | % | Statement of charge (SOC), capacity | |
| system_production | Calc | kW | System Production | {photovoltaics} + {battery_discharge} - {battery_charge} |
| system_production_lifetime | Calc | kWh | System Production total | {photovoltaics_lifetime} + {battery_discharge_lifetime} - {battery_charge_lifetime} |
| system_production_today | Calc | kWh | System Production today | {photovoltaics_today} + {battery_discharge_today} - {battery_charge_today} |
| system_production_with_battery_lifetime | 1139 | kWh | System production total (including battery) | |
| system_production_with_battery_today | 1137 | kWh | System production today (including battery) |
How to use the package
import asyncio
import logging
from sys import argv
from growatt_client.growatt import GrowattClient
# defaults
# USB port of RS232/RS485 converter
DEFAULT_PORT = "/dev/ttyUSB0"
# Growatt modbus address
DEFAULT_ADDRESS = 0x1
logging.basicConfig(level=logging.DEBUG)
async def main():
port = str(argv[1]) if len(argv) > 1 else DEFAULT_PORT
address = int(argv[2]) if len(argv) > 2 else DEFAULT_ADDRESS
growatt_client = GrowattClient(
port,
address,
attributes=["import_from_grid_today", "local_load_lifetime"],
)
try:
data = await growatt_client.async_update()
print(f"Sensors data: {data}")
except Exception as error:
print("Error: " + repr(error))
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
Project details
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 growatt_client-1.0.6.tar.gz.
File metadata
- Download URL: growatt_client-1.0.6.tar.gz
- Upload date:
- Size: 3.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2810597e9d56b62e6864f1dfc5f907290645bb6d2317507213195a84f6a79432
|
|
| MD5 |
23f45414c17c3703c49354bce450fbe5
|
|
| BLAKE2b-256 |
4da71814875ac51a79ef011cbcd249540fa6413873a900cf843ac91232d0681e
|
File details
Details for the file growatt_client-1.0.6-py3-none-any.whl.
File metadata
- Download URL: growatt_client-1.0.6-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d02798418135824bfd264060cfab497c62568ee32b549a1a04e27ba43033279
|
|
| MD5 |
fa1789be4b0b9521e4cace7e6a509aa8
|
|
| BLAKE2b-256 |
8a3cac20f7e6f850455ede2c3c56572b494b7037ed461096e3d7f1bb3a7cc23a
|