Xiaomi / Aqara ZigBee device drivers (possibly may no longer be maintained)

It appears that the single-button model may send messages when it’s pressed and when it’s released.

However, I don’t think you’ve assigned the device driver I linked to, because it would never post “Button triggered” log messages.

Please try going to the device details page, assigning the Xiaomi Aqara Dual Button Light Switch driver, click “save”, then turn on debug log output, “save”, and post your log entries that occur when you click the button, hold for a few seconds and release. That should produce the Zigbee messages in the log that I need to make the device driver compatible.

1 Like

My bad! I was trying my own version.

2018-04-08 18:37:18.200:debugButton: Left button pushed

2018-04-08 18:37:18.189:debugButton: Parsing description: read attr - raw: 82B70100060800001001, dni: 82B7, endpoint: 01, cluster: 0006, size: 08, attrId: 0000, encoding: 10, value: 01

2018-04-08 18:37:18.002:debugButton: Left button pushed

2018-04-08 18:37:17.990:debugButton: Parsing description: read attr - raw: 82B70100060800001000, dni: 82B7, endpoint: 01, cluster: 0006, size: 08, attrId: 0000, encoding: 10, value: 00

Great! Based on the times in the log output, it appears you just clicked the button once, right?

Also, can you try holding the button for 3-5 seconds, and post the log output for that?

Tried it:

2018-04-08 19:14:36.347:debugButton: Left button pushed

2018-04-08 19:14:36.326:debugButton: Parsing description: read attr - raw: 82B70100060800001001, dni: 82B7, endpoint: 01, cluster: 0006, size: 08, attrId: 0000, encoding: 10, value: 01

2018-04-08 19:14:33.307:debugButton: Left button pushed

2018-04-08 19:14:33.290:debugButton: Parsing description: read attr - raw: 82B70100060800001000, dni: 82B7, endpoint: 01, cluster: 0006, size: 08, attrId: 0000, encoding: 10, value: 00

Wait a second - you said model WXKG01LM, right?

I think I confused this model with a different button.

Does your button look like this:


If yes, then you should use the “original” Xiaomi Button device driver. It supports button hold, single-click, double-click, triple-click, quadruple-click, and also quintuple-click.

EDIT: I have released a new version of the round button device driver; please see my next post (below).

[UPDATE] All Xiaomi Device Drivers except Aqara Button

Links to updated code

Changes from previous versions
All device drivers

  • added (informational) info log message toggle preference setting, for displaying helpful plain English" / non-debug log messages
  • custom attribute events (for use with webCoRE) now use more accurate Epoch Time stamp
  • changed Battery Replaced Date to use system-formatted new Date() date/time stamp
  • removed Date Format and 24 hour clock preference settings because they are no longer used
  • removed lastPressedDate because it doesn’t serve any real purpose on Hubitat
  • edited preference setting and log message text for clarity

Aqara Leak Sensor device driver

  • added custom lastDry attribute event for webCoRE use

both Motion Sensor device drivers

  • added custom lastInactive attribute event for webCoRE use
  • changed default of motionreset to 61 seconds (1 second longer than normal hardware reset of 60 seconds)

Temp/Humidity Sensors device driver

  • added attribute "pressure", "Decimal" to be used for custom pressure value events

Note: These device drivers are not final, and some features or preferences may be added / removed


The button seems to work! Thank you for the effort :wink:

1 Like

For anyone who downloaded the updated code for the Aqara Leak Sensor driver, @NoWon alerted me to an issue that shows an error on the log page and prevents the wet / dry status to be sent to the hub.

I have fixed the code, but I won’t be able to test it until I get home in about 8 hours.

If you want to revert to the previous v0.6 code, it is still available here.

Sorry for any inconvenience, and thanks for your patience!

The updated Aqara Leak sensor driver code is now working correctly. Version is now v0.7.1, grab the code from here.

1 Like

working great thank you

Thanks again for these drivers Keith. Just received my Aqara button today. Pairing was easy. Hope it stays paired, as this thing is so cool, and an incredible deal vs a Flic. So far I’m using single-click, hold, double-click and triple-click with the Button Controller app. All are performing perfectly.

1 Like

@veeceeoh: Would it be possible for you to add a offset configuration field for the Aqara motions sensors, to compensate for variances in there illuminance reporting? Thanks!


[UPDATE] v0.7.1 of Aqara Motion Sensor Device Driver

This small update adds an Lux value offset preference setting:


  • The lux upper limit of the Aqara Motion Sensor is 1000 or 1200 (depending on model revision) and does not seem to be highly accurate.
  • Although a lux reading message is sent by the sensor when motion is detected, the order of lux and motion detection messages is not always the same (i.e., the lux value message may be sent before or after the motion detected message.) With that in mind, a change in lux value should probably be evaluated before evaluating whether motion detected = true in an automation app rule.

Is anyone else seeing their Xiaomi (original) motion sensors not going inactive after a while? It’s normally fine after the hub has been rebooted, but within a day or so the runIn() call doesn’t seem to do anything.

I’m wondering if there’s a resource that’s not being freed somewhere, although I can only assume that it’s in the Hubitat firmware, since the DTH looks perfectly fine.

Perhaps not related, last night I discovered that all events of device subscribed to by apps were being ignored. I was pulling my hair out for an hour before deciding to reboot and then it was all working fine again.

Since I still consider my Hubitat to be "in testing", I have very few apps, only 6 RM rules, and just one WebCore Piston. I see no reason why I would need to reboot my hub because of resources being bogged down in any way. A look at my logs shows very frequent inactivity, so I am becoming increasingly frustrated with bizarre issues that are magically cleared by a reboot.

But enough of my rant. Have you checked your events list for the motion sensor to see if the motion - inactive event was sent?

Yeah, I have checked the events list in the past and the inactive event was definitely not being sent.

I have 3 cats and they trigger the motion sensors quite a lot, especially the ones on the stairs (one likes to sleep on the stairs). From a quick scan of the logs, each motion sensor is triggered about 40 times in a 24 hour period. There are 3 sensors in active use at present in the same area so that's 120 calls to runIn() in a day. It seems to take around 2-3 days before I have to reboot the hub, so if there's a limit on the number of timers used by runIn() and there's a resource leak then that limit would be about 256.

Of course I could be entirely wrong in my diagnosis, but without access to more detailed logs of the internals of Hubitat it's hard to be sure.

I find that really hard to believe, as runIn() is used by Apps for all kinds of delay-based automations. If there are limits on how many / how often it and other chon schedule calls can be used per day, it hasn’t been mentioned anywhere.

Sounds like something to ask the Hubitat folks about.

I hope you’re right about that. It would certainly be a surprise. I’ve enabled info and debug logging in a couple of the motion sensors - unfortunately that doesn’t seem to include any debugging for calls to runIn()

I’ve added some debugging code to my version to see if there’s a possibility that the device state isn’t as expected. I’ll see how it runs for a few days.

As I understand it, the device driver code is executed once for each message received from a device or command sent, and then exits. But, the runIn() call initializes a scheduled execution of the driver code, and at the scheduled time, it goes right to the function named in runIn() and then exits.

Since I can’t add any log message above the “level” of device driver execution, all I can do is put a confirmation info log message in the function that resets motion to inactive, and it’s no more helpful that checking whether the inactive event was sent.

So if the system is not honoring scheduled execution requests, there’s no way to have the device driver code let you know about that. It would require system or admin level logging.