Danielhiversen/PyXiaomiGateway

Xiaomi Aqara square wireless buttons stopped working

Opened this issue · 24 comments

Using latest stable 0.99.3 but this is broken for the last two months, and I always update as soon as a new version comes out. Sorry I can't be more specific when.
Home Assistant release with the issue (if applicable):

Aqara Square button (2nd gen) automations in HA stopped working. I see in history that devices become Unavailable and then recognized again in approx every 12hrs or so. But even when I can see their state as 'off' (they are allways off, they work as binary_sensor component), they still don't trigger automations. Logs don't say anything, as if nothing happens. I tried pairing - repairing - battery changing - everything. I use Xiaomi Hub on latest FW. I also have many Aqara Wireless switches that work perfectly with the same component and syntax.

Alot of people reporting the same problems with Aqara square buttons on reddit:
https://www.reddit.com/r/homeassistant/comments/curh39/aqara_button_square_with_gyro_stopped_working/
https://www.reddit.com/r/homeassistant/comments/dct42j/xiaomi_binary_sensor_wireless_button_automations/

Any more information I can provide I will. Thank you!

Last working Home Assistant release (if known):
sorry, don't know

PyXiaomiGateway library version (if known):

Operating environment (Hass.io/Docker/Windows/etc.):
docker (unraid)
hass.io (rpi3)

Traceback (if applicable):


Description of the bug:

syssi commented

It could be a docker issue because my setups (3x RPi3 + venv) doesn't have this issue. How many devices do you use / have you paired?

4x non-wireless aqara swicthes
4x wireless aqara switches
1x round xiaomi wireless button
3x aqara square wireless buttons (not-working anymore)
2x motion sensors
3x door sensors
6x temperature sensors
total : 23

Also, I have been using them for almost a year before they stopped working, without any issue. Since I've been very busy at work for a long time now I haven't make any changes (no new devices, no config changed) in my HA for at least 6 months except updating HA version and/or fixing breaking-changes syntax in some platforms.
Thanks!

I could spin up my dusty rpi3 with hass.io and my configs to see if that make any difference? (now im using my linux unraid server with docker as my main HA instance) ..Or is hass.io HA also docker based?

syssi commented

Hass.io is docker based, too. You could follow this guide on any linux host (python >=3.6):

https://www.home-assistant.io/docs/installation/virtualenv/

Will try to do it later today, and will post back results.

I've tried virtualenv installation using my config files from unraid, on my rpi4 (I've stopped my unraid docker before that of course). Results are the same, everything works except my aqara square buttons.

I checked now, and all my buttons are that aren't working are 2nd gen WXKG12LM (with gyro) version. Could you please check do you have the same version? Maybe this bug is specific to this hw revision.

This time all my aqara buttons were reporting to HA normally (state was "off", not "unavailable") , but when I press them no automations triggers and I can't see nothing in the logs, same like before.

syssi commented

Please enable the debug output of this library and the Home Assistant component by:

# configuration.yaml

logger:
  default: warn
  logs:
    xiaomi_gateway: debug
    homeassistant.components.xiaomi_aqara: debug
    homeassistant.components.binary_sensor.xiaomi_aqara: debug

And try to reproduce the issue: Restart HA, toggle the button and post the relevant parts of your home-assistant.log.

Also I've tried to downgrade to 0.96.4 and 0.94.2 (pip3 install homeassistant==0.94.2) and results are the same. Automations work for 1 minute, I can see them in logs, but after that nothing. I'm starting to think that maybe this new Xiaomi Hub/gw update is to blame. Could you please check in Mi Home app do you have any updates pending? My version is 1.4.1_170.0158.

Also whats the maximum number of supported devices on xiaomi hub. I have 25?!

Thank you alot for your help, I will post debug logs in a few minutes...

syssi commented

Which version of the Gateway to you own? Are you sure your network (multicast) isn't the problem? I dont't know the exact limit anymore. It's around 30. Please provide some logs.

I doubt its the network because it all worked great for many months. Also whats the chance that always only the aqara square wouldn't work?

And yes, I would love to give you logs but thats the problem. There are no logs.
After restart approx 2 mins automations does work:
2019-10-04 20:47:39 DEBUG (Thread-5) [xiaomi_gateway] MCAST (report) << {'cmd': 'report', 'model': 'sensor_switch.aq3', 'sid': '158d0002adea2b', 'short_id': 18617, 'data': '{"status":"click"}'}
2019-10-04 20:47:39 DEBUG (MainThread) [homeassistant.components.xiaomi_aqara] PUSH >> : {'status': 'click'}
2019-10-04 20:47:42 DEBUG (Thread-5) [xiaomi_gateway] MCAST (report) << {'cmd': 'report', 'model': 'sensor_switch.aq3', 'sid': '158d0002adea2b', 'short_id': 18617, 'data': '{"status":"double_click"}'}

But after that.. nothing.. no logs, no automations..

EDIT: i have lumi.gateway.v2

syssi commented

I fear the button is the problem. I don't own this hardware version to reproduce the issue.

syssi commented

The other devices are working flawlessly?

Yes, for 1 year no problem at all. Everything is snappy and work awesome. I have hundreds of xiaomi_aqara related automations and everything is perfect. And I haven't change or add anything for 6 months minimum :/

Still thanks alot for your trouble

syssi commented

Did you update your gateway firmware in the meantime or did you block the internet access of the gateway?

I never blocked internet access. I did update to the latest fw (1.4.1_170.0158) maybe 3 months ago, but I can assure you everything worked for some time(approx. 1 month) after that. I was pending of bugs after update.

syssi commented

This is strange. How much aq3 buttons do you own?

3 aqara buttons :/

I know, Im going crazy and I cant believe nobody else has this problems (except 1-2 people on reddit). Guess this button version was not very popular (more expensive then non gyro version). I think I will throw them in the trash and order Aqara switches instead.

I also have deconz stick (in my rpi3 but its too far from my bedroom buttons), still Ill try if they work through deconz tomorrow.

syssi commented

All of them has this problem? Did you put the button next to the gateway for testing? Try to avoid zigbee repeater (just for testing: plug them off). There are zigbee repeaters around with broken routing tables f.e.

syssi commented

~Every wall powered zigbee device acts as repeater.

I only have xiaomi zigbee devices and I think I read somewhere that they dont follow specification correctly, and that their in-wall devices dont work as routers.. so they all connect directly to hub.

Yes, all the buttons (WXKG12LM) has this weird problem.

I will try tomorrow again, its 12pm here.. thank you once again for all your free time wasted on me :/

syssi commented

No problem. Please post your findings here!

I connected them through deconz component and they work perfectly. Single, double, triple, quadruple?! clicks all work great (on non-gyro), on gyro also everything works great, single,double,long press, shake. Please anybody else having the same problems as me - post here.

Also through deconz I found out that one of my 2 buttons that weren't working was in fact non gyro square (WXKG11LM) version.
So for me both WXKG12LM and WXKG11LM stopped working for some mysterious reason :/