[RELEASE] Xiaomi Aqara Mijia Sensors and Switches Driver

Ha. 30 years for me this may. My wife say the same !!

2 Likes

Agree 100%...all good advice, and my normal approach. I have a rule (that I've only violated on my IBlinds automations, heaven help me) that everything MUST WORK if the hub is down/missing/expoded into 1000 tiny plastic bits. So every "on/off" automated device in the house has to be set up to work regardless of the hub being on or off. No 'hub only' controlled devices.

Same in this case. The original dumb light switch was still in place/usable, she was just not in any mood to have anything around the bathroom "not normal" that day due to the horrendous food poisoning she was experiencing (so bad we took her for Covid testing the next day on doctor's advice, she was negative). One of those perfect-storm moments. The fact that the original dumb switch was still there and usable did not pacify her that morning, she wanted "that dumb little button" (Aqara) removed and automations shut off! "Yes mam!" :wink:

3 Likes

This is the way. She has spoken.

2 Likes

In one of my cases the porch light does have direct control but with the new driver the up and down scene buttons got reversed. So the switch was turning the light on and then the BC was being refreshed from the timer routine to back off.

1 Like

And the end result...you're in the dog house. :frowning:

Yeup. Lol

Just released version 0.07 which adds 3 new devices:

  • Xiaomi Mijia Wireless Switch : WXKG01LM
  • Xiaomi Aqara Wireless Mini Switch : WXKG12LM
  • Xiaomi Aqara Water Leak Sensor : SJCGQ11LM
1 Like

Nice work, I love simply drivers with a basic functionality but a presence functionality would be nice, especially for the Xiaomi drivers. Any change you will add it?

2 Likes

How did you make those tiles?

1 Like

Yup very nice tiles @BrunoVoeten
Are you using tile master?

1 Like

It is made using Device WatchDog

2 Likes

Good idea. I'm adding a simple presence to the driver to change state if no communication after 3 hours. That seems a reasonable timeframe as the devices generally report battery status every 50 minutes.

3 Likes

@chirpy - Thanks much! I had been using @veeceeoh 's drivers for my Aqara and Xiaomi devices but recently was getting javascript errors [java.lang.ClassFormatError: Truncated class file (parse)]. Your driver works great for Xiaomi Aqara Motion Sensor (RTCGQ11LM). Thanks so much for making these available!

1 Like

this is interesting ... one of two aqara WSDCGQ11LM temp sensor.
Just looking more - it's not just the temp but the humidity reading has gone wonky as well.

I'd try pressing the button on it (just a short push) and see if it corrects itself.

EDIT: I'll also add some failsafes to ignore out of sensible range values.

EDIT2: I'll also fix that pressure unit, which should be hPa :roll_eyes:

It corrected itself the next temp reading w/o any intervention. ?? Possible just a comm error ??

I actually am just interested in the temp & humidity so it’s ok if the pressure is wonky .... approx 9 times too high? I have two of the sensors and they are both reading the same thing so must be the driver.

Thanks about the failsafe warning. Not actually using them for anything yet. Seeing if they stay connected now that I have them back on my C7.

New version released:

v0.08 - Added simple presence tracking that checks the devices presence and will change state if no data receieved
Added support for MCCGQ01LM
Added safeguard limits to humidity, pressure and temperature measurements
Fixed the pressure unit description to hPa

4 Likes

This driver just gets better and better! I'm using it for most of my Aqara devices now and the presence check is a very nice addition. The only device I have that isn't covered yet is the WXKG11LM single button device . I have just tried it with the latest version in case it works the same way as either the WXKG01LM or WXKG12LM but while it seems to pick up the presence of the device it doesn't get any button presses. This is what the logs give for a button press, if that is any help adding this device:

2021-02-01 11:35:01.020 am infoSky Reboot Button present
dev:1292021-02-01 11:35:00.962 am infoSky Reboot Button contact changed to closed
dev:1292021-02-01 11:35:00.957 am debugProcessing Xigbee data (cluster:0006, attrId:0000)
dev:1292021-02-01 11:35:00.949 am debugIncoming data from device : read attr - raw: 726D010006100000100000001001, dni: 726D, endpoint: 01, cluster: 0006, size: 10, attrId: 0000, encoding: 10, command: 0A, value: 0000001001

What is the model name in the Device Details section of the device page?

A test would be to make a temporary change to the driver and update the two instances of:

getDeviceDataByName('model') == "lumi.sensor_switch"

to the name in the model field and try it out.

The model name is

lumi.sensor_switch.aq2

Changing the driver as you suggested now gets button press working OK :+1:

The only thing is it also gives a button held event after however many seconds I set in the driver for button hold duration even though I don't hold the button down.

EG driver set to 3 seconds but the button being pressed and immediately released gives this:

[dev:36](http://192.168.1.91/logs#dev36)2021-02-01 04:01:43.729 pm [info](http://192.168.1.91/device/edit/36)Aqara Button held for at least 3 seconds

[dev:36](http://192.168.1.91/logs#dev36)2021-02-01 04:01:40.760 pm [info](http://192.168.1.91/device/edit/36)Aqara Button present

[dev:36](http://192.168.1.91/logs#dev36)2021-02-01 04:01:40.702 pm [info](http://192.168.1.91/device/edit/36)Aqara Button pushed

[dev:36](http://192.168.1.91/logs#dev36)2021-02-01 04:01:40.694 pm [info](http://192.168.1.91/device/edit/36)Aqara Button contact changed to closed

[dev:36](http://192.168.1.91/logs#dev36)2021-02-01 04:01:40.672 pm [debug](http://192.168.1.91/device/edit/36)Processing Xigbee data (cluster:0006, attrId:0000)

[dev:36](http://192.168.1.91/logs#dev36)2021-02-01 04:01:40.661 pm [debug](http://192.168.1.91/device/edit/36)Incoming data from device : read attr - raw: 5E74010006100000100000001001, dni: 5E74, endpoint: 01, cluster: 0006, size: 10, attrId: 0000, encoding: 10, command: 0A, value: 0000001001