core: Xiaomi Gateway (Aqara) integration loss connection to zigbee subdevices every few hours and they become unavailable.

The problem

Xiaomi Gateway (Aqara)integration loss connection to zigbee subdevices every few hours and they become unavailable. Effected devices: Motion sensors Temperature sensors Vibration sensors Switches etc…

The devices are still available and working on “xiaomi home” app and the temperature sensors still available and working with “xiaomi miio” integration in home assistant. Reload the integration or restart home assistant solve the issue for few hours then it happens again.

What version of Home Assistant Core has the issue?

core-2021.12.10

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Xiaomi Gateway (Aqara)

Link to integration documentation on our website

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

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Maybe:
Logger: xiaomi_gateway
Source: /usr/local/lib/python3.9/site-packages/xiaomi_gateway/__init__.py:333
First occurred: January 27, 2022, 12:14:51 PM (3 occurrences)
Last logged: January 28, 2022, 9:09:02 AM

Cannot connect to Gateway

and:

Logger: xiaomi_gateway
Source: /usr/local/lib/python3.9/site-packages/xiaomi_gateway/__init__.py:429
First occurred: January 27, 2022, 12:14:51 PM (3 occurrences)
Last logged: January 28, 2022, 9:09:02 AM

No data in response from hub None

Additional information

While the issue happens The devices are still available and working on “xiaomi home” app and the temperature sensors still available and working with “xiaomi miio” integration in home assistant.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 32 (8 by maintainers)

Most upvoted comments

As a workaround you can try reloading gateway automatically once one of the child devices becomes unavailable. That seems to work.

Here is discussion around it as well https://community.home-assistant.io/t/templating-with-default-values/241936

alias: 'Reload Xiaomi '
description: ''
trigger:
  - platform: state
    entity_id:
      - sensor.temperature_living_room
    to: unavailable
    for:
      hours: 0
      minutes: 5
      seconds: 0
condition: []
action:
  - service: homeassistant.reload_config_entry
    data: {}
    target:
      device_id: 976cce1c40f20730dd7ebbfd90ec55bc
  - service: persistent_notification.create
    data:
      message: 'Xiaomi reload required '
mode: single

@llapinski It looks like your setup / Home Assistant instance isn’t able to receive multicast traffic.

Thank you for a tip - it was connected with docker service upgrade (changed docker-compose structure). In newer version it wasn’t possible to add network_mode: host and ports declaration in the same service in docker-compose file. I decided to use the ports section and I didn’t connect that with integration problems. As you suggested, I noticed that this setting prevents receiving multicast traffic. I changed ports section to network_mode: host and my integration is stable again. Thank you @syssi

@llapinski It looks like your setup / Home Assistant instance isn’t able to receive multicast traffic.

@syssi “Reading states are fine so far”, no Unknowns, the bug is gone. My current setup has up-to-date HASS version fresh install and OracleVM instead of Hyper-V, everything else including hardware host and router is the same. Quite possible that you was right and the weak link was getting multicast inside Hyper-V.