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

I can confirm that the buttonReleased attribute works perfectly for me. Was able to use a combination of this trigger and the pushed value to harness all button events from 1 to 5, from within webCoRE. Great job again, thanks! :slight_smile:

The only scenario that could not be worked out is the Button Held scenario. Currently, there is no way to differentiate between the following triggers since buttonReleased is agnostic to whether the button was pushed or held.
a) pushed = 1 && buttonReleased changes
a) held = 1 && buttonReleased changes

But I guess this was already known at the time we were discussing possible approaches and we didnā€™t have a clear solution.

I believe it should be possible to generate events that would allow a held button to be recognized, but I don't quite follow why WebCoRE can't use the buttonReleased event as a way to make a comparison to either pushed or held events.

In any event, in my own testing tonight I think I need to work a bit more on the code because it's generating buttonReleased events when I expect it to.

I think I wasnā€™t clear in my explanation. I donā€™t think webCoRE is the issue.

Letā€™s assume that the following scenario takes place after the button has been installed and pressed as well as held, at least once. (This makes the current pushed and held values, both set to 1, or more).
So, now to create a trigger, I can use any combination of values or changes in values, provided by pushed, held and buttonReleased.

Do note that the values of each of these attributes persist. So before I push the button, the value of pushed is 1. After I push the button once, the value is still 1. The only trigger I can use is to see if the buttonReleased value changed (and then to look at the pushed value to determine the number of clicks).

With held, I donā€™t have such a liberty. The value of held, like pushed is still 1, both before and after holding the button. But herebuttonReleased, though a valid trigger, cannot tell me if the update in its value was because of a hold or a push. So technically, I can only intercept holds also as pushes only, in webCoRE.
Only solution I can think of is to have a buttonHoldReleased or something similar, which updates only for a hold.

Again, I do not miss the lack of a valid trigger for hold at all. The handler works perfectly and now I have 5 different button press scenarios to chose from, unlike the limited options while I was on ST, thanks to you! :sunglasses:

Okay, well I think I've managed to do this two times better, hopefully.

First I realized that the custom buttonReleased event for WebCoRE didn't have the Java-format timestamp used for lastCheckin, so I fixed that. Then I added custom buttonPressed and buttonHeld events, also for WebCoRE use. That should give enough for anyone to make use of, I think!

Here's an example sequence of events when the button is held, and then released:

|Name|Value|Description Text|
|---|---|---|---|---|---|
|lastCheckinDate|1520402158000||
|buttonPressed|1520402158000|buttonPressed (webCoRE)|
|held|1|Xiaomi Button: Button 1 was held|
|buttonHeld|1520402159000|buttonHeld (webCoRE)|
|lastCheckin|Tue Mar 06 2018 9:56:02 PM||
|lastCheckinDate|1520402162000||
|buttonReleased|1520402162000|buttonReleased (webCoRE)|

Try out this new & improved code by copying it from here.

If that looks good, I'll make it official!

I created a device driver for the aqara button. But after looking at some of these posts it appears that the events for hubitat are quite different from smartthings??

For now it will create a button pressed and released event for button 1.

Hubitat does install the correct DD upon pairing.

Yeah, using the SmartThings' sendEvent(name: "button", value: "pushed",etc. is not supported by Hubitat and won't be recognized by Rule Machine, the Button Controller App, other Hubitat-native apps, etc.

The sendEvent / createEvent mapped data should follow this format:

return [
        name: 'pushed',
        value: buttonNumber,
        isStateChange: true,
        descriptionText: descriptionText
    ]

Also there is no support for a released state. So all of that can be removed, including the countdown timer.

But does the Aqara Button generate different messages when it's pressed versus released? If yes, then the "original" Xioami driver I'm working on could be adapted.

Same thing if the Aqara Button generates different messages for multi-clicks.

I'd love to help with the device driver, but I can only do that if I know what messages it produces with different click actions.

EDIT: For the official explanation of Hubitat's Button capability implementation, please see this forum thread.

The aqara does not have a release event.

I have modified my local code to send a pressed state.

It appears to be picked up by rule machine.

That's unfortunate. I still don't understand why they removed that from the (original) Aqara model. At least the new Aqara Button model has more functionality.

Do you see any different messages for double-click, triple-click, etc?

I worked on the aqara button DD some more and updated the pull request. I really like how it is working now.

Is there a api for this weird little thing? I can see it being useful, maybe? Remembering what does what might take a bit.

https://www.lightinthebox.com/xiaomi-mi-cube-controller-zigbee-version-controlled-by-six-actions-with-phone-app-for-smart-home-device-tv-smart-socket_p5408586.html?prm=1.10.12.0

1 Like

I have one, and plan to adapt the SmartThings Advanced device handler to Hubitat.

While the device itself supports 7 different actions, that DTH supports maps different actions to up to 43 buttons!!!

Needless to say, it's a more complicated driver, and I'll want to do thorough testing. But since I have one, I am definitely going to make a Hubitat device driver.

