Hi, I have been testing Modbus under HA and it seems to be behaving in a strange way. I’m making tests with one of my controllers with Modbus interface. This is connected to a Moxa tcpip-rs485 converter (NPort 5230). HA is installed in Oracle VirtualBox in a Win10 box. My configuration.yaml is following:
modbus:
- name: "Ouman EH686 autotalli"
type: serial
method: rtu
port: /dev/ttyS1
baudrate: 38400
bytesize: 8
parity: N
stopbits: 1
delay: 1
timeout: 5
retry_on_empty: true
message_wait_milliseconds: 200
sensors:
- name: "Autotalli T (°C)"
address: 64
count: 1
input_type: holding
scan_interval: 5
slave: 1
unit_of_measurement: °C
scale: 0.01
precision: 1
Basically I want to read only one register (64). I have also been using Modbus Poll and it doesn’t have any problems so reading register 64 is fine. I have also monitored the traffic on COM2 using Serial Port Monitor and I don’t understand it at all. Session log looks following when reading of register is OK:
872 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_COMMSTATUS) DOWN COM2
873 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_COMMSTATUS) UP STATUS_SUCCESS 00 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00 00 00 00 00 .................... 20 COM2
874 26/12/2021 16:36:21 IRP_MJ_READ DOWN 7 COM2
875 26/12/2021 16:36:21 IRP_MJ_READ UP STATUS_SUCCESS 01 03 02 09 e1 7e 5c ....á~\ 7 COM2
876 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_COMMSTATUS) DOWN COM2
877 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_COMMSTATUS) UP STATUS_SUCCESS 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................... 20 COM2
878 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_WAIT_ON_MASK) DOWN COM2
879 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_COMMSTATUS) DOWN COM2
880 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_COMMSTATUS) UP STATUS_SUCCESS 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................... 20 COM2
881 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_SET_WAIT_MASK) DOWN fd 01 00 00 ý... 4 COM2
882 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_WAIT_ON_MASK) UP STATUS_SUCCESS 00 00 00 00 .... 4 COM2
883 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_SET_WAIT_MASK) UP STATUS_SUCCESS COM2
884 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_COMMSTATUS) DOWN COM2
885 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_COMMSTATUS) UP STATUS_SUCCESS 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................... 20 COM2
886 26/12/2021 16:36:21 IRP_MJ_WRITE DOWN 01 03 00 40 00 01 85 de ...@..…Þ 8 8 COM2
887 26/12/2021 16:36:21 IRP_MJ_WRITE UP STATUS_SUCCESS 01 03 00 40 00 01 85 de ...@..…Þ 8 COM2
888 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_COMMSTATUS) DOWN COM2
889 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_COMMSTATUS) UP STATUS_SUCCESS 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................... 20 COM2
890 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_SET_WAIT_MASK) DOWN f9 01 00 00 ù... 4 COM2
891 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_SET_WAIT_MASK) UP STATUS_SUCCESS COM2
892 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_COMMSTATUS) DOWN COM2
893 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_COMMSTATUS) UP STATUS_SUCCESS 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................... 20 COM2
894 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_COMMSTATUS) DOWN COM2
895 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_COMMSTATUS) UP STATUS_SUCCESS 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................... 20 COM2
896 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_WAIT_ON_MASK) DOWN COM2
897 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_WAIT_ON_MASK) UP STATUS_SUCCESS 01 00 00 00 .... 4 COM2
898 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_COMMSTATUS) DOWN COM2
899 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_COMMSTATUS) UP STATUS_SUCCESS 00 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00 00 00 00 00 .................... 20 COM2
900 26/12/2021 16:36:21 IRP_MJ_READ DOWN 7 COM2
901 26/12/2021 16:36:21 IRP_MJ_READ UP STATUS_SUCCESS 01 03 02 09 e1 7e 5c ....á~\ 7 COM2
902 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_COMMSTATUS) DOWN COM2
903 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_COMMSTATUS) UP STATUS_SUCCESS 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................... 20 COM2
904 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_WAIT_ON_MASK) DOWN STATUS_PENDING COM2
905 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_COMMSTATUS) DOWN COM2
906 26/12/2021 16:36:21 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_COMMSTATUS) UP STATUS_SUCCESS 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................... 20 COM2
Bytes 09 e1 give the temperature (9*256+225)/100.
When reading fails the session log looks following:
1000 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_SET_CHARS) UP STATUS_SUCCESS COM2
1001 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_SET_HANDFLOW) DOWN 00 00 00 00 00 00 00 80 05 00 00 00 05 00 00 00 .......€........ 16 COM2
1002 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_SET_HANDFLOW) UP STATUS_SUCCESS COM2
1003 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_CLR_DTR) DOWN COM2
1004 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_CLR_DTR) UP STATUS_SUCCESS COM2
1005 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_CLR_RTS) DOWN COM2
1006 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_CLR_RTS) UP STATUS_SUCCESS COM2
1007 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_MODEMSTATUS) DOWN COM2
1008 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_MODEMSTATUS) UP STATUS_SUCCESS f0 00 00 00 ð... 4 COM2
1009 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_BAUD_RATE) DOWN COM2
1010 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_BAUD_RATE) UP STATUS_SUCCESS 00 96 00 00 .–.. 4 COM2
1011 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_LINE_CONTROL) DOWN COM2
1012 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_LINE_CONTROL) UP STATUS_SUCCESS 00 00 08 ... 3 COM2
1013 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_CHARS) DOWN COM2
1014 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_CHARS) UP STATUS_SUCCESS 00 00 00 00 11 13 ...... 6 COM2
1015 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_HANDFLOW) DOWN COM2
1016 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_HANDFLOW) UP STATUS_SUCCESS 00 00 00 00 00 00 00 80 05 00 00 00 05 00 00 00 .......€........ 16 COM2
1017 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_SET_BAUD_RATE) DOWN 00 96 00 00 .–.. 4 COM2
1018 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_SET_BAUD_RATE) UP STATUS_SUCCESS COM2
1019 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_CLR_RTS) DOWN COM2
1020 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_CLR_RTS) UP STATUS_SUCCESS COM2
1021 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_CLR_DTR) DOWN COM2
1022 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_CLR_DTR) UP STATUS_SUCCESS COM2
1023 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_SET_LINE_CONTROL) DOWN 00 00 08 ... 3 COM2
1024 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_SET_LINE_CONTROL) UP STATUS_SUCCESS COM2
1025 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_SET_CHARS) DOWN 00 00 00 00 11 13 ...... 6 COM2
1026 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_SET_CHARS) UP STATUS_SUCCESS COM2
1027 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_SET_HANDFLOW) DOWN 00 00 00 00 00 00 00 80 05 00 00 00 05 00 00 00 .......€........ 16 COM2
1028 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_SET_HANDFLOW) UP STATUS_SUCCESS COM2
1029 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_SET_DTR) DOWN COM2
1030 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_SET_DTR) UP STATUS_SUCCESS COM2
1031 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_SET_RTS) DOWN COM2
1032 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_SET_RTS) UP STATUS_SUCCESS COM2
1033 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_MODEMSTATUS) DOWN COM2
1034 26/12/2021 16:46:55 IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_GET_MODEMSTATUS) UP STATUS_SUCCESS f0 00 00 00 ð... 4 COM2
Strange thing is that I can’t see IRP_MJ_WRITE or IRP_MJ_READ lines in the case when reading fails. In HA log I just have error:
2021-12-26 16:45:42 ERROR (SyncWorker_0) [homeassistant.components.modbus.modbus] Pymodbus: Ouman EH686 autotalli: Modbus Error: [Input/Output] Modbus Error: [Invalid Message] No response received, expected at least 2 bytes (0 received)
The problem seems to be rather sporadic. If I just restart HA reading of the register may be successful or not. This problem really drives me nuts. Any ideas?
If I can’t get Modbus working properly then HA is a no-go for me. I have ~10 programmable controllers with Modbus interface. I have managed to get Modbus under Homeseer rock solid.