Closed rainerbeck closed 1 year ago
Hey there @adamchengtkc, @janiversen, @vzahradnik, mind taking a look at this issue as it has been labeled with an integration (modbus
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
modbus documentation modbus source (message by IssueLinks)
Read the error message (in .4), it never worked, but now we catch it instead of sometimes producing bad data.
I did read the error message. It does not work with any larger datatype despite being 2 bytes registers the most. And it did work before and yielded usable and correct data. What would be the workaround?
It does work with e.g. datatype int32. A word is 4 bytes.
Solution is to correct your configuration swap:word or datatype:
workaround is not upgrade
Thank You for Your quick reply….
- name: BDC rated power
unique_id: sg_bdc_rated_power
slave: !secret sungrow_modbus_slave
address: 5627 # reg 5628
input_type: input
count: 1
data_type: int32
swap: word
unit_of_measurement: "W"
device_class: power
state_class: measurement
scale: 100
scan_interval: 600
Gives
Error in sensor BDC rated power swap(word) impossible because datatype(int32) is too small @ data['modbus'][0]['sensors'][19]. Got {'name': 'BDC rated power', 'unique_id': 'sg_bdc_rated_power', 'slave': 1, 'address': 5627, 'input_type': 'input', 'count': 1, 'data_type': 'int32', 'swap': 'word', 'unit_of_measurement': 'W', 'device_class': 'power', 'state_class': 'measurement', 'scale': 100, 'scan_interval': 600}
So the change of the datatype does not fix it. Does not work with larger datatype as int64 (neither uint32 oder uint64), tried that before writing the bug….
That must be .3, with .4 that should work but you have other problems, why have you configured count: 1, read the documentation it is calculated.
for int32 you need 2 registers, so count should be 2.
Btw....how come you change datatype that easy, your device delivers only one datatype and that must be matched.
You are completely right… The datatype delivered is different, but it shouldn‘t matter if I put a in16 in a int32. The error message might still be misleading as a swap: word should work with an int32….
Nevertheless, the configuration seems to be messed up and I will try to rewrite and adapt…
Thank You for Your feedback and Your effort!
The problem
Loading of the configurations fails with error message Invalid config for [modbus]: Error in sensor BDC rated power swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][19]. Got {'name': 'BDC rated power', 'unique_id': 'sg_bdc_rated_power', 'slave': 1, 'address': 5627, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'unit_of_measurement': 'W', 'device_class': 'power', 'state_class': 'measurement', 'scale': 100, 'scan_interval': 600}
Therefore the modbus-Sensors are no longer working.
What version of Home Assistant Core has the issue?
Core-2023.8.3 and Core-2023.8.4
What was the last working version of Home Assistant Core?
Core-2023.8.2
What type of installation are you running?
Home Assistant OS
Integration causing the issue
ModBus
Link to integration documentation on our website
No response
Diagnostics information
No response
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
No response