question

shop6 avatar image
shop6 asked

Why do DBUS requests to Cerbo GX via python/paramiko/ssh take so long (0.5 sec/call)?

Getting this (attributes) 
/Dc/Battery/Soc
/Yield/System
/Ac/L1/Energy/Forward
/Ac/L2/Energy/Forward
/System/MinCellVoltage
/System/MaxCellVoltage
/System/MinCellTemperature
/System/MaxCellTemperature
/System/MinVoltageCellId
/System/MaxVoltageCellId
/System/MinTemperatureCellId
/System/MaxTemperatureCellId
needs more than 10 seconds.

Is there a faster way to read out the current data from the Victron system?



cerbo gxModbus TCP
1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

kevgermany avatar image kevgermany ♦♦ commented ·

@shop6 Moved to modifications space.

0 Likes 0 ·
2 Answers
Kevin Windrem avatar image
Kevin Windrem answered ·

The command line dbus calls do take a while but there is another call: dbus-send that takes far less time per call.

Look here:

https://github.com/victronenergy/venus/wiki/commandline---development

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

shop6 avatar image
shop6 answered ·

There is a faster alternative: modbustcp calls by pymodbus, see below.

Unfortunately, not all values readable via dbus are available, e.g. /Yield/System, and the values supplied via modbustcp, e.g. /System/MinCellVoltage:1290, are less precise.

Modified sample code from https://community.victronenergy.com/questions/190594/need-help-with-python-modbus-queery.html, tested with pymodbus-3.6.8 on Python 3.9.2, RaspberryPiCM4, CerboGX v3:

from pymodbus.constants import Endian
from pymodbus.client import ModbusTcpClient as ModbusClient
from pymodbus.payload import BinaryPayloadDecoder
BattID = 225
ip = "192.168.2.38"
client = ModbusClient(ip, port='502')
def modbus_register(address, slave):
    msg     = client.read_holding_registers(address, slave=slave)
    decoder = BinaryPayloadDecoder.fromRegisters(msg.registers, byteorder=Endian.BIG)
    msg     = decoder.decode_16bit_int()
    return msg
BatterySOC  = modbus_register(266, BattID) / 10
print(f"BatterySOC {BatterySOC}")
1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

outsourcedguru avatar image outsourcedguru commented ·
Rather than using ip, you might just hard-code in " venus.local".
0 Likes 0 ·