core
core copied to clipboard
Xiaomi Aqara Gateway not receiving events
The problem
After upgrading to the new core version, aqara switches/temperature sensors/etc. don't send events or state updates to HA. The only device I see messages coming from the gateway is the Power Plug.
When I go to the Mi Home app, I see the trigger events getting logged, but they don't get passed to HA.
What version of Home Assistant Core has the issue?
core-2022.10.03
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
xiaomi_aqara
Link to integration documentation on our website
https://www.home-assistant.io/integrations/xiaomi_aqara/
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
2022-10-13 10:05:20.132 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] Gateway with host '10.40.0.18' connected, listening for broadcasts 2022-10-13 10:05:50.228 DEBUG (SyncWorker_8) [homeassistant.components.xiaomi_aqara.switch] Update data from hub: Plug_158d00015adfce 2022-10-13 10:05:50.234 DEBUG (SyncWorker_8) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Plug_158d00015adfce: on>: {'voltage': 3600, 'status': 'on', 'inuse': '1', 'power_consumed': '256227', 'load_power': '0.89'} 2022-10-13 10:06:20.229 DEBUG (SyncWorker_2) [homeassistant.components.xiaomi_aqara.switch] Update data from hub: Plug_158d00015adfce 2022-10-13 10:06:20.233 DEBUG (SyncWorker_2) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Plug_158d00015adfce: on>: {'voltage': 3600, 'status': 'on', 'inuse': '1', 'power_consumed': '256227', 'load_power': '0.89'} 2022-10-13 10:06:50.230 DEBUG (SyncWorker_7) [homeassistant.components.xiaomi_aqara.switch] Update data from hub: Plug_158d00015adfce 2022-10-13 10:06:50.236 DEBUG (SyncWorker_7) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Plug_158d00015adfce: on>: {'voltage': 3600, 'status': 'on', 'inuse': '1', 'power_consumed': '256227', 'load_power': '0.89'} 2022-10-13 10:07:20.231 DEBUG (SyncWorker_1) [homeassistant.components.xiaomi_aqara.switch] Update data from hub: Plug_158d00015adfce
Additional information
No response
Hey there @danielhiversen, @syssi, mind taking a look at this issue as it has been labeled with an integration (xiaomi_aqara) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
xiaomi_aqara documentation xiaomi_aqara source (message by IssueLinks)
I can confirm the issue. My sensors are not getting updated anymore, however, I cannot see any errors in the log files.
Update: I rolled back to 2022.10.02 but the issue still persists.
I started a separate test instance of HA and configured my gateway from scratch, which was working fine. The sensors are getting updated again.
So, the problem seems to be related to existing gateways, which are configured already. Is there a way to reset the gateway configuration, without losing all existing entities?
Edit: I deleted one of my gateways with less devices and added it again. The sensors are getting only updated once during the start of the integration. After that no updates are shown.
Many Thanks, Wlad
I have also had this issue since updating to 2022.10.X, after rolling back to 2022.9.X everything works perfectly again.
I can also confirm that the Xiaomi Aqara Gateway has not been reliable since updating. Sensor are updated in the native xiaomi app but not (or highly irregular) in Home Assistant
After a couple of integration reloads and container restarts, everything seems to be working fine again ... strange.
After a couple of integration reloads and container restarts, everything seems to be working fine again ... strange.
Also after a couple of hours? In my installation is looks likes it works after reboot but soon after the door/window sensors are not updated reliable anymore.
Yes ... working since yesterday evening. But I have to mention I do have mi Gateways and not Aqara.

