[Deprecated] Xiaomi / Aqara / Opple Drivers with Presence!

NOTE: Although Xiaomi / Aqara devices are used by many users with great success, Xiaomi / Aqara Zigbee devices are NOT officially supported on HE.

Why new drivers?

Xiaomi / Aqara drivers was something I wanted to write my own version of. Since @veeceeoh isn't here to support his I thought I'd release mine. I have published drivers for most types of Zigbee devices from Xiaomi / Aqara, if any are missing it's probably because I don't have the specific device. With this said, a big thank you goes to @veeceeoh for his drivers that were where it all began for me :slight_smile:

Want to know more?

Want to know more about our releases? Go here.

What's different?

Many things, these are a COMPLETE rewrite, they don't share any code with the old drivers. They have been tested by a few people and been found to make the devices more stable and responsive. Yes you read that right, if you want to know more about how that is done, look at the code.
For those that monitor Last Activity to see if the devices are online, that will not work as expected with these drivers, check the Presence attribute instead.

Supported Devices

  • Xiaomi / Aqara / Opple Button/Switch/Remote (works with models WXKG01LM, WXKG11LM (2015 & 2018), WXKG12LM, WXKG02LM (2016 & 2018), WXKG03LM (2016 & 2018), WXCJKG11LM, WXCJKG12LM & WXCJKG13LM) - Import URL
  • Xiaomi / Aqara Contact Sensor (works with model MCCGQ01LM & MCCGQ11LM) - Import URL
  • Xiaomi / Aqara Motion Sensor (works with model RTCGQ01LM & RTCGQ11LM) - Import URL
  • Xiaomi / Aqara Temperature & Humidity Sensor (works with model WSDCGQ01LM, WSDCGQ11LM & Keen RS-THP-MP-1.0) - Import URL
  • Xiaomi Mijia Smart Light Sensor - Zigbee 3.0 (works with model GZCGQ01LM) - Import URL
  • Aqara Water Leak Sensor (works with model SJCGQ11LM) - Import URL
  • Aqara Smart Curtain Motor (works with models ZNCLDJ11LM & ZNCLDJ12LM) - Import URL
  • Xiaomi / Aqara Smart Plug/Wall Outlet (works with models ZNCZ02LM & QBCZ11LM) - Import URL
  • Aqara Vibration Sensor (works with model DJT11LM) Import URL
  • Aqara Cube (works with model MFKZQ01LM) - Import URL
  • Xiaomi Smoke Detector (works with model JTYJ-GD01LM/BW) - Import URL

For my Generic Zigbee Drivers, see this thread.
For my Sonoff Zigbee Sensor Drivers, see this thread.
For my Tasmota WiFi Device drivers, see this thread.

Which driver should I use?

All drivers are as combined as they can be, the list above should make it clear which driver go with which model.

AQARA WALL SWITCHES

An initial driver for the Aqara Wall Switches has been published. The full support is just for the new D1 series (tested with QBKG24LM), as well as the old no-neutral switches QBKG03LM and QBKG04LM. Others may work, please report your progress. If I can get the logs (NOT with debug turned on) from all other Aqara wall switches, it is now easy to add full support for them all. PM me the logs from when you turn on, off and double click all buttons on the device, don't send them as a screenshot, I need them as text since I will need to extract data from them. Test disconnecting the buttons from the relays with the commands in my driver, if it work/doesn't work for your model, please report it.

Available here. Also available using HPM.

Beta Versions

The Beta versions with the latest (and usually just as stable) features and enhancements can be found here.

Installation

Use the Hubitat Package Manager or install manually using the Import URLs above. When changing from another driver to mine, run Initialize.

Shameless Relevance ranking improvement:
Xiaomi Aqara MiJia Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara MiJia Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara MiJia Xiaomi Aqara MiJia Xiaomi Aqara Xiaomi Aqara MiJia Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara Xiaomi Aqara
Hubitat Aqara Motion Sensor
Hubitat Aqara Contact Sensor
Hubitat Aquara Motion Sensor
Hubitat Aquara Contact Sensor
Hubitat Xiaomi Motion Sensor
Hubitat Xiaomi Contact Sensor

62 Likes

Pairing

It is perfectly fine to replace the driver of a currently installed device with these drivers, no need to pair them again, in general. There are exceptions, most notably the Opple remotes and most Aqara Button devices. They need to have some settings sent to them which can only be sent when pairing. More details in a future post below.
There may be errors in the logs during the first 3 hours when switching drivers, just ignore those. It will settle and get back to normal.

Your mesh

A good and stable mesh is needed for any Zigbee devices, not just Xiaomi/Aqara devices, but they can be more demanding at times. For more information regarding that:

Presence

All drivers have the Presence capability, if the device doesn't report in for over 3 hours it will be set as not present. This makes it easy to see that all devices are online at a glance in a Dashboard, or to monitor any change in Presence using RM or a custom App.

Recovery Mode

This mode has been able to get devices that have fallen off to reconnect. There is a warning in the log when it activates for a device. When the device is back another warning message will show that it is disabled again.
This doesn't always work, it depends on how the device fell off. It at least helps partially. If the device doesn't come back on its own when in Recovery Mode, try quick-pressing the reset button (do not fully reset and re pair the device). This might nudge the device back. If pressing the reset button works, it works within 30 seconds. On button devices it may be enough to just press any button.
If none of the above works, re pairing without deleting the device is your last option.

Please report your progress in using this, good or bad results are all needed to know how to improve.

Opple Remotes

The 2, 4 and 6 button Opple remotes that doesn't work as they should according to many open source projects and others who have tried to write drivers for them, do work REALLY well with these driver. When pairing them, look at the live log and make sure you follow the instructions in the log messages. When all is working the logs will tell you.

