Reads Deye solar inverter metrics using Modbus over TCP and publishes them over MQTT.
The meaning of certain inverter registers depends on the inverter type. You should choose metric group(s) that are appropriate to your inverter model. If your inverter is not listed below, it may still work with one of the already existing metric groups. Give it a try and experiment. In the worst case it won't work.
When your inverter is not supported, feel free to open an issue in this github project. Maybe, together we will find a way to add the support.
When your inverter turns out to work well with an already exiting metrics group, then please be so kind, and let me know in this issue. This will help in building the list of supported inverters below. Thanks!
Inverter model | Metric groups |
---|---|
Deye SUN-4K-G05 | string |
Deye SUN300G3 | micro |
Deye SUN600G3 | micro |
Deye SUN1300G3 | micro |
Deye SUN1600G3 | micro |
Bosswerk MI600 | micro |
Deye SUN-5/6/8/10/12K-SG04LP3 | deye_sg04lp3, deye_sg04lp3_battery |
Reports deye-inverter-mqtt service status (not the inverter/logger status):
online
- when the service is connected to the MQTT brokeroffline
- when the service is disconnected from the MQTT broker
The default topic name is status
and can be changed in the configuration.
Reports solar inverter's logger connectivity status
online
- when the service connect to the logger successfullyoffline
- when the service can't connect to the logger
The default topic name is logger_status
and can be changed in the configuration.
Monitors current logger status and sets the time at the logger/inverter once the connection to it can be established.
This is useful in a setup where the inverter has no access to the public internet, or is cut off from the Solarman cloud services.
This feature is disabled by default and must be activated by setting DEYE_FEATURE_SET_TIME
in the config file.
-
Copy
config.env.example
asconfig.env
-
Fill in values in
config.env
, see Configuration for more details -
Run the container
docker run --rm --env-file config.env ghcr.io/kbialek/deye-inverter-mqtt
Docker container fails to start with error message: PermissionError: [Errno 1] Operation not permitted
It can happen on debian buster based linux distributions, including raspbian.
Solution: Install libseccomp2
from the backports
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 04EE7237B7D453EC 648ACFD622F3D138
echo "deb http://deb.debian.org/debian buster-backports main" | sudo tee -a /etc/apt/sources.list.d/buster-backports.list
sudo apt update
sudo apt install -t buster-backports libseccomp2
All configuration options are controlled through environment variables.
LOG_LEVEL
- application log level, can be any ofDEBUG
,INFO
,WARN
,ERROR
DEYE_DATA_READ_INTERVAL
- interval between subsequent data reads, in seconds, defaults to 60DEYE_METRIC_GROUPS
- a comma delimited set of:string
- string invertermicro
- micro inverterdeye_sg04lp3
- sg04lp3 inverterdeye_sg04lp3_battery
- sg04lp3 battery
DEYE_LOGGER_SERIAL_NUMBER
- inverter data logger serial numberDEYE_LOGGER_IP_ADDRESS
- inverter data logger IP addressDEYE_LOGGER_PORT
- inverter data logger communication port, typically 8899DEYE_FEATURE_MQTT_PUBLISHER
- controls, if the service will publish metrics over mqtt, defaults totrue
DEYE_FEATURE_SET_TIME
- when set totrue
, the service will automatically set the inverter/logger time, defaults tofalse
MQTT_HOST
- MQTT Broker IP addressMQTT_PORT
- MQTT Broker port, typically 1883MQTT_USERNAME
- MQTT Broker username for authenticationMQTT_PASSWORD
- MQTT Broker password for authenticationMQTT_TOPIC_PREFIX
- mqtt topic prefix used for all inverter metricsMQTT_AVAILIBILITY_TOPIC
- mqtt availability topic, defaults tostatus
MQTT_LOGGER_STATUS_TOPIC
- logger connectivity status topic, defaults tologger_status
The tool allows reading and writing raw register values directly in the terminal.
USE AT YOUR OWN RISK! Be sure to know what you are doing. Writing invalid values may damage the inverter. By using this tool you accept this risk and you take full responsiblity for the consequences.
-
To read register value execute:
docker run --rm --env-file config.env ghcr.io/kbialek/deye-inverter-mqtt r <reg_address>
where
<reg_address>
is register address (decimal) -
To write register value execute:
docker run --rm --env-file config.env ghcr.io/kbialek/deye-inverter-mqtt w <reg_address> <reg_value>
where
<reg_address>
is register address (decimal), and <reg_value> is a value to set (decimal)
- Install python dependencies
pip install -r requirements.txt
- Running the code
- Option 1 - Run the code locally without using Docker
- Fill in
config.env
file - Execute
make run
- Fill in
- Option 2 - Build a new docker image locally (for amd64 architecture)
- Execute
make docker-build-local
- Fill in
config.env
file - Execute
make docker-run
- Execute
- Option 1 - Run the code locally without using Docker
- To run the tests use:
make test
make test-mqtt
- requires mosquitto MQTT broker binary