I have exactly the same as romulder. I also have a Mi Gateway, but the integration is exactly the same, so don't quite know what's going on.
I have also had this issue since updating to 2022.10.X, after rolling back to 2022.9.X everything works perfectly again.
I also had this issue and rolling back to 2022.9.7 makes everything works again.
I think I have a similar / related issue. I only use my xiaomi Gateway for the light switch and light sensor as a night light in automatons. on reboot or restating the integration the entities are there and getting updates but after a while become unavailable and don't respond.
I also have problems since I have updated to the new version. I use the gateways together with temperature and door sensors.
Hi @Danielhiversen, @syssi, can we help in anyway by providing logs or something?
I've compared the traffic between the Aqara Gateway and HA Core 2022.9.7 vs. 2022.10.4. I cannot see any differences.
Please increase the log level of the xiaomi_aqara component and the underlying library by:
logger:
default: warning
logs:
xiaomi_gateway: debug
homeassistant.components.xiaomi_aqara: debug
homeassistant.components.sensor.xiaomi_aqara: debug
homeassistant.components.switch.xiaomi_aqara: debug
homeassistant.components.binary_sensor: debug
miio: debug
If you see something like this
DEBUG (Thread-4) [xiaomi_gateway] MCAST (report) << {'cmd': 'report', 'model': 'magnet', 'sid': '158d000116f2bb', 'short_id': 9184, 'data': '{"status":"close"}'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Battery_158d000116f2bb: 43>: {'status': 'close'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Door Window Sensor_158d000116f2bb: on>: {'status': 'close'}
DEBUG (Thread-4) [xiaomi_gateway] MCAST (report) << {'cmd': 'report', 'model': 'magnet', 'sid': '158d000116f2bb', 'short_id': 9184, 'data': '{"status":"open"}'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Battery_158d000116f2bb: 43>: {'status': 'open'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Door Window Sensor_158d000116f2bb: off>: {'status': 'open'}
DEBUG (Thread-4) [xiaomi_gateway] MCAST (report) << {'cmd': 'report', 'model': 'magnet', 'sid': '158d000116f2bb', 'short_id': 9184, 'data': '{"status":"close"}'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Battery_158d000116f2bb: 43>: {'status': 'close'}
DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> <Entity Door Window Sensor_158d000116f2bb: on>: {'status': 'close'}
you are able to receive and process multicast messages. You could capture some traffic using wireshark/tcpdump too. The multicast messages does look like this:

Please capture the traffic at the Home Assistant Core host to be sure Home Assistant is able to receive / see the same traffic.
@syssi After increasing the logging level as you suggested, I'm only seeing the following Aquara related log after rebooting:
2022-10-16 22:44:18.291 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] Gateway with host '192.168.0.55' connected, listening for broadcasts
I do see the following in the logs:
Then after all the devices are setup i see this which is the last xiaomi_gateway log:

It appears that all the devices are setup correctly but the states are not updated afterward even though the listener is started.
When reverting Home Assistant back to 2022.9.7, I see the devices being updated and the expected PUSH logs:

@meichthys Could you describe your setup? I tried to reproduce the issue using a python virtualenv install. Do you use a docker setup?
@syssi I'm running hassos (or whatever it's called these days 😀) on a proxmox vm.
I had not made any configuration changes between upgrading or downgrading. I tried running a packet capture on the hassos machine but I'm not sure how to do it since I don't have access to 'apk' to install tcpdump. Maybe there's a built in too I'm not aware of.
I will setup a hassos instance to reproduce the issue locally.
Same issue running HA on a container, upgrading to 2022.10.x makes my two gateways stop receiving updates from sensors. The mi app is working fine.
At boot time both gateways detect all sensors (temperature, movement, water...) but then no updates are received, only a Xiaomi power switch until they go to an unavailable state.
These are logs from 2022.9.7 where I can see the multicast traffic going back to my gateway:
2022-10-21 08:28:12.081 DEBUG (SyncWorker_9) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d00023f3f19"}'
2022-10-21 08:28:12.107 DEBUG (SyncWorker_9) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d00023f3f19', 'short_id': 11435, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1728","load_power":"0.00"}'}
2022-10-21 08:28:12.107 DEBUG (SyncWorker_9) [xiaomi_gateway] read_ack << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d00023f3f19', 'short_id': 11435, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1728","load_power":"0.00"}'}
2022-10-21 08:28:20.709 DEBUG (Thread-3 (_listen_to_msg)) [xiaomi_gateway] MCAST (report) << {'cmd': 'report', 'model': 'weather.v1', 'sid': '158d0006c6e723', 'short_id': 63528, 'data': '{"temperature":"2338"}'}
2022-10-21 08:28:20.715 DEBUG (Thread-3 (_listen_to_msg)) [xiaomi_gateway] MCAST (report) << {'cmd': 'report', 'model': 'weather.v1', 'sid': '158d0006c6e723', 'short_id': 63528, 'data': '{"humidity":"6366"}'}
2022-10-21 08:28:20.718 DEBUG (Thread-3 (_listen_to_msg)) [xiaomi_gateway] MCAST (report) << {'cmd': 'report', 'model': 'weather.v1', 'sid': '158d0006c6e723', 'short_id': 63528, 'data': '{"pressure":"101350"}'}
Here are the logs from 2022.10.5 at initializing time, where the component registers and detects all devices:
2022-10-21 08:44:39.531 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd >> b'{"cmd" : "get_id_list"}'
2022-10-21 08:44:39.556 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd resp << {'cmd': 'get_id_list_ack', 'sid': '7811dcf7870a', 'token': 'ovdX3bzCbxLKwszi', 'data': '["158d00023f3f19","158d00022efaf4","158d000248846a","158d000272b945","158d0002e95c40","158d0003971d94","158d00063335ae","158d000632ee4e","158d0006c6e723"]'}
2022-10-21 08:44:39.556 INFO (SyncWorker_3) [xiaomi_gateway] Found 10 devices
2022-10-21 08:44:39.557 DEBUG (SyncWorker_3) [xiaomi_gateway] Discovery attempt 1/5
2022-10-21 08:44:39.557 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd >> b'{"cmd":"read","sid":"158d00023f3f19"}'
2022-10-21 08:44:39.560 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d00023f3f19', 'short_id': 11435, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1728","load_power":"0.00"}'}
2022-10-21 08:44:39.561 DEBUG (SyncWorker_3) [xiaomi_gateway] Registering device 158d00023f3f19, plug as: switch
2022-10-21 08:44:39.562 DEBUG (SyncWorker_3) [xiaomi_gateway] Discovery attempt 1/5
2022-10-21 08:44:39.562 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd >> b'{"cmd":"read","sid":"158d00022efaf4"}'
2022-10-21 08:44:39.565 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'magnet', 'sid': '158d00022efaf4', 'short_id': 62655, 'data': '{"voltage":3045,"status":"close"}'}
2022-10-21 08:44:39.566 DEBUG (SyncWorker_3) [xiaomi_gateway] Registering device 158d00022efaf4, magnet as: binary_sensor
2022-10-21 08:44:39.566 DEBUG (SyncWorker_3) [xiaomi_gateway] Discovery attempt 1/5
2022-10-21 08:44:39.567 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd >> b'{"cmd":"read","sid":"158d000248846a"}'
2022-10-21 08:44:39.570 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'switch', 'sid': '158d000248846a', 'short_id': 14936, 'data': '{"voltage":3022}'}
2022-10-21 08:44:39.571 DEBUG (SyncWorker_3) [xiaomi_gateway] Registering device 158d000248846a, switch as: binary_sensor
2022-10-21 08:44:39.571 DEBUG (SyncWorker_3) [xiaomi_gateway] Discovery attempt 1/5
2022-10-21 08:44:39.572 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd >> b'{"cmd":"read","sid":"158d000272b945"}'
2022-10-21 08:44:39.576 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'sensor_motion.aq2', 'sid': '158d000272b945', 'short_id': 6344, 'data': '{"voltage":3035,"lux":"17"}'}
2022-10-21 08:44:39.577 DEBUG (SyncWorker_3) [xiaomi_gateway] Registering device 158d000272b945, sensor_motion.aq2 as: sensor
2022-10-21 08:44:39.577 DEBUG (SyncWorker_3) [xiaomi_gateway] Registering device 158d000272b945, sensor_motion.aq2 as: binary_sensor
2022-10-21 08:44:39.578 DEBUG (SyncWorker_3) [xiaomi_gateway] Discovery attempt 1/5
2022-10-21 08:44:39.579 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd >> b'{"cmd":"read","sid":"158d0002e95c40"}'
2022-10-21 08:44:39.583 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'smoke', 'sid': '158d0002e95c40', 'short_id': 28159, 'data': '{"voltage":3105,"alarm":"0"}'}
2022-10-21 08:44:39.584 DEBUG (SyncWorker_3) [xiaomi_gateway] Registering device 158d0002e95c40, smoke as: binary_sensor
2022-10-21 08:44:39.585 DEBUG (SyncWorker_3) [xiaomi_gateway] Discovery attempt 1/5
2022-10-21 08:44:39.585 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd >> b'{"cmd":"read","sid":"158d0003971d94"}'
2022-10-21 08:44:39.589 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'sensor_magnet.aq2', 'sid': '158d0003971d94', 'short_id': 59237, 'data': '{"voltage":3035,"status":"close"}'}
2022-10-21 08:44:39.590 DEBUG (SyncWorker_3) [xiaomi_gateway] Registering device 158d0003971d94, sensor_magnet.aq2 as: binary_sensor
2022-10-21 08:44:39.591 DEBUG (SyncWorker_3) [xiaomi_gateway] Discovery attempt 1/5
2022-10-21 08:44:39.591 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd >> b'{"cmd":"read","sid":"158d00063335ae"}'
2022-10-21 08:44:39.599 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'sensor_wleak.aq1', 'sid': '158d00063335ae', 'short_id': 30956, 'data': '{"voltage":3045}'}
2022-10-21 08:44:39.600 DEBUG (SyncWorker_3) [xiaomi_gateway] Registering device 158d00063335ae, sensor_wleak.aq1 as: binary_sensor
2022-10-21 08:44:39.600 DEBUG (SyncWorker_3) [xiaomi_gateway] Discovery attempt 1/5
2022-10-21 08:44:39.601 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd >> b'{"cmd":"read","sid":"158d000632ee4e"}'
2022-10-21 08:44:39.604 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'sensor_wleak.aq1', 'sid': '158d000632ee4e', 'short_id': 44708, 'data': '{"voltage":3085}'}
2022-10-21 08:44:39.605 DEBUG (SyncWorker_3) [xiaomi_gateway] Registering device 158d000632ee4e, sensor_wleak.aq1 as: binary_sensor
2022-10-21 08:44:39.605 DEBUG (SyncWorker_3) [xiaomi_gateway] Discovery attempt 1/5
2022-10-21 08:44:39.606 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd >> b'{"cmd":"read","sid":"158d0006c6e723"}'
2022-10-21 08:44:39.610 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'weather.v1', 'sid': '158d0006c6e723', 'short_id': 63528, 'data': '{"voltage":2975,"temperature":"2338","humidity":"6366","pressure":"101350"}'}
2022-10-21 08:44:39.610 DEBUG (SyncWorker_3) [xiaomi_gateway] Registering device 158d0006c6e723, weather.v1 as: sensor
2022-10-21 08:44:39.611 DEBUG (SyncWorker_3) [xiaomi_gateway] Discovery attempt 1/5
2022-10-21 08:44:39.611 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd >> b'{"cmd":"read","sid":"7811dcf7870a"}'
2022-10-21 08:44:39.615 DEBUG (SyncWorker_3) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'gateway', 'sid': '7811dcf7870a', 'short_id': 0, 'data': '{"rgb":0,"illumination":987,"proto_version":"1.1.2"}'}
2022-10-21 08:44:39.615 DEBUG (SyncWorker_3) [xiaomi_gateway] Registering device 7811dcf7870a, gateway as: sensor
2022-10-21 08:44:39.616 DEBUG (SyncWorker_3) [xiaomi_gateway] Registering device 7811dcf7870a, gateway as: light
2022-10-21 08:44:41.540 INFO (MainThread) [xiaomi_gateway] XiaomiMulticast listener started
Then, I only receive the power switch, which by chance it is the first of the array/list in the previous log:
2022-10-21 08:45:44.049 DEBUG (SyncWorker_8) [xiaomi_gateway] _send_cmd >> b'{ "cmd":"read","sid":"158d00023f3f19"}'
2022-10-21 08:45:44.080 DEBUG (SyncWorker_8) [xiaomi_gateway] _send_cmd resp << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d00023f3f19', 'short_id': 11435, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1728","load_power":"0.00"}'}
2022-10-21 08:45:44.080 DEBUG (SyncWorker_8) [xiaomi_gateway] read_ack << {'cmd': 'read_ack', 'model': 'plug', 'sid': '158d00023f3f19', 'short_id': 11435, 'data': '{"voltage":3600,"status":"off","inuse":"0","power_consumed":"1728","load_power":"0.00"}'}
By the way, the gateway light is working fine. I deleted and installed again the addon + gateway config but did not solve the issue. My only valid workaround was going back to 2022.9.7.
Let me know if you need more info.
Also having the same issue. Similar setup to @alosadagrande: HA via container, upgrading to 2022.10.x makes my gateway stop receiving updates from sensors. The mi app is working fine. Downgrading to 2022.9.7 eliminates the issue.
@poldim @alosadagrande @hanunes Can you all confirm if you are using HassOS (Home Assistant Operating System)? It appears that it is only relevant for HassOS installs, but i could be wrong.
@poldim @alosadagrande @hanunes Can you all confirm if you are using HassOS (Home Assistant Operating System)? It appears that it is only relevant for HassOS installs, but i could be wrong.
Confirming hassos for my situation
im using hass.io on docker. can see a few mentions of similar setups in the comments above so I dont think this is specific to hassos.
Running on a rpi3b+ with Fedora 36 for Edge as OS
I'm having same problem running ghcr.io/home-assistant/home-assistant:2022.10.3 Had to revert to 2022.9 to make it work again
@poldim @alosadagrande @hanunes
Can you all confirm if you are using HassOS (Home Assistant Operating System)?
It appears that it is only relevant for HassOS installs, but i could be wrong.
No, I'm using the standard docker core container, not hassos:
Broken: image: homeassistant/home-assistant:stable
Works: image: homeassistant/home-assistant:2022.9.7
Have same thing with 2022.10.5, docker on Ubuntu 20.04, with a China-model Xiaomi gateway. Sensors seem to be detected very briefly after reboot, then stop receiving events and at some point later report being disconnected. These are door and motion sensors. This happened after updating from 2022.9.7 to 2022.10.5, and I had to revert to 2022.9.7 to fix. There they work reliably, as they do in the Xiaomi app. Also tried rebooting the Xiaomi gateway, which did not achieve anything, rebooting the host machine of HA which only made it work immediately after boot as noted above.
There's probably some kind of bug in the async implementation that's switched to in 2022.10, a bit too coincidental otherwise.
@syssi is there any other kind of logs or info we can provide to help troubleshoot this?
I would just downgrade, but since I rely on the newer HACS version that's not compatible with 2022.9.7, I would break some other things.