If no-one else has said so before, you're a superstar. Also, 43 is too many. Who the hell could remember all the things.

Since I'm asking about odd little devices, what about the IR remote control?

If it could be used locally, it'd eliminate the need for Harmony (I find their software always just slightly lacking what I want to really make it work the way I want)

https://www.lightinthebox.com/xiaomi-universal-ir-remote-controller-abundant-matching-ways-for-air-condition-tv-projector-fan-camera-cellphone_p6518276.html?utm_campaign=cartcross&prm=1.10.4.0

I tested the new attributes and everything works perfect!
Now there is a unique combination of triggers to track from practically all variants of presses and holds.

Thanks a ton for helping make things compatible with webCoRE! :+1:t3:

1 Like

As far as I know, this one only operates on 802.11 b/g/n wifi. So it's a completely different monster than anything ZigBee based, and I'd expect only works with Xiaomi's (Chinese-language-only) app. Probably way outside my realm of knowledge on how to get it cooperating with the Hubitat in any manner.

I just saw this, this AM.

Perhaps it can be ported over....

1 Like

If it could I would buy a couple of them now! :slight_smile:

Harmony hubs are too expensive here (UK) to buy loads of them

Zapals lists the Xiaomi IR Remote for $12.50 US:

https://www.zapals.com/xiaomi-mi-home-automation-controller-universal-ir-remote-control-device.html?geoip_country=US&gclid=CjwKCAiA_ojVBRAlEiwAOLRxI_kMro_BwFtL3cFVco11xbBC14-QZVPKeQOadLM4xq33RsllDEXVJxoCUYMQAvD_BwE

I am going to order one. Probably will take some weeks to arrive.

EDIT: Use code honeyza08 for $1 off.

NOTE: The KuKu Mi SmartThings device handler requires a Docker Daemon app to run continuously on a computer on your local network. Of course that computer must always be on.

I think Xiaomi is great for cost sensitive smart home stuff. I wouldnā€™t use it as a professional installer or really trust long term reliability but for setting up budget friendly systems it seems good enough. I also buy 3 if I need 2 just in case one is defective. :wink:

1 Like

[RELEASE] v0.2 of Xiaomi Aqara Button (model WXKG11LM) Device Driver
Created by @brianspranger - thanks!!

EDIT: PLEASE NOTE THIS DEVICE HANDLER HAS SINCE BEEN UPDATED
Please see this post for more information.

For convenience please copy the driver code from this direct link.

The Aqara model WXKG11LM button is different from the Xiaomi ā€œoriginalā€ Button in that no message is sent when the button is released. However it does support multi-clicks up to a quadruple-click. So when set to Momentary mode in the preference settings, @brianspranger has included a countdown timer that, after a user-set delay, will automatically send a pushed - button 0 event to emulate a button ā€œreleasedā€ event. This should theoretically be usable in WebCoRE to capture single-clicks.

Hereā€™s a chart of what happens with each kind button press:

Aqara Button model WXKG11LM

Action Hubitat button event(s)
Single click button 1 pushed , then button 0 pushed after user-set delay
Double-click button 2 pushed
Triple-click button 3 pushed
Quadruple-click button 4 pushed
Hold Not supported (same behavior as single-click)

Other Features:

  • The Hubitat hub should correctly select this custom device driver when pairing.
  • The date/time of the most recent opening of the contact is stored as lastPressed (human readable) and lastPressedDate (java format).
  • Battery replacement date tracking, stored in batteryLastReplaced state
  • Commands / Preferences include:
    ā€¢ A preference to set how many seconds until single press is cleared with a button 0 ā€œreleasedā€ event
    ā€¢ A Toggle / Momentary mode setting
    ā€¢ A Reset Battery Replaced Date command to track battery life
    ā€¢ Date / 24-hour clock settings for display of lastCheckin
    ā€¢ Min/Max voltage values used to calculate the battery percentage
    ā€¢ Display log message toggle setting. EDIT: in newest version of device handler there are two toggles settings for display of informational and/or debug log messages

Notes / Limitations:

  • This device driver is not final, and some features or preferences may be added / removed
  • There is a new version of the Aqara Button (model WXKG12LM) with more features which was released late last year. Currently this device driver will not work with it. I have ordered a couple of the new Aqara button model and plan to update this driver after they arrive.
    EDIT: The device driver has been updated with support for model WXKG12LM
2 Likes

Thnanks for all your work on the driver! Iā€™m really grateful to know that the 11LM version supports multi-tap. Are you just listening to single press events and using the minimum timer simulate this or does the button send a unique value for each press type?

Additionally, what event gets fired off for each button press? Iā€™m aiming to use this w/ the event -> mqtt bridge: hubitat-mqtt-bridge/hubitat-mqtt-bridge-app.groovy at master Ā· jeubanks/hubitat-mqtt-bridge Ā· GitHub and iā€™m wondering what additional capabilities/events that app needs to listen for to catch events from the button?