home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.42k stars 29.9k forks source link

Modbus becomes unavailable after some hours of communication and several communication errors #59744

Closed samuelrodelius closed 2 years ago

samuelrodelius commented 2 years ago

The problem

I have been running home assistant for many years and a similar modbus configuration the whole time, made some minor changes this summer when the modbus module configuration syntax was changed.

Since some week back I have an annoying error, after approx. 12-24 hours the modbus sensors and entities becomes unavailable, first it comes with long time between the state "unavailable" and then it gets more frequent until no value is read or can be sent.

A restart of home-assistant is not helping, I have to unplug and replug the USB2modbus device: Bus 003 Device 002: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC

I'm running Home assistant in a docker-container: image: homeassistant/home-assistant:latest devices:

home-assistant.log configuration.yaml.txt unavailable mobus sensors (The grey: "Otillgänglig" means unavailable in English) home-assistant-debug.log

What version of Home Assistant Core has the issue?

core-2021.11.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

modbus

Link to integration documentation on our website

https://www.home-assistant.io/integrations/modbus

Example YAML snippet

#My modbus config from the configuration.yaml:
# Modbus entry for serial connection
modbus:
  type: serial
  method: rtu
  port: /dev/ttyUSB0
  baudrate: 19200
    #  baudrate: 9600
  stopbits: 1
  bytesize: 8
  parity: N
  timeout: 14
  delay: 4
    #  timeout: 5
    #  retries: 5
  retry_on_empty: true
  message_wait_milliseconds: 500
  switches:
    - name: ventilation_boost_mode
      slave: 1
      address: 2
      write_type: coil
    - name: ventilation_electric_heater
      slave: 1
      address: 50
      command_on: 1
      command_off: 0
  sensors:
    - name: ventilation_outdoor_air_temperature
      unit_of_measurement: °C
      slave: 1
      address: 1
      input_type: input
      count: 1
      scale: 0.1
      offset: 0
      precision: 1
      data_type: int16
    - name: ventilation_supply_air_temperature
      unit_of_measurement: °C
      slave: 1
      input_type: input
      address: 2
      count: 1
      scale: 0.1
      offset: 0
      precision: 1
      data_type: int16
    - name: ventilation_exhaust_air_temperature
      unit_of_measurement: °C
      slave: 1
      address: 3
      input_type: input
      count: 1
      scale: 0.1
      offset: 0
      precision: 1
      data_type: int16
    - name: ventilation_waste_air_temperature
      unit_of_measurement: °C
      slave: 1
      address: 4
      input_type: input
      count: 1
      scale: 0.1
      offset: 0
      precision: 1
      data_type: int16
    - name: ventilation_heat_recovery_wheel_temperature
      unit_of_measurement: °C
      slave: 1
      address: 6
      input_type: input
      count: 1
      scale: 0.1
      offset: 0
      precision: 1
      data_type: int16
    - name: ventilation_target_supply_temperature
      unit_of_measurement: °C
      slave: 1
      address: 1
      input_type: holding
      count: 1
      scale: 1
      offset: 0
      precision: 0
      data_type: int16
    - name: ventilation_supply_fan_speed
      unit_of_measurement: RPM
      slave: 1
      address: 26
      input_type: input
      count: 1
      scale: 1
      offset: 0
      precision: 0
      data_type: int16
    - name: ventilation_exhaust_fan_speed
      unit_of_measurement: RPM
      slave: 1
      address: 27
      input_type: input
      count: 1
      scale: 1
      offset: 0
      precision: 0
      data_type: int16
    - name: ventilation_heating_power
      unit_of_measurement: '%'
      slave: 1
      address: 28
      input_type: input
      count: 1
      scale: 0.39215686
      offset: 0
      precision: 0
      data_type: int16
    - name: ventilation_heat_cold_recovery_power
      unit_of_measurement: '%'
      slave: 1
      address: 29
      input_type: input
      count: 1
      scale: 0.39215686
      offset: 0
      precision: 0
      data_type: int16
  binary_sensors:
    - name: ventilation_unit_on
      slave: 1
      address: 0
      input_type: coil
        #    - name: ventilation_boost_mode
        #      slave: 1
        #      address: 2
        #      input_type: coil
        #    - name: ventilation_fire_switch
        #      slave: 1
        #      address: 0
        #      input_type: discrete_input
        #    - name: ventilation_boost_switch
        #      slave: 1
        #      address: 1
        #      input_type: discrete_input
        #    - name: ventilation_overpressure_switch
        #      slave: 1
        #      address: 2
        #      input_type: discrete_input
        #    - name: ventilation_aux_switch
        #      slave: 1
        #      address: 3
        #      input_type: discrete_input
        #    - name: ventilation_heating
        #      slave: 1
        #      address: 29
        #      input_type: discrete_input
        #    - name: ventilation_recovering_heat_cold
        #      slave: 1
        #      address: 30
        #      input_type: discrete_input

