Closed kimb1 closed 1 year ago
Plot thickens - I can communicate with the inverter using the python package pyModbusTCP but not pymodbus in TCP mode
The test script below will read three registers using "c1" but not "c2". I can repeat this on the HomeAssistant instance and on a plain Debian box.
I'll keep at it - I'm sure I'm doing something stupid here.
from pyModbusTCP.client import ModbusClient
from pymodbus.client import ModbusTcpClient
# init modbus client
c1 = ModbusClient(host='192.168.3.107', port=502, debug=True, auto_open=True)
c2 = ModbusTcpClient(host='192.168.3.107', port=502, debug=True, auto_open=True)
# if success display registers
print ("trying v1")
regs_l = c1.read_holding_registers(43006, 3)
if regs_l:
print('reg ad #0 to 9: %s' % regs_l)
else:
print('unable to read registers via c1')
print ("trying v2")
regs_2 = c2.read_holding_registers(43006, 3)
# if success display registers
if regs_2:
print('reg ad #0 to 9: %s' % regs_2)
else:
print('unable to read registers via c2')
~ #
[Waveshare RS485 to WIFI/ETH](https://www.waveshare.com/wiki/RS485_TO_WIFI/ETH)
This RS485 adaptor is very problematic:
There seems to be delayed communications,
Struggles to read more than 7 registers at a time,
Modbus Error: [Input/Output] Unable to decode request,
No ability to set "Auto query storage type" for Sofar Inverters.
Thank you - sorry, I'd missed that entry. I got drawn in by other GitHub projects which seemed to use it successfully.
I now have it working with the Waveshare device in Modbus RTU over TCP mode, with the Waveshare set to "transparent". So the Modbus protocol is now in python not in the Waveshare.
Will monitor and see how it goes, but possibly put together a different device.
Thanks!
@kimb1 can you document/describe what you did to make it work?
As above: I have a configuration which has been working for several days apparently successfully
SolaX Inverter Modbus configured:
So the key is not using the Waveshare to do Modbus/TCP to Modbus over serial conversion itself.
The Modbus protocol is now in Python in HomeAssistant and the TCP connection and Waveshare are a "dumb pipe for bytes" This seems to avoid the issues in the FAQ reading more than 7 registers at a time.
Because the Waveshare has no awareness of open or completed Modbus requests I think it would be inadvisable to have multiple clients connect to the Waveshare (as is apparently possible in some other projects to have the Solis datalogger active to the Solis cloud simultaneously with HomeAssistant). But in my setup I don't need that, only HA to the Solis.
Solis 5kW, Waveshare RS485 to Wifi using Modbus TCP - Modbus RTU gateway mode.
Seems generally to work - a lot of addresses read fine. I can aparently read addresses with other modbus tools separately.
Integration gets down to "battery_charge_direction" and dies with an error reading modbus data.
`2023-09-19 23:38:32.901 ERROR (MainThread) [pymodbus.logging] General exception: unpack requires a buffer of 2 bytes 2023-09-19 23:38:32.904 ERROR (MainThread) [pymodbus.logging] Modbus IO exception Modbus Error: [Input/Output] Unable to decode request 2023-09-19 23:38:32.907 ERROR (MainThread) [custom_components.solax_modbus] Something went wrong reading from modbus Traceback (most recent call last): File "/config/custom_components/solax_modbus/init.py", line 436, in read_modbus_data res = self.read_modbus_registers_all() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/solax_modbus/init.py", line 545, in read_modbus_registers_all self.data[descr.key] = descr.value_function(0, descr, self.data ) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/solax_modbus/const.py", line 213, in value_function_battery_output_solis inout = datadict["battery_charge_direction"]