During pairing, if you press button 1 or 2 on these devices all your Zigbee lights may turn off, this is normal and will only happen during pairing before the devices have received the new configuration from the driver.

But I heard that...

If you know about these devices you've probably read that you can't get all the button events except on an original gateway, that is not true, these drivers work just as well as on the original gateway, in fact, they even report triple-click if you feel you need that.

Counters

When a device becomes Present after having been Not Present, the restoredCounter is increased by 1. restoredCounter can be reset manually.
For every 3 hours the device is Not Present the notPresentCounter is increased by 1. When Present again, the notPresentCounter is reset to 0.

Errors/Bugs/Feature requests

Post about it in this thread and maybe it will make it into a Github Issue and eventually taken care of :wink:
There may still be some excessive logging, that will be removed shortly, this is mostly so that it will be easier to debug any early issues not caught during beta testing.

Mesh problems

Post about it somewhere else which seems appropriate. Not in this thread.

FAQ

  1. "Your idea is stupid and slow and I don't like it" - Don't use the code
  2. "Your app/driver is crashing my Hub. I submitted a support ticket" - Don't do that, the fine folks at Hubitat Inc. do NOT maintain this code. This software is given free of charge with no support, implied or otherwise. I may still help...
  3. "The latest update broke it, FIX IT" - I do this for fun, please don't make it un-fun.
  4. "I have a great idea for a feature" - Go ahead and post it, I might get around to it...
  5. "You ignored my great idea" - See #2
  6. "I hate you for getting my hopes up, your app/driver is awful/buggy/stupid" - Ok, please write a better one so I can use it
  7. "Please fix your code, it's broken" - I write this because I enjoy coding. I will continue to support and provide updates as long as that remains the case.
  8. "I stole your code and made it soooo much better" - Thanks. Please post it so I can start using it.
  9. "You are awfully sarcastic, I don't like you" - That's ok, I don't need you to
    (thank you @thomas.c.howard for the original FAQ this one was based on)
6 Likes

For Pairing

For the future

You Sir are a legend.
I can finally put that Opple button to proper use.

1 Like

Let me know how it goes :slight_smile: So far I'm the only one who has tested these drivers with those buttons since none of the beta testers had them. It should be rather easy and straight forward to get them working, but I'd be happy to know if there are problems that needs fixing.

It took a few goes pairing them to actually get them to be responsive.
Now all of the 30 events seem to be working.

1 Like

I can usually pair them in one try, but you usually have to press a button once when the message in the log asks for it. And it needs to be done quickly before the device leaves pairing mode.

It was more it took forever to actually pair and the time it work it was pretty quick.
I just realise my hub is running slow and needs a reboot so I'll blame that.

1 Like

@markus Jsut replaced the driver for my temp sensor and it works good. Thank you!
Is there any way you could make it so that the temp offset shows up under Run Custom Action in RM?

That way I could make a simple, not so accurate, temp calibration rule. :slight_smile:

How do you want that to work? The offset is applied to the next time a temperature is reported. If what you want is to have an offset which is different depending on the current value, you'd need a different filter, like a linear regression filter. In general you don't need anything more complex for simple temperature data than a filter like that. It's easy to implement, in fact I have a version written in Groovy, the issue is that entering the training data is never going to be "user friendly".

EDIT: Here is an example of how the training data could look like for W readings:

"0.0:1.14;62.06167:10.93;1503.27161:247.6;1599.81213:263.7;3923.67700:631.4;7109.50928:1148.0;7237.0857:1193.0;7426.71338:1217.0"

I actually just need the offset to be 13 when the temp is above 50C and then back to 0 when below 40 again.

It’s because when the temp gets higher the the sensors spec, which is 60C, it shows a wrong value. It’s not important that it’s 100% accurate since I only use it for a notification when the temp is above 70.
I could leave the offset on 13 all the time but it’s nice to be able to see the normal room temp in the sauna from time to time also.

If that is all you want? May I suggest that you create a virtual temperature sensor and just set up rules to do exactly that.
If you change the offset from outside the driver and then go below 50, then when do you know that it really has gone down below 50 again? It would make for easier logic in RM to just read the value from your actual temperature device, then set the temperature of a virtual device based on the input value from this one and applying your offset.

@markus

Very nice job! I especially like the addition of Presence capability - it provides a really simple way to keep track of Mijia/Aqara devices in Node-RED.

5 Likes

@markus, I freaking love these drivers!

Thank you so much for the additional stuff, and helping me keep mine connected :+1:

3 Likes

Yes, that was my thought, there are many easy ways to track Presence. The hope is that these drivers will also make it MUCH less likely you actually encounter issues.

Thank you for testing them :slight_smile:

2 Likes

Brilliant idea! I hope other developers consider your approach. My congratulations and thanks again.

1 Like

I really would like to have a dedicated capability for this, that would be even nicer. Presence will have to do for now :slight_smile:

3 Likes

That is true for me too.
I'm very lazy and I was forced to write groovy xiaomi drivers by the lack of smart light sensor driver. It was my first , and I changed it a lot since the first version. After that I continued to write for my own fun although the available drivers were ok for me. I discovered a lot, and I'm still continuing.
I found the markus drivers excellent, and I can imagine he uses a custom generator/version manager to mantain them. That is also the way I would have done (and I'm doing).
Thanks Markus.

Any news about veeceeoh? Did he leave HE platform?

1 Like

Glad you like them :slight_smile: I hope they will be useful.

I am, I've written one to handle my drivers and manage all parts they share. Without automatic code-reuse these drivers would quickly become hard to maintain. The code for this is on my github, but there is no documentation...

I would also like to know, there was someone who told me there was a Tweet or Instagram picture posted by him in mid April, but in general he seems to not even be online anymore.

1 Like