This script is obsolete.
For a better Home Assistant integration see: https://github.com/littleyoda/ha-pysmaplus
For a script that supports more devices and delivers the data also via mqtt, see: https://github.com/littleyoda/pysma/tree/master/scripts/pysma2mqtt
Script which reads out the current measured values of an inverter of the SMA Tripower x (STP XX-50) series and makes them available via MQTT to Home Assistant. For other inverter and even for other SMA inverter series, the script will most likely not work.
Optionally, the measured values from SMA Energy Meter or Sunny Home Manager can also be received and makes them also available via MQTT to Home Assistant.
Home Assistant detects the sensors automatically via MQTT Discovery.
The Python script is a proof of concept. I have been using the script myself for a few successful weeks now.
The script cannot currently be executed as an add-on or similar in Home Assistant. It has to be started manually on a computer with installed Python.
Most values from the Tripower-X Inverter are only returned if the PV system also produces electricity. At times when no electricity is produced, only a fraction of the measured values are returned.
To install the libraries necessary for the script, the following instruction must be executed. pip install -r requirements.txt
For use, an MQTT server (e.g. Mosquitto broker Add-On) must be running and the MQTT integration in Home Assistant must be active.
The config file (sma2mqtt.yaml) must be changed before use.
Since the script works for me, I will probably not invest any more time. However, I am open to pull requests. It would be nice if someone could turn the script into a home assistant integration.