Hello.
I have updated to pymodbus 3.1.3 and have now dificulties to read VenusOS data, other than from the com.victronenergy.system (Id=100)
My Solar Cgargers have the IDs 238 and 239 and show up like this in the Modbus Page.
With the code below I demand Voltage and SOC from ID 100, but when refering to ID 238, an error message appears.
This is the output of the code below:
Battery Voltage from System 100: 263 SOC: 72 Error: Exception Response(132, 4, GatewayPathUnavailable).
In the modbus section of Venus OS I read:
"Error processing function code 4, unit id 0, start address 789, quantity 1, src 192.168.178.41: error finding service with device type solar charger at device instance 0"
So, somehow I am doing something wrong, adressing the correct ID, I guess.
Does anybody know, how to change the code to make it work?
Thanks already in advance.
Here is the Python3 code:
from pymodbus.constants import Endian
from pymodbus.client import ModbusTcpClient
from pymodbus.payload import BinaryPayloadDecoder
client = ModbusTcpClient('192.168.178.50', port=502, timeout=3, unit_id=100)
result = client.read_input_registers(840, 1)
if not result.isError():
decoder = BinaryPayloadDecoder.fromRegisters(result.registers, byteorder=Endian.Big)
voltage = decoder.decode_16bit_uint()
print("Battery Voltage from System 100:")
print(voltage)
else:
print("Error:", result)
result = client.read_input_registers(843, 1)
if not result.isError():
decoder = BinaryPayloadDecoder.fromRegisters(result.registers, byteorder=Endian.Big)
SOC = decoder.decode_16bit_uint()
print("SOC:")
print(SOC)
else:
print("Error:", result)
client = ModbusTcpClient('192.168.178.50', port=502, timeout=3, unit_id=238)
result = client.read_input_registers(789, 1)
if not result.isError():
decoder = BinaryPayloadDecoder.fromRegisters(result.registers, byteorder=Endian.Big)
voltage = decoder.decode_16bit_uint()
print("PV Power from Solar Charger:")
print(voltage)
else:
print("Error:", result)