[RELEASE] Xiaomi Aqara Mijia Sensors and Switches Driver

I see where the problem is with that. It's a bit of a weird device and I'll try and isolate the pushes better.

1 Like

I'll release the fix for that tomorrow, just need to test it thoroughly :slightly_smiling_face:

1 Like

Unfortunately, they're not going to fit in with this driver as they need more individual care with a discrete driver as powered switches.

New release:

Added motion to contact sensors via an option for those want it
Fixed button pushed status for WXKG01LM

1 Like

I've just switched over the contact sensors, that I was also using as motion sensors with a custom driver, to this one and with the new option ticked it works perfectly. Thanks again.

I've just noticed something odd while going through my Xiaomi devices - some of them have a string of wierd non-print type characters in the model name of the device eg:

endpointId: 01
application:
manufacturer:
model: lumi.sensor_magnet.aq2�B!�(!�!$ !�d

Has anyone else got that with theirs? Is it something that I can, or need to, do anything about? I'm not even sure where that info comes from - is the direct from the device or anything to do with the driver?

AFAIK, that comes from the device and I see it on one or two of the devices.

@chirpy, Thanks for adding the presence functionality
But I think you added to much "Present" :smiley:

I have 2 notification set in the

System notification app

  1. "Not Present Check", the moment a button or device becomes NOT present
  2. "Present Check", the moment a button or device becomes present again

When I hit a button its "generates" each time a "Present" --> notification

I think the other driver only generates a present when it becomes present from a not present state

Just a quick update.
It been a week and two temp sensor and one motion are back on my main hub and are hanging on.
I guess the change of removing the three ST plug-ins was enough.

3 Likes

I have one Aqara contact sensor that has held on...two others fell off repeatedly, would never stay connected. No idea why this one is so persistently good when the other two were awful. Really odd. It's the only Aqara device I have, and will likely remain marooned away from all his/her friends. Kinda sad... :wink:

1 Like

I have found in the past that battery level indicator can be inaccurate on these devices.
Perhaps a fresh battery is called for?

They were both brand new, out of the box, so I don't think that was it...

1 Like

I'll have a look at it.

1 Like

Did some testing, the "present" issue exists for all my sensors (motion, contact, watersensors and button)

I've just converted one of my Aqara Temp/Humidity sensors from Markus' driver to yours and noticed the pressure value was off by 10, and with this change they do match (100.8 kPa on his, 1008 hPa on yours). But I wonder if just dividing by 10 and reporting the number as kPa is better since I see kPa numbers more frequently than hPa.

Thanks @chirpy! Thanks to this driver, I picked up a couple of (relatively) cheap sensors and so far everything's working out great!

I calibrated the temp sensor (WSDCGQ11LM) with my laser thermometer and I found it was out by 1.6F. In the Hue sensor there appears to be an option in HE for putting in a correction factor that is applied to all readings.
Is it possible to include something like that with this driver?

I'm brand new to HE, so I don't know if it's more complex than this but it looks like you might be able to change a few spots to cater for it.

After line 111, add in:
input name: "tempCorrectionFactor", type: "number", title: "Temperature Correction Factor", description: "How many degrees up (+) or down (-) does the reading need to be adjusted", defaultValue: "0"

After line 182, add in:
rawValue = rawValue + tempCorrectionFactor

If you think I'm on the right track, and you don't want to take it on, let me know and I will try it out on my local copy and can send you a pull request.

Thanks again!

@chirpy I started using this driver with my WXKG01LM button and it's not behaving as expected.

There are error logs appearing shown below and the held action doesn't seem to be working either.
When I paired the device it defaulted to using Markus' driver and I can't remove that driver yet as I'm still using it with another button. (Don't want to break all my buttons at once :slight_smile: )

[dev:190](http://192.168.1.11/logs#dev190)2021-02-07 03:59:10.740 [info](http://192.168.1.11/device/edit/190)Office Button was pushed

[dev:190](http://192.168.1.11/logs#dev190)2021-02-07 03:59:10.728 [info](http://192.168.1.11/device/edit/190)Office Button contact changed to open

[dev:190](http://192.168.1.11/logs#dev190)2021-02-07 03:59:10.540 [error](http://192.168.1.11/device/edit/190)java.lang.NullPointerException: Cannot invoke method intValue() on null object on line 251 (parse)

[dev:190](http://192.168.1.11/logs#dev190)2021-02-07 03:59:10.517 [info](http://192.168.1.11/device/edit/190)Office Button contact changed to closed

[dev:190](http://192.168.1.11/logs#dev190)2021-02-07 03:59:02.546 [info](http://192.168.1.11/device/edit/190)Office Button was pushed

[dev:190](http://192.168.1.11/logs#dev190)2021-02-07 03:59:02.535 [info](http://192.168.1.11/device/edit/190)Office Button contact changed to open

[dev:190](http://192.168.1.11/logs#dev190)2021-02-07 03:58:57.437 [error](http://192.168.1.11/device/edit/190)java.lang.NullPointerException: Cannot invoke method intValue() on null object on line 251 (parse)

[dev:190](http://192.168.1.11/logs#dev190)2021-02-07 03:58:57.414 [info](http://192.168.1.11/device/edit/190)Office Button contact changed to closed

[dev:190](http://192.168.1.11/logs#dev190)2021-02-07 03:58:54.820 [info](http://192.168.1.11/device/edit/190)Office Button tapped 3 time(s)

[dev:190](http://192.168.1.11/logs#dev190)2021-02-07 03:58:49.499 [info](http://192.168.1.11/device/edit/190)Office Button tapped 4 time(s)

[dev:190](http://192.168.1.11/logs#dev190)2021-02-07 03:58:40.302 [info](http://192.168.1.11/device/edit/190)Office Button tapped 4 time(s)

[dev:190](http://192.168.1.11/logs#dev190)2021-02-07 03:58:25.645 [info](http://192.168.1.11/device/edit/190)Office Button tapped 4 time(s)

[dev:190](http://192.168.1.11/logs#dev190)2021-02-07 03:58:16.098 [info](http://192.168.1.11/device/edit/190)Office Button was pushed

[dev:190](http://192.168.1.11/logs#dev190)2021-02-07 03:58:16.081 [info](http://192.168.1.11/device/edit/190)Office Button contact changed to open

[dev:190](http://192.168.1.11/logs#dev190)2021-02-07 03:58:10.415 [error](http://192.168.1.11/device/edit/190)java.lang.NullPointerException: Cannot invoke method intValue() on null object on line 251 (parse) 

Now after we get this fixed would it be at all possible to change the driver to allow a time of around 500ms for the button to be detected at held? This would in my opinion give a better user experience and it matches with other buttons I have used in the past

Actually I played with it a bit more and after I enabled the debug logs the errors disappeared.
I wonder because it had been using another driver first is there a chance that some of the state wasn't right and your driver couldn't take over properly?

I have released v0.11:

Modified presence to only update if previously not present or set
Added a temperature offset setting
Added experimental support for an internal temperature sensor that some of these devices contain

6 Likes

Which devices contain the temp sensor?

Just updated and have this error with a contact sensor

2021-02-07 08:30:22.728 am errorgroovy.lang.MissingMethodException: No signature of method: user_driver_waytotheweb_Xiaomi_Aqara_Mijia_Sensors_and_Switches_1455.checkEventInterval() is applicable for argument types: () values: [] (checkEventInterval)