Skip to content

Monitoring the Huawei SUN2000L KTL L1 inverter via Modbus TCP and publishing the values to MQTT

Notifications You must be signed in to change notification settings

ccorderor/huawei-sun2000-modbus-mqtt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Huawei SUN2000 KTL L1 Inverter Modbus TCP to MQTT

Monitoring the Huawei SUN2000L KTL L1 inverter via Modbus TCP and publishing the values to MQTT

What is this?

This script allows to control a Huawei SUN2000L KTL L1 inverter via Modbus TCP and to publish the values in MQTT (for use in node-red, Home Assistant, OpenHab...).

I created this script because the examples I found on the internet did not work with the dongle (SDongle A52) using LAN connection and not via WiFi. It seems that the SUN2000L is quite peculiar with its Modbus TCP protocol...

I use the HuaweiSolar library (https://gitlab.com/Emilv2/huawei-solar) from Emilv2. I only extract the data I am interested in, but of course, you can include all the data provided by the inverter via Modbus TCP.

Finally, there is also the possibility to build a docker image and launch it in any environment.

A lot of information, code and knowledge extracted from:

Howto generate docker container

First, download the code from this repo (you can either clone the repo or download the gzip file and extract it). You should download it in the same computer you are going to run the container.

Modify the huaweisolar.py script and add any additional parameters you wish to log into the vars and vars_inmediate variables, see the library source for the possible values of the sources, see: https://gitlab.com/Emilv2/huawei-solar/-/blob/master/src/huawei_solar/register_names.py

Then, you need to generate the docker image. Enter inside the code folder, and execute the following command:

docker build -t huawei-solar .

Once the docker image has been generated, you can use the following docker-compose service to initialize it:

 huawei-solar:
    container_name: huawei-solar
    restart: unless-stopped
    image: huawei-solar:latest
    environment:
      - INVERTER_IP=XXX.XXX.XXX.XXX
      - MQTT_HOST=XXX.XXX.XXX.XXX

Save as: docker-compose.yml Run:

docker compose up -d

Docker container

docker

Node-red mqtt listeners

node-red

About

Monitoring the Huawei SUN2000L KTL L1 inverter via Modbus TCP and publishing the values to MQTT

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •