core: Modbus TCP - Function code 0x03 (read holding registers) - Cannot use all registers read
The problem
I’m trying to read several registers representing real 32bits (IEE754). The modbus request is good, but I can’t get my 4 sensors - 32 bits floats (16 bit inverted).
Environment
- Home Assistant Core release with the issue: 2020.12.0
- Last working Home Assistant Core release (if known): 5.4.83
- Operating environment (OS/Container/Supervised/Core): Supervised (VM QNAP)
- Integration causing this issue: Modbus
- Link to integration documentation on our website:
Problem-relevant configuration.yaml
Multiple Modbus TCP connections
modbus:
type: tcp host: 192.168.0.20 port: 502 name: S500
type: tcp host: 192.168.0.25 port: 502 name: WAGO
#sensor:
platform: modbus scan_interval: 10 registers:
name: modbus_group_h1 hub: S500 slave: 1 register: 42124 #register_type: input count: 4 data_type: custom structure: “>4h”
name: modbus_group_h2 hub: S500 slave: 1 register: 54247 #register_type: input count: 8 reverse_order: true data_type: custom structure: “>4f” precision: 1
platform: template sensors:
Modbus Group H1
mdbgroup1_val00: friendly_name: "MdbGroup1_Val00" value_template: "{{ states('sensor.modbus_group_h1')[0] }}" mdbgroup1_val01: friendly_name: "MdbGroup1_Val01" unit_of_measurement: "%" value_template: "{{ states('sensor.modbus_group_h1')[1] }}" mdbgroup1_val02: friendly_name: "MdbGroup1_Val02" value_template: "{{ states('sensor.modbus_group_h1')[2] }}" mdbgroup1_val03: friendly_name: "MdbGroup1_Val03" unit_of_measurement: V value_template: "{{ states('sensor.modbus_group_h1')[3] }}"
Modbus Group H2
mdbgroup1_val10: friendly_name: "MdbGroup1_Val10" value_template: "{{ states('modbus_group_h2')[0] }}" mdbgroup1_val11: friendly_name: "MdbGroup1_Val11" unit_of_measurement: W value_template: "{{ states('modbus_group_h2')[1] }}" mdbgroup1_val12: friendly_name: "MdbGroup1_Val12" unit_of_measurement: W value_template: "{{ states('modbus_group_h2')[2] }}" mdbgroup1_val13: friendly_name: "MdbGroup1_Val13" value_template: "{{ states('modbus_group_h2')[3] }}"
Traceback/Error logs
[pymodbus.transaction] SEND: 0x0 0x8 0x0 0x0 0x0 0x6 0x1 0x3 0xd3 0xe7 0x0 0x8 [pymodbus.transaction] RECV: 0x0 0x8 0x0 0x0 0x0 0x13 0x1 0x3 0x10 0xcc 0xcd 0x40 0xfc 0x99 0x9a 0x41 0x29 0x33 0x33 0x41 0x63 0x33 0x33 0x41 0x4b
Additional information
On the example log, I would like to have : mdbgroup1_val10: 0xcc 0xcd 0x40 0xfc -> reverse order: true -> 0x40 0xfc 0xcc 0xcd = 7.9 f mdbgroup1_val11: 0x99 0x9a 0x41 0x29 -> reverse order: true -> 0x41 0x29 0x99 0x9a = 10.6 f mdbgroup1_val12: … mdbgroup1_val13: …
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 21 (11 by maintainers)
I too am no fan of this method, but we haven’t found another that works with HA (suggestions welcome).
Limiting the number of digits is an easy fix, but I do not think we can find a small number universally acceptable, so it needs to be configurable and that too is easy. But we are not allowed to change the old configuration so PR #46591 to be merged first.
Hello,
For the first issue, I can now find all the registers with a template. But I think it’s not a very clean solution to use a separator to give all the registers of the Modbus response .
For the revers_order I have created a new issue #44553