Does the modbus_controller:: sensor parameter “register_count” work? Cause is sure doesn’t do what I expect!
I read three blocks from a Renogy battery: v_cell[1-4] @ 5001 then t_cell[1-4] @ 5018 and then overall battery values (temp, current, voltage,…) @ 5042
The yaml, below, is the first sensor (by address) with the “register_count” followed by all the other sensors.
I tried to gather everything in one read (register_count: 52), but that failed (see log below), so I tried just bundling the first two blocks (register_count: 21) and instead of one read I get the first sensor (the one with the register_count) then a second read for the remaining three sensors, then the next block of sensors, etc. I.e. register_count seems to fragment, not gather registers into a command.
It would appear the register count is working, but not extending to subsequent sensors within the range. Not having any “register_count:” specified gives me the least number of commands/reads. I would prefer to bundle due to the modbus overhead + whatever ESPHome is doing between commands.
What have I missed?
# Granular cell values
- id: ${modbus_id}_v_cell1
name: ${modbus_id} Voltage Cell 1
platform: modbus_controller
modbus_controller_id: ${modbus_id}
address: 5001
unit_of_measurement: 'V'
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
# register_count: 52 # read everything at once
register_count: 21 # bundle up v and t, doesn't work.
filters:
- multiply: 0.1
NB this log is with “register_count: 52” with 21 the command works.
[11:22:14.988][I][main:582]: battery1 command sent
[11:22:14.992][D][modbus:157]: Modbus error function code: 0x83 exception: 2
[11:22:14.994][E][modbus_controller:094]: Modbus error function code: 0x3 exception: 2
[11:22:15.002][E][modbus_controller:098]: Modbus error - last command: function code=0x3 register address = 0x1389 registers count=52 payload size=0
[11:22:15.033][I][main:582]: battery1 command sent
[11:22:15.064][D][modbus_controller.sensor:025]: Sensor new state: 33.00
[11:22:15.064][D][sensor:131]: 'battery1 Voltage Cell 2': Sending state 3.30000 V with 1 decimals of accuracy
[11:22:15.070][D][modbus_controller.sensor:025]: Sensor new state: 33.00
[11:22:15.073][D][sensor:131]: 'battery1 Voltage Cell 3': Sending state 3.30000 V with 1 decimals of accuracy
[11:22:15.080][D][modbus_controller.sensor:025]: Sensor new state: 33.00
[11:22:15.080][D][sensor:131]: 'battery1 Voltage Cell 4': Sending state 3.30000 V with 1 decimals of accuracy
[11:22:15.080][I][main:582]: battery1 command sent
[11:22:15.112][D][modbus_controller.sensor:025]: Sensor new state: 100.00
[11:22:15.130][D][sensor:131]: 'battery1 Temp Cell 1': Sending state 10.00000 °C with 1 decimals of accuracy
[11:22:15.130][D][modbus_controller.sensor:025]: Sensor new state: 100.00
[11:22:15.145][D][sensor:131]: 'battery1 Temp Cell 2': Sending state 10.00000 °C with 1 decimals of accuracy
[11:22:15.145][D][modbus_controller.sensor:025]: Sensor new state: 100.00
[11:22:15.145][D][sensor:131]: 'battery1 Temp Cell 3': Sending state 10.00000 °C with 1 decimals of accuracy
[11:22:15.145][D][modbus_controller.sensor:025]: Sensor new state: 100.00
[11:22:15.145][D][sensor:131]: 'battery1 Temp Cell 4': Sending state 10.00000 °C with 1 decimals of accuracy
[11:22:15.145][I][main:582]: battery1 command sent
[11:22:15.163][D][modbus_controller.sensor:025]: Sensor new state: 47.00
[11:22:15.163][D][sensor:131]: 'battery1 Current': Sending state 0.47000 A with 2 decimals of accuracy
[11:22:15.215][D][modbus_controller.sensor:025]: Sensor new state: 133.00
[11:22:15.215][D][sensor:131]: 'battery1 Voltage': Sending state 13.30000 V with 1 decimals of accuracy
[11:22:15.218][D][modbus_controller.sensor:025]: Sensor new state: 85666.00
[11:22:15.241][D][sensor:131]: 'battery1 Remaining Capacity': Sending state 85.66600 AH with 1 decimals of accuracy
[11:22:15.250][D][modbus_controller.sensor:025]: Sensor new state: 99333.00
[11:22:15.250][D][sensor:131]: 'battery1 size': Sending state 99.33301 AH with 1 decimals of accuracy
[11:22:15.257][D][modbus_controller.sensor:025]: Sensor new state: 142.00
[11:22:15.257][D][sensor:131]: 'battery1 Total Cycles': Sending state 142.00000 Cycles with 0 decimals of accuracy