Hey Guys, having a strange issue with MODBUS data points.
I have recently migrated a water management system across from Mango Automation, which I was happy with until they sold to another business who ended up not having as good support and the newer versions of the software were very buggy and unusable for my application. Anyways…
Most of the sensors in my setup use MODBUS over TCP. I have successfully got these to come in to HA without issue.
I have 2 tank sensors that are ultrasonic style and their data is available via RS485 MODBUS. I’ve got a pair of simple RTU’s at each of the tanks converting MODBUS TCP to Serial RS485 MODBUS. These work in the old system no worries, however when I try to retrieve data from them in HA, I get all kinds of timeout errors as you’ll see below…
I’m trying to work out the difference in the MODBUS config between tcp and rtuovertcp and which one I should be using for these 2 sensors, there isn’t much explanation of what the two config options do.
Here is some snippets of my config, some working screenshots of data coming back with a MODBUS test tool, and some error logs. I’m hoping someone is out there with some more MODBUS skills than myself and they can see the error of my ways…
- name: "Solar Tank"
type: tcp
host: 10.42.0.13
port: 502
close_comm_on_error: true
delay: 5
timeout: 5
retry_on_empty: true
retries: 10
sensors:
- name: "Solar Tank Level Raw"
address: 521
input_type: holding
#unit_of_measurement: in
count: 1
offset: 0
data_type: uint16
#scan_interval: 10
scale: 0.003384
The log seems to have entries relating to timeouts, however there doesn’t seem to be any sort of network outages. The other entries relate to unexpected close of comms. Is it maybe timing out after 5 seconds due to my timeout setting? I wouldn’t think it would take more than a couple of ms to read a single holding register
2023-02-14 06:42:30.820 ERROR (SyncWorker_8) [homeassistant.components.modbus.modbus] Pymodbus: Top Tank: Modbus Error: [Connection] ModbusTcpClient(10.42.0.16:502): Connection unexpectedly closed 1.2159347534179688e-05 seconds into read of 8 bytes without response from unit before it closed connection
2023-02-14 06:42:31.082 ERROR (SyncWorker_3) [homeassistant.components.modbus.modbus] Pymodbus: Solar Tank: Exception Response(131, 3, GatewayNoResponse)
I am only reading the first value 0x0208 or 520 in decimal, although I have to add 1 because MODBUS