AlexxIT / XiaomiGateway3

Home Assistant custom component for control Xiaomi Multimode Gateway (aka Gateway 3), Xiaomi Multimode Gateway 2, Aqara Hub E1 on default firmwares over LAN
https://github.com/AlexxIT/Blog
MIT License
2.45k stars 342 forks source link

Non-Xiaomi Zigbee devices become 'offline' after a short period. #515

Closed pcurren closed 1 year ago

pcurren commented 2 years ago

I have a few different types of non-Xiaomi Zigbee single, double and triple wall switches. I can pair them, and they will work however after a few hours it seems that the hub is marking then as 'online: False'.

The debug logs for the XiaomiGateway component shows the following. (The relevant part is 'alive:0' I believe.)

2021-11-21 15:48:00  DEBUG    main          SysInfo: {'installation_type': 'Home Assistant OS', 'version': '2021.10.6', 'dev': False, 'hassio': True, 'virtualenv': False, 'python_version': '3.9.7', 'docker': True, 'user': 'root', 'arch': 'armv7l', 'timezone': 'Australia/Sydney', 'os_name': 'Linux', 'os_version': '5.10.17-v7', 'supervisor': '2021.10.8', 'host_os': 'Home Assistant OS 6.6', 'docker_version': '20.10.8', 'chassis': 'embedded'}
2021-11-21 15:48:00  DEBUG    gateway3      192.168.86.60 | Start main thread
2021-11-21 15:48:00  DEBUG    gateway3      192.168.86.60 | lumi.158d00040e8175 lumi.sensor_ht retain: {'CCA': 1, 'alive': 1, 'battery': 67, 'battery_end_of_life': 0, 'chip_temperature': 0, 'cur_state': 3, 'fw_ver': 0, 'humidity': 6192, 'hw_ver': 0, 'lqi': 0, 'power_tx': 10, 'pre_state': 4, 'pressure': 0, 'pv_state': 0, 'reset_cnt': 9, 'send_all_cnt': 2, 'send_fail_cnt': 0, 'send_retry_cnt': 0, 'temperature': 2121, 'voltage': 3005}
2021-11-21 15:48:00  DEBUG    gateway3      192.168.86.60 | lumi.158d0005448fe5 lumi.sensor_motion retain: {'CCA': 1, 'alive': 1, 'battery': 72, 'battery_end_of_life': 0, 'chip_temperature': 93, 'cur_state': 3, 'fw_ver': 0, 'hw_ver': 0, 'illumination': 0, 'lqi': 0, 'lux': 0, 'no_motion_sec': 120, 'parent': 0, 'power_tx': 10, 'pre_state': 1, 'pv_state': 0, 'report_period': 60, 'reset_cnt': 8, 'security_state': True, 'send_all_cnt': 1, 'send_fail_cnt': 0, 'send_retry_cnt': 0, 'voltage': 3035}
2021-11-21 15:48:00  DEBUG    gateway3      192.168.86.60 | lumi.158d0005484656 lumi.sensor_switch retain: {'CCA': 1, 'alive': 1, 'battery': 72, 'battery_end_of_life': 0, 'chip_temperature': 95, 'cur_state': 3, 'fw_ver': 0, 'hw_ver': 0, 'lqi': 0, 'power_tx': 10, 'pre_state': 1, 'pv_state': 0, 'reset_cnt': 105, 'send_all_cnt': 1, 'send_fail_cnt': 0, 'send_retry_cnt': 0, 'voltage': 3032}
2021-11-21 15:48:00  DEBUG    gateway3      192.168.86.60 | lumi.84fd27fffe6cc0a2 lumi.plug.mmeu01 retain: {'alive': 1, 'channel_0': 'off', 'charge_protect': 0, 'en_night_tip_light': 0, 'fw_ver': 0, 'hw_ver': 0, 'load_power': 0, 'load_voltage': 0, 'max_power': 1800, 'plug_detection': 'plug_out', 'power': 'off', 'power_on_join': 0, 'poweroff_memory': 0, 'protect': 'temp'}
2021-11-21 15:48:00  DEBUG    gateway3      192.168.86.60 | lumi.84fd27fffece68bf lumi.switch.b2lacn02 retain: {'alive': 1, 'disable_btn0': 0, 'disable_btn1': 0, 'disable_btn2': 0, 'fw_ver': 0, 'hw_ver': 0, 'load_power': 0, 'load_s0': 0, 'load_s1': 0, 'load_s2': 0, 'load_voltage': 0, 'mains_voltage': 0, 'neutral_0': 'off', 'neutral_1': 'off', 'neutral_2': 'off', 'power': 'off', 'poweroff_memory': 0, 'slide_t0': 0, 'slide_t1': 0, 'slide_t2': 0}
2021-11-21 15:48:00  DEBUG    gateway3      192.168.86.60 | lumi.60a423fffe52e490 lumi.plug.mmeu01 retain: {'alive': 0, 'channel_0': 'off', 'charge_protect': 0, 'en_night_tip_light': 0, 'fw_ver': 0, 'hw_ver': 0, 'load_power': 0, 'load_voltage': 0, 'max_power': 1800, 'plug_detection': 'plug_out', 'power': 'off', 'power_on_join': 0, 'poweroff_memory': 0, 'protect': 'temp'}
2021-11-21 15:48:00  DEBUG    gateway3      192.168.86.60 | lumi.5c0272fffecf53a9 lumi.switch.l3acn3 retain: {'alive': 0, 'disable_btn0': 0, 'disable_btn1': 0, 'disable_btn2': 0, 'fw_ver': 0, 'hw_ver': 0, 'load_power': 0, 'load_s0': 0, 'load_s1': 0, 'load_s2': 0, 'load_voltage': 0, 'mains_voltage': 0, 'neutral_0': 'off', 'neutral_1': 'off', 'neutral_2': 'off', 'power': 'off', 'poweroff_memory': 0, 'slide_t0': 0, 'slide_t1': 0, 'slide_t2': 0}
2021-11-21 15:48:00  DEBUG    gateway3      192.168.86.60 | lumi.5c0272fffedfb1e6 lumi.switch.l3acn3 retain: {'alive': 0, 'disable_btn0': 0, 'disable_btn1': 0, 'disable_btn2': 0, 'fw_ver': 0, 'hw_ver': 0, 'load_power': 0, 'load_s0': 0, 'load_s1': 0, 'load_s2': 0, 'load_voltage': 0, 'mains_voltage': 0, 'neutral_0': 'off', 'neutral_1': 'off', 'neutral_2': 'off', 'power': 'off', 'poweroff_memory': 0, 'slide_t0': 0, 'slide_t1': 0, 'slide_t2': 0}
2021-11-21 15:48:02  ERROR    gateway3      Can't read mesh devices`

