meltaxa / solariot

Leverage your IoT enabled Solar PV Inverter to stream your solar energy usage data to a real time dashboard.
https://solariot.live
MIT License
210 stars 71 forks source link

RPi4 HA Docker - MQTT No sensor/intergration - modbus proxy? #102

Open EvoSems opened 9 months ago

EvoSems commented 9 months ago

Hi guys. great project, this is the only option I could find that will work with my SG5KD, as there is no useable lan port (is there one inside the unit??) I have the smart meter connected to my other port which reads my grid data (SG Smart Meter_002_001)

I'm not very code friendly. but I have managed to create my docker file and integrate to HA Core on my Rpi4. with my following command.

sudo docker run -v -d --name solariot --restart=unless-stopped -v /home/xxx/solariot:/config --network=host meltaxa/solariot:latest

inverter_ip = "192.168.xx.xxx" inverter_port = 502 slave = 0x01 model = "sungrow-sg5kd" timeout =5 scan_interval =30

It takes a lot of effort to get connected. I have to keep restarting my container and maybe once an hour (retrying to connect 50 times or more) I can connect. but if I restart my rpi or the container I have to spend forever to connect again. what is causing this? but when it does connect its great! could we look into something like a proxy -- https://github.com/mkaiser/Sungrow-SHx-Inverter-Modbus-Home-Assistant/wiki/FAQ:-My-Modbus-connection-always-cuts-out

WARNING:root:Modbus connection failed WARNING:root:Failed to scrape inverter, sleeping until next scan

anyway..

I can read the logs from inside Portainer interface which is working great!

INFO:root:{'daily_power_yield': 2900.0, 'total_power_yield': 447.73, 'internal_temp': 41.9, 'pv1_voltage': 301.1, 'pv1_current': 3.7, 'pv2_voltage': 305.9, 'pv2_current': 3.7, 'total_pv_power': 2262, 'grid_voltage': 244.8, 'inverter_current': 9.5, 'total_active_power': 2262, 'grid_frequency': 50.0, 'export_power': -325, 'export_power_indicator': 65535, 'power_meter': 1936, 'daily_purchased_energy': 9.1, 'daily_energy_consumption': 2600.0, 'total_energy_consumption': 779.2, 'year': 2024, 'month': 1, 'day': 31, 'hour': 8, 'minute': 48, 'second': 31, 'timestamp': '31/1/2024 8:48:31'} INFO:root:Published to MQTT INFO:root:{'daily_power_yield': 2900.0, 'total_power_yield': 447.73, 'internal_temp': 41.8, 'pv1_voltage': 301.2, 'pv1_current': 3.6, 'pv2_voltage': 304.0, 'pv2_current': 3.6, 'total_pv_power': 2216, 'grid_voltage': 244.6, 'inverter_current': 9.3, 'total_active_power': 2216, 'grid_frequency': 50.0, 'export_power': -274, 'export_power_indicator': 65535, 'power_meter': 1941, 'daily_purchased_energy': 9.1, 'daily_energy_consumption': 2600.0, 'total_energy_consumption': 779.2, 'year': 2024, 'month': 1, 'day': 31, 'hour': 8, 'minute': 48, 'second': 38, 'timestamp': '31/1/2024 8:48:38'} INFO:root:Published to MQTT

I can also receive the MQTT messages within HA Core MQTT Listen setting:

{ "daily_power_yield": 3300, "total_power_yield": 447.73, "internal_temp": 44, "pv1_voltage": 300.9, "pv1_current": 4.1, "pv2_voltage": 305.4, "pv2_current": 4.1, "total_pv_power": 2500, "grid_voltage": 243.9, "inverter_current": 10.4, "total_active_power": 2420, "grid_frequency": 50, "export_power": 825, "export_power_indicator": 0, "power_meter": 3245, "daily_purchased_energy": 9.1, "daily_energy_consumption": 2900, "total_energy_consumption": 779.5, "year": 2024, "month": 1, "day": 31, "hour": 8, "minute": 55, "second": 41, "timestamp": "31/1/2024 8:55:41" }

I'm just really stuck on the next part to add this data to HA in a useful way within the energy tab. could anyone shed some light. (reminder I do not have the add-on page as core)

other that that this is fantastic! thanks very much for all your time and effort.

p.s is there also a way to link and change the requirements.txt to my /home/xxx/solariot/ directory to be able to edit that and build with different versions. ex pymodbus==2.4.0 (this is as I am using docker image on rpi4. or is this not an issue anymore?