ccorderor / huawei-sun2000-modbus-mqtt Goto Github PK
View Code? Open in Web Editor NEWMonitoring the Huawei SUN2000L KTL L1 inverter via Modbus TCP and publishing the values to MQTT
Monitoring the Huawei SUN2000L KTL L1 inverter via Modbus TCP and publishing the values to MQTT
Hi everyone,
I was using this library for a while, it served me well, but I recently decided that I wanted more data from my inverter inside node-red and to log it to an influx db, and this python script didn't expose what I wanted so I took the plunge and created a nodered flow that uses ModBus directly, no additional docker image or python script to maintain separately.
here's the nodered flow code:
here's a screenshot:
emon/*
topics.an example 'process device status' output message payload looks like this:
{"state_1":[{"bits":[0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0],"bit0":0,"bit1":1,"bit2":1,"bit3":0,"bit4":0,"bit5":0,"bit6":0,"bit7":0,"bit8":0,"bit9":0,"bit10":0,"bit11":0,"bit12":0,"bit13":0,"bit14":0,"bit15":0}],"state_2":[{"bits":[1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],"bit0":1,"bit1":0,"bit2":1,"bit3":0,"bit4":0,"bit5":0,"bit6":0,"bit7":0,"bit8":0,"bit9":0,"bit10":0,"bit11":0,"bit12":0,"bit13":0,"bit14":0,"bit15":0}],"state_3":0,"alarm_1":[{"bits":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"bit0":0,"bit1":0,"bit2":0,"bit3":0,"bit4":0,"bit5":0,"bit6":0,"bit7":0,"bit8":0,"bit9":0,"bit10":0,"bit11":0,"bit12":0,"bit13":0,"bit14":0,"bit15":0}],"alarm_2":[{"bits":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"bit0":0,"bit1":0,"bit2":0,"bit3":0,"bit4":0,"bit5":0,"bit6":0,"bit7":0,"bit8":0,"bit9":0,"bit10":0,"bit11":0,"bit12":0,"bit13":0,"bit14":0,"bit15":0}],"alarm_3":[{"bits":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"bit0":0,"bit1":0,"bit2":0,"bit3":0,"bit4":0,"bit5":0,"bit6":0,"bit7":0,"bit8":0,"bit9":0,"bit10":0,"bit11":0,"bit12":0,"bit13":0,"bit14":0,"bit15":0}],"pv1_voltage_v":0,"pv1_current_a":0,"pv2_voltage_v":0,"pv2_current_a":0,"input_power_kw":0,"power_grid_voltage_c":234.5,"power_grid_curent_a":0,"peak_active_power_today_kw":5.22,"active_power_kw":0.679,"reactive_power_kw":0,"power_factor_kvar":1,"grid_hz":49.92,"efficiency_percent":100,"internal_temperature_c":29.400000000000002,"insulation_resistance_mohms":3,"device_status":512,"fault_code":0,"startup_time_s":1710921425,"shutdown_time_s":4294967295,"accumulated_energy_yield_kwh":1979.654,"daily_energy_yield_kwh":1.605,"running_status":2,"charge_discharge_w":-731,"bus_voltage_v":438.70000000000005,"battery_soc_percent":92,"working_mode":0.4,"rated_charge_power_w":500,"rated_discharge_power_w":500,"fault_id":0,"current_day_charge_capacity_kwh":8.97,"current_day_discharge_capacity_kwh":6.99,"bus_current":-1.7000000000000002,"battery_temperature_c":36.7,"remaining_time_m":0,"dcdc_version":"","bms_version":"","maximum_charge_power_w":5000,"maximum_discharge_power_w":500,"serial_number":"BT21804169","total_charge_kwh":5583.35,"total_discharge_kwh":5447.14,"device_status_message":"On-Grid"}
Here's what a simple graph in InfuxDB looks like using the above:
Note that on my inverter's dongle firmware it's not possible to have 2 programs connected to the modbus on tcp port 502. i.e. both the python script from this project running at the same time as the NodeRed modbus 'server' instance, thus you can only use either this projects python code, or this nodered flow.
Hope this is useful to someone.
Hi there,
Trying to get this working. I also have a SUN2000-5KTL-L1. I have a vanilla RPI4 with Rabian OS Lite. I've installed your docker image and changed the config as my Sun2000 IP is 192.168.200.1:6607 (port 502 isn't used in the latest firmware).
When I try run the app I get the following error:
sudo docker run huawei-solar Traceback (most recent call last): File "huaweisolar.py", line 2, in <module> from huawei_solar import HuaweiSolar File "/usr/local/lib/python3.8/site-packages/huawei_solar/__init__.py", line 6, in <module> from .bridge import HuaweiSolarBridge # noqa File "/usr/local/lib/python3.8/site-packages/huawei_solar/bridge.py", line 15, in <module> from huawei_solar.huawei_solar import AsyncHuaweiSolar, Result File "/usr/local/lib/python3.8/site-packages/huawei_solar/huawei_solar.py", line 35, in <module> from .registers import REGISTERS, RegisterDefinition File "/usr/local/lib/python3.8/site-packages/huawei_solar/registers.py", line 216, in <module> class TimeOfUseRegisters(RegisterDefinition): File "/usr/local/lib/python3.8/site-packages/huawei_solar/registers.py", line 228, in TimeOfUseRegisters ) -> list[LG_RESU_TimeOfUsePeriod]: TypeError: 'type' object is not subscriptable
Any ideas or things I could troubleshoot?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.