I hacked the plugin to force 'online: True' in gateway3.setup_devices, as shown by the lines starting 'PAC':

`2021-11-21 15:48:02  DEBUG    gateway3      192.168.86.60 | Setup gateway device {'did': '374378657', 'model': 'lumi.gateway.mgl03', 'mac': '0x842e14fffe25899f', 'wlan_mac': '54:EF:44:CA:63:4F', 'type': 'gateway', 'fw_ver': '1.4.6_0040', 'online': True, 'init': {'firmware lock': True}}
2021-11-21 15:48:02  DEBUG    gateway3      192.168.86.60 | PAC: Finished setup_devices for device: {'did': '374378657', 'model': 'lumi.gateway.mgl03', 'mac': '0x842e14fffe25899f', 'wlan_mac': '54:EF:44:CA:63:4F', 'type': 'gateway', 'fw_ver': '1.4.6_0040', 'online': True, 'init': {'firmware lock': True}, 'device_manufacturer': 'Xiaomi', 'device_name': 'Dining Room Mi Hub', 'device_model': 'lumi.gateway.mgl03 ZNDMWG03LM', 'lumi_spec': [['8.0.2012', None, 'power_tx', None], ['8.0.2024', None, 'channel', None], ['8.0.2081', None, 'pairing_stop', None], ['8.0.2082', None, 'removed_did', None], ['8.0.2084', None, 'added_device', None], ['8.0.2103', None, 'device_model', None], ['8.0.2109', None, 'pairing_start', None], ['8.0.2110', None, 'discovered_mac', None], ['8.0.2111', None, 'pair_command', None], ['8.0.2155', None, 'cloud', None], [None, None, 'pair', 'remote'], [None, None, 'firmware lock', 'switch']], 'miot_spec': [[3, 1, 'alarm', 'alarm_control_panel'], [3, 22, 'alarm_trigger', None]], 'entities': {'pair': None, 'firmware lock': None, 'alarm': None}, 'gateways': []}
2021-11-21 15:48:02  DEBUG    gateway3      192.168.86.60 | Setup zigbee device {'did': 'lumi.158d00040e8175', 'mac': '0x158d00040e8175', 'nwk': '0xe755', 'model': 'lumi.sensor_ht', 'type': 'zigbee', 'fw_ver': 'mod: 0 hw: 0 fw: 2', 'init': {'temperature': 21.21, 'humidity': 61.92, 'battery': 61}, 'online': True}
2021-11-21 15:48:02  DEBUG    gateway3      192.168.86.60 | PAC: Finished setup_devices for device: {'did': 'lumi.158d00040e8175', 'mac': '0x158d00040e8175', 'nwk': '0xe755', 'model': 'lumi.sensor_ht', 'type': 'zigbee', 'fw_ver': 'mod: 0 hw: 0 fw: 2', 'init': {'temperature': 21.21, 'humidity': 61.92, 'battery': 61}, 'online': True, 'device_manufacturer': 'Xiaomi', 'device_name': 'Guest Room Environment Sensor', 'device_model': 'lumi.sensor_ht WSDCGQ01LM', 'lumi_spec': [['0.1.85', 'temperature', 'temperature', 'sensor'], ['0.2.85', 'humidity', 'humidity', 'sensor'], ['8.0.2008', 'voltage', 'battery', 'sensor']], 'miot_spec': None, 'entities': {'temperature': None, 'humidity': None, 'battery': None}, 'gateways': []}
2021-11-21 15:48:02  DEBUG    gateway3      192.168.86.60 | Setup zigbee device {'did': 'lumi.158d0005448fe5', 'mac': '0x158d0005448fe5', 'nwk': '0xc5a4', 'model': 'lumi.sensor_motion', 'type': 'zigbee', 'fw_ver': 'mod: 11 hw: 0 fw: 11', 'init': {'battery': 67}, 'online': True}
2021-11-21 15:48:02  DEBUG    gateway3      192.168.86.60 | PAC: Finished setup_devices for device: {'did': 'lumi.158d0005448fe5', 'mac': '0x158d0005448fe5', 'nwk': '0xc5a4', 'model': 'lumi.sensor_motion', 'type': 'zigbee', 'fw_ver': 'mod: 11 hw: 0 fw: 11', 'init': {'battery': 67}, 'online': True, 'device_manufacturer': 'Xiaomi', 'device_name': 'Guest room robe motion sensor', 'device_model': 'lumi.sensor_motion RTCGQ01LM', 'lumi_spec': [['3.1.85', None, 'motion', 'binary_sensor'], ['8.0.2008', 'voltage', 'battery', 'sensor']], 'miot_spec': None, 'entities': {'motion': None, 'battery': None}, 'gateways': []}
2021-11-21 15:48:02  DEBUG    gateway3      192.168.86.60 | Setup zigbee device {'did': 'lumi.158d0005484656', 'mac': '0x158d0005484656', 'nwk': '0x8ebf', 'model': 'lumi.sensor_switch', 'type': 'zigbee', 'fw_ver': 'mod: 10 hw: 0 fw: 10', 'init': {'battery': 66}, 'online': True}
2021-11-21 15:48:02  DEBUG    gateway3      192.168.86.60 | PAC: Finished setup_devices for device: {'did': 'lumi.158d0005484656', 'mac': '0x158d0005484656', 'nwk': '0x8ebf', 'model': 'lumi.sensor_switch', 'type': 'zigbee', 'fw_ver': 'mod: 10 hw: 0 fw: 10', 'init': {'battery': 66}, 'online': True, 'device_manufacturer': 'Xiaomi', 'device_name': 'Mi kitchen switch', 'device_model': 'lumi.sensor_switch WXKG01LM', 'lumi_spec': [['13.1.85', None, 'button', None], [None, None, 'action', 'sensor'], ['8.0.2008', 'voltage', 'battery', 'sensor']], 'miot_spec': None, 'entities': {'action': None, 'battery': None}, 'gateways': []}
2021-11-21 15:48:02  DEBUG    gateway3      192.168.86.60 | Setup zigbee device {'did': 'lumi.84fd27fffe6cc0a2', 'mac': '0x84fd27fffe6cc0a2', 'nwk': '0xaa38', 'model': 'lumi.plug.mmeu01', 'type': 'zigbee', 'fw_ver': 'mod: 1 hw: 0 fw: 1', 'init': {'power': 0, 'switch': None}, 'online': True}
2021-11-21 15:48:02  DEBUG    gateway3      192.168.86.60 | PAC: Finished setup_devices for device: {'did': 'lumi.84fd27fffe6cc0a2', 'mac': '0x84fd27fffe6cc0a2', 'nwk': '0xaa38', 'model': 'lumi.plug.mmeu01', 'type': 'zigbee', 'fw_ver': 'mod: 1 hw: 0 fw: 1', 'init': {'power': 0, 'switch': None}, 'online': True, 'device_manufacturer': 'Xiaomi', 'device_name': 'Music Room fairy light (Zigbee)', 'device_model': 'lumi.plug.mmeu01 ZNCZ04LM', 'lumi_spec': [['0.12.85', 'load_power', 'power', 'sensor'], ['0.13.85', None, 'energy', 'sensor'], ['4.1.85', 'neutral_0', 'switch', 'switch']], 'miot_spec': None, 'entities': {'power': None, 'energy': None, 'switch': None}, 'gateways': []}
2021-11-21 15:48:02  DEBUG    gateway3      192.168.86.60 | Setup zigbee device {'did': 'lumi.84fd27fffece68bf', 'mac': '0x84fd27fffece68bf', 'nwk': '0x06d7', 'model': 'lumi.switch.b2lacn02', 'type': 'zigbee', 'fw_ver': 'mod: 1 hw: 0 fw: 1', 'init': {'channel 1': None, 'channel 2': None}, 'online': True}
2021-11-21 15:48:02  DEBUG    gateway3      192.168.86.60 | PAC: Finished setup_devices for device: {'did': 'lumi.84fd27fffece68bf', 'mac': '0x84fd27fffece68bf', 'nwk': '0x06d7', 'model': 'lumi.switch.b2lacn02', 'type': 'zigbee', 'fw_ver': 'mod: 1 hw: 0 fw: 1', 'init': {'channel 1': None, 'channel 2': None}, 'online': True, 'device_manufacturer': 'Aqara', 'device_name': 'Aqara Wall Switch (With Neutral, Double Rocker)', 'device_model': 'lumi.switch.b2lacn02 QBKG22LM', 'lumi_spec': [['4.1.85', 'channel_0', 'channel 1', 'switch'], ['4.2.85', 'channel_1', 'channel 2', 'switch'], ['13.1.85', None, 'button_1', None], ['13.2.85', None, 'button_2', None], ['13.5.85', None, 'button_both', None], [None, None, 'action', 'sensor']], 'miot_spec': None, 'entities': {'action': None, 'channel 1': None, 'channel 2': None}, 'gateways': []}
2021-11-21 15:48:02  DEBUG    gateway3      192.168.86.60 | Setup zigbee device {'did': 'lumi.60a423fffe52e490', 'mac': '0x60a423fffe52e490', 'nwk': '0x1204', 'model': 'lumi.plug.mmeu01', 'type': 'zigbee', 'fw_ver': 'mod: 1 hw: 0 fw: 1', 'init': {'power': 0, 'switch': None}, 'online': False}
2021-11-21 15:48:02  DEBUG    gateway3      192.168.86.60 | PAC: Found offline device which has now been set to online. Confirm device attributes: {'did': 'lumi.60a423fffe52e490', 'mac': '0x60a423fffe52e490', 'nwk': '0x1204', 'model': 'lumi.plug.mmeu01', 'type': 'zigbee', 'fw_ver': 'mod: 1 hw: 0 fw: 1', 'init': {'power': 0, 'switch': None}, 'online': True}
2021-11-21 15:48:02  DEBUG    gateway3      192.168.86.60 | PAC: Finished setup_devices for device: {'did': 'lumi.60a423fffe52e490', 'mac': '0x60a423fffe52e490', 'nwk': '0x1204', 'model': 'lumi.plug.mmeu01', 'type': 'zigbee', 'fw_ver': 'mod: 1 hw: 0 fw: 1', 'init': {'power': 0, 'switch': None}, 'online': True, 'device_manufacturer': 'Xiaomi', 'device_name': 'Bin floodlight', 'device_model': 'lumi.plug.mmeu01 ZNCZ04LM', 'lumi_spec': [['0.12.85', 'load_power', 'power', 'sensor'], ['0.13.85', None, 'energy', 'sensor'], ['4.1.85', 'neutral_0', 'switch', 'switch']], 'miot_spec': None, 'entities': {'energy': None, 'power': None, 'switch': None}, 'gateways': []}
2021-11-21 15:48:02  DEBUG    gateway3      192.168.86.60 | Setup zigbee device {'did': 'lumi.5c0272fffecf53a9', 'mac': '0x5c0272fffecf53a9', 'nwk': '0x10d9', 'model': 'lumi.switch.l3acn3', 'type': 'zigbee', 'fw_ver': 'mod: 1 hw: 0 fw: 1', 'init': {'channel 1': 0, 'channel 2': 0, 'channel 3': 0}, 'online': False}
2021-11-21 15:48:02  DEBUG    gateway3      192.168.86.60 | PAC: Found offline device which has now been set to online. Confirm device attributes: {'did': 'lumi.5c0272fffecf53a9', 'mac': '0x5c0272fffecf53a9', 'nwk': '0x10d9', 'model': 'lumi.switch.l3acn3', 'type': 'zigbee', 'fw_ver': 'mod: 1 hw: 0 fw: 1', 'init': {'channel 1': 0, 'channel 2': 0, 'channel 3': 0}, 'online': True}
2021-11-21 15:48:02  DEBUG    gateway3      192.168.86.60 | PAC: Finished setup_devices for device: {'did': 'lumi.5c0272fffecf53a9', 'mac': '0x5c0272fffecf53a9', 'nwk': '0x10d9', 'model': 'lumi.switch.l3acn3', 'type': 'zigbee', 'fw_ver': 'mod: 1 hw: 0 fw: 1', 'init': {'channel 1': 0, 'channel 2': 0, 'channel 3': 0}, 'online': True, 'device_manufacturer': 'Aqara', 'device_name': 'Aqara Smart Wall Switch Triple', 'device_model': 'lumi.switch.l3acn3 QBKG25LM', 'lumi_spec': [['4.1.85', 'neutral_0', 'channel 1', 'switch'], ['4.2.85', 'neutral_1', 'channel 2', 'switch'], ['4.3.85', 'neutral_2', 'channel 3', 'switch'], ['13.1.85', None, 'button_1', None], ['13.2.85', None, 'button_2', None], ['13.3.85', None, 'button_3', None], ['13.5.85', None, 'button_both_12', None], ['13.6.85', None, 'button_both_13', None], ['13.7.85', None, 'button_both_23', None], [None, None, 'action', 'sensor']], 'miot_spec': None, 'entities': {'channel 1': None, 'channel 2': None, 'channel 3': None, 'action': None}, 'gateways': []}
2021-11-21 15:48:02  DEBUG    gateway3      192.168.86.60 | Setup zigbee device {'did': 'lumi.5c0272fffedfb1e6', 'mac': '0x5c0272fffedfb1e6', 'nwk': '0xa041', 'model': 'lumi.switch.l3acn3', 'type': 'zigbee', 'fw_ver': 'mod: 1 hw: 0 fw: 1', 'init': {'channel 1': 0, 'channel 2': 0, 'channel 3': 0}, 'online': False}
2021-11-21 15:48:02  DEBUG    gateway3      192.168.86.60 | PAC: Found offline device which has now been set to online. Confirm device attributes: {'did': 'lumi.5c0272fffedfb1e6', 'mac': '0x5c0272fffedfb1e6', 'nwk': '0xa041', 'model': 'lumi.switch.l3acn3', 'type': 'zigbee', 'fw_ver': 'mod: 1 hw: 0 fw: 1', 'init': {'channel 1': 0, 'channel 2': 0, 'channel 3': 0}, 'online': True}
2021-11-21 15:48:02  DEBUG    gateway3      192.168.86.60 | PAC: Finished setup_devices for device: {'did': 'lumi.5c0272fffedfb1e6', 'mac': '0x5c0272fffedfb1e6', 'nwk': '0xa041', 'model': 'lumi.switch.l3acn3', 'type': 'zigbee', 'fw_ver': 'mod: 1 hw: 0 fw: 1', 'init': {'channel 1': 0, 'channel 2': 0, 'channel 3': 0}, 'online': True, 'device_manufacturer': 'Aqara', 'device_name': 'Aqara Triple Wall Switch D1', 'device_model': 'lumi.switch.l3acn3 QBKG25LM', 'lumi_spec': [['4.1.85', 'neutral_0', 'channel 1', 'switch'], ['4.2.85', 'neutral_1', 'channel 2', 'switch'], ['4.3.85', 'neutral_2', 'channel 3', 'switch'], ['13.1.85', None, 'button_1', None], ['13.2.85', None, 'button_2', None], ['13.3.85', None, 'button_3', None], ['13.5.85', None, 'button_both_12', None], ['13.6.85', None, 'button_both_13', None], ['13.7.85', None, 'button_both_23', None], [None, None, 'action', 'sensor']], 'miot_spec': None, 'entities': {'action': None, 'channel 1': None, 'channel 2': None, 'channel 3': None}, 'gateways': []}
2021-11-21 15:48:02  DEBUG    gateway3      192.168.86.60 | Gateway time offset: 0.15685415267944336

This hack forced Home Assistant to show the devices as enabled, however triggering the switches does not result in a successful call to the gateway. i.e. the gateway does not turn on the switch, and home assistant ends up flicking it to the off state again.

Do you have any thoughts or ideas on stopping the gateway from decided that some Zigbee devices are offline?

Thanks!

AlexxIT commented 2 years ago

I don't know why you "hack" integration, because this setting described in readme (ignore offline). It's known issue on some 3rd party zigbee devices. Maybe it will be fixed in integration version 2.0

pcurren commented 2 years ago

Thanks AlexxIT. You are correct that my hack basically just does what your setting already does. I didn't notice the setting, but thank you for pointing it out.

I've removed the hack now and upgraded to the latest version of the component.

With the setting, Home Assistant does show the switches as enabled. It's just a shame that the Xiaomi Gateway will not try to send signals to the devices!

What do you mean my 'integration version 2'?

Oh, and finally, thank you very much for all your work on this component! It's great :-)

AlexxIT commented 2 years ago

There is no fix of your problem yet

AlexxIT commented 1 year ago

Please reopen the issue if it is still relevant