Anything in the logs that might be useful for us?

The error showed in the home assistant log is:
Cleanup recv buffer before send: 0x7e
20:57:05 – (VARNING) /usr/local/lib/python3.9/site-packages/pymodbus/client/sync.py - Message happened first at 20:53:22 and has occured 33 times
Pymodbus: modbus_hub: Modbus Error: [Input/Output] No Response received from the remote unit/Unable to decode response
20:55:45 – (FEL) Modbus - Message happened first at 20:54:31 and has occured 3 times

Additional information

The device I'm communicating with over modbus is a ventilation unit - Östberg 250 S EC, It has been working since 2018 without any issues and no changes has been done, I have restarted the ventilation unit after error started to occur but with no effect.

logging is enabled according to this: logger: default: error logs: homeassistant.components.modbus: debug pymodbus.client: debug

probot-home-assistant[bot] commented 2 years ago

modbus documentation modbus source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years 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)

janiversen commented 2 years ago

Please include the debug log, just showing the errors makes it very difficult to see the problem.

samuelrodelius commented 2 years ago

home-assistant-debug.log

Let me know if I can provide any more input to help find the root-cause.

I also see this in the log-file in the UI: Logger: pymodbus.client.sync Source: /usr/local/lib/python3.9/site-packages/pymodbus/client/sync.py:707 First occurred: 18:00:02 (118 occurrences) Last logged: 18:10:36

Cleanup recv buffer before send: 0xff 0xbd 0xff 0xbf 0xbc 0xfd 0xff 0xff 0xc7 0xfc 0xef 0xff 0xff 0xff 0xef 0xff 0xcf 0xff 0xff 0xff 0xef 0xff 0xbb 0xef 0xf7 0xfe 0xff 0x75 0xcf 0x77 0xf7 0xff 0x7f 0x77 0xaf 0x6f 0xff 0xef 0xff 0xff 0x7f 0xbd 0xff 0xef 0xff 0xee Cleanup recv buffer before send: 0xfd 0x6d 0xa7 0xff 0xf5 0xf7 0xa6 0xf7 0xff 0xfc 0xdf 0xef 0xff 0xff 0xee 0xfb 0xff 0xaf 0xee 0xfe 0x75 0xf6 0xef 0xff 0xff 0xfe 0xf 0xff 0xbe 0xff 0x9d 0x14 0xef 0xff 0xfd 0xe7 0xdf 0x77 0x67 0xf7 0xef 0xef 0xf8 0xff 0xee 0xcf 0x77 0xff 0xff 0x97 0x7f 0x8e 0xef 0xff Cleanup recv buffer before send: 0xfe 0xbf 0xaf 0xff 0xfe 0xff 0xff 0xf6 0xff 0xff 0xed 0xef 0xaf 0xfb 0x3d 0xe5 0xff 0xff 0xff 0xef 0xff 0x3e 0xbf 0xad 0xfe 0xbe 0xff 0xff 0xee 0xd5 0xff 0xce 0xff 0xfe 0xfe 0xfe 0xff 0xfe 0xee 0xff 0xff 0xbc Cleanup recv buffer before send: 0xff 0xff 0x7f 0xff 0xf7 0xef 0xf5 0xff 0xef 0xc6 0x4f 0xef 0x73 0xfe 0xb7 0x1e 0xc7 0xff 0xff 0xff 0xbf 0xf7 0xbf 0x65 0xfe 0xff 0xff 0x5d 0xbf 0xff 0xef 0xfe 0xf7 0xff 0xfd 0xd9 0xf7 0xff 0x77 0xff 0xff Cleanup recv buffer before send: 0xef 0xff 0xef 0xca 0xff 0xef 0xcf 0xef 0x33 0xf2 0xbf 0x7e 0xff 0x6f 0xfd 0xef 0xfe 0xfe 0xff 0xef 0x7d 0xf3 0xff 0xff 0xff 0xe7 0xf3 0xce 0xbb 0x77 0xbb 0xdf 0x46 0x5f 0xee 0xf3 0xff 0xff 0xe7 0xff 0xef 0xff 0xeb 0xff 0xee 0xef 0xff 0x3c 0xfe 0xe6 0xff 0xf7 0xff 0xbd 0xff 0xe7 0xdb 0xef 0x7e 0xff 0xff 0xac 0xf6

janiversen commented 2 years ago

Seems your usb is blocking communication, at least that is what the error messages say

samuelrodelius commented 2 years ago

Seems your usb is blocking communication, at least that is what the error messages say

Ok, could be a BIOS update I made some week ago then, I'll check some settings there. Thanks!

samuelrodelius commented 2 years ago

The issue remains after downgrading BIOS, I will need to verify that the usb2RS485 device I have is working properly. If its clear that the error is originating from outside of home assistant modbus integration then feel free to close the issue.