Akulatraxas / ha-modbusproxy

Hassio Addon packaging modus-proxy
Apache License 2.0
31 stars 4 forks source link

Set Slave ID (for Huawei) #11

Open GrandAmmor opened 1 year ago

GrandAmmor commented 1 year ago

I'm using your Add-On for a Sungrow modbus-proxy and it works perfectly well!

Now I tried tne same on a different home assistant instance with a Huawei Sun2000 inverter. It runs into 'connection refused' as long as I can't set the slave ID to '0'.

I tried https://github.com/wlcrs/huawei_solar to show the values and it works with the same IP and port as I tried with your add-on. Just the configuration of slave ID is missing I guess.

Can you help me with that issue?

Thx for your work anyways!

Akulatraxas commented 1 year ago

Mhh, from looking through that documentation it looks like the slave_id is only relevant if you use a RS Connections, not for a tcp-connection? Before looking deeper into it have you make sure that you disconnected all clients from the Sun2000 inverter and waited at least 10 minutes before trying to start the add-on ?

GrandAmmor commented 1 year ago

Thanks for your quick reply!

I disconected all devices and waited around 30 min till I started the add-on.

Now it shows this error (connecting to the dongle IP): 2023-02-26 18:03:36,105 INFO modbus-proxy: Starting... 2023-02-26 18:03:36,118 INFO modbus-proxy.ModBus(192.168.178.35:502): Ready to accept requests on 0:502 2023-02-26 18:04:23,723 INFO modbus-proxy.Client(192.168.178.254:58304): new client connection 2023-02-26 18:04:24,724 DEBUG modbus-proxy.Client(192.168.178.254:58304): received b'\x00\x01\x00\x00\x00\x06\x01\x03}@\x00\x02' 2023-02-26 18:04:24,726 INFO modbus-proxy.ModBus(192.168.178.35:502): connecting to modbus... 2023-02-26 18:04:24,733 INFO modbus-proxy.ModBus(192.168.178.35:502): connected! 2023-02-26 18:04:24,734 INFO modbus-proxy.ModBus(192.168.178.35:502): delay after connect: 1 2023-02-26 18:04:25,738 DEBUG modbus-proxy.ModBus(192.168.178.35:502): sending b'\x00\x01\x00\x00\x00\x06\x01\x03}@\x00\x02' 2023-02-26 18:04:25,739 ERROR modbus-proxy.ModBus(192.168.178.35:502): write_read error [1/2]: IncompleteReadError('0 bytes read on a total of 6 expected bytes')

And if I use the other IP of the inverter (eth), this error shows up:

2023-02-26 18:13:50,947 ERROR modbus-proxy.ModBus(192.168.178.36:502): write_read error [1/2]: ConnectionRefusedError(111, "Connect call failed ('192.168.178.36', 502)")

It was so easy with sungrow, but Huawei drives me crazy...

GrandAmmor commented 1 year ago

Do you think you can implement a modbus-proxy feature?

Your integration works like a charm and I would to see other services using your integration as a modbus proxy.

In don't know how much works that would be. This is why I'm asking that naive way ;)

vinc32 commented 1 year ago

i do have the same issue. any solution here?

PulsarFX commented 6 months ago

In the source repo for this addon: https://github.com/tiagocoutinho/modbus-proxy I've seen similar logs for sun2000 inverters. Seems like it needs some delay to work

Roving-Ronin commented 1 week ago

Shame this modbus (tcp) proxy isn't written in C++, it would be excellent if it was able to run upon an ESP32 board, using ESPHome. Could add these inputs / pulldown selections to the web interface (that would also make them accessible in Home Assistant) for setting the modbus servers IP and port your wanting to query, as well as the port the proxy accepts queries upon. US$5 board (RISC IV @ 240Mhz) consuming a few watts of power and that boots in a few seconds.

Would also mean centralisation of the code being possible, with people able to add this to an espome device and pull the code into an esp and run it. Example:

external_components:
  - source: github://dentra/esphome-components