SmartThings Community

[RELEASE] Xiaomi Sensors and Button (beta)



Anyone know why the color of the temp background is red when temp gets too cold? I don’t know the exact number it happens at but right now 39.3F is like a darker grey blue and 34.3F is brick red. As temp goes even lower it just stays red. Happens with my original Xiaomi temp sensors as well as aqara, with the a4refillpad dh for the originals as well as Brian’s latest for aqara. Any ideas?

(Matt) #1984

These things are so damn flaky - glad I didn’t spend much on two of them.

Going with another brand - not worth the trouble

(JimmyJames) #1985

Ifs in the DH, Look for the following… It’ll be in there twice.

[value: 0, color: “#153591”],
[value: 5, color: “#1e9cbb”],
[value: 10, color: “#90d2a7”],
[value: 15, color: “#44b621”],
[value: 20, color: “#f1d801”],
[value: 25, color: “#d04e00”],
[value: 30, color: “#bc2323”],
[value: 44, color: “#1e9cbb”],
[value: 59, color: “#90d2a7”],
[value: 74, color: “#44b621”],
[value: 84, color: “#f1d801”],
[value: 95, color: “#d04e00”],
[value: 96, color: “#bc2323”]

The first number is the Temp and the #(number) is Hex color coding. You can see that at 96 its #bc2323 which is red and goes down to 44 #1e9ccb which is a a shade of light Blue with a touch of grey . and then 0 is #153591 which is a deep blue. However in between 44 and 0 the values for 96 thru 59 repeat themselves.

I simply took those out and mine looks like this.

[value: 0, color: “#153591”],
[value: 44, color: “#1e9cbb”],
[value: 59, color: “#90d2a7”],
[value: 74, color: “#44b621”],
[value: 84, color: “#f1d801”],
[value: 95, color: “#d04e00”],
[value: 96, color: “#bc2323”]

Its an easy mod, Go to the API click on My Device Handlers, click on the DH thats for the temp sensor, and simply delete the lines to make it look like above, or modify to what ever temps and colors you’d like. Then click Save, then click Publish. and your Colors will correct.

Hope this helps.


Wow good catch. Thanks man. I looked quick but only at the high and low colors, didn’t notice them repeating.

(Brian Spranger) #1987

I will try to Update the DH. Might take me a few days to get around to it.

( #1988

Sorry for what is probably a noob question, but after I added the device handler, and found the pairing instructions here (Xiaomi Zigbee Door/Window Sensor, Motion Sensor, & Smart Button Device Type [beta]) I selected ‘Xiaomi Door/Window Sensor’ and added the device with the id from the logs. However, the door/window sensor always shows as open. Bringing the 2 pieces together doesnt change anything. Is there anything obvious I am doing wrong please?

(Keith G) #1989

I have figured out how to get the Aqara Door/Window Sensor DeviceHandler to immediately update the battery voltage any time you press the reset / pairing button after the sensor has been properly paired and added in ST.

This is accomplished by parsing the battery voltage data in the announcement message that a paired sensor sends when the button is pressed.

With my change to the DH, you can also get battery status before the first update 50 minutes after pairing. Here’s what it looks like in the Live Logging window of the IDE:

After adding and renaming the sensor in the ST App, just wait about a minute for it to be configured, and press the button (a short press, not long), you’ll see the LED flash a couple times, the IDE Live Logging will show “Button press detected” followed by the battery parse message, and in the ST app you’ll see the battery percentage displayed when viewing that device.

I have forked Brian’s (@ArstenA) xiaomi-aqara-door-window-sensor.groovy DeviceHandler, added my button press battery parse code, and put in a pull request to hopefully have it rolled into his DH, after it’s been tested.

In the meanwhile, anyone who wants to try it out the modified DH can find it here.

A couple of final notes:

  1. This only works for the Aqara door/window sensor. The “original” door/window sensor doesn’t send battery status data when the reset button is pushed.
  2. I don’t use any other Xiaomi Aqara sensors besides door/window sensors, but it would be interesting to look at what data is contained in the message sent when their reset/button is pushed after proper pairing.

(phil) #1990

Anyone ever try these for temp sensors? Do the work well and easy to pair?

(Huy Nguyen) #1991

I have 12 of these and they pair easily and actually use the native st contact device type so they also work locally. Because they have a low profile I use them on my windows for open/close so I don’t really use them for temp so I can’t say how accurate they are temp wise but for open/close they work great. I assume the temp sensors should be fine since you can always adjust the offset.

(phil) #1992

Thanks for the info. Maybe those are the next cheap sensors to use for temp since I really can’t find a temp only sensor that seems to work very well. When you get a chance can you look at your log and see how often it updates the temp

(Huy Nguyen) #1993

It updates frequently you can see in my activity for the device that it reports every degree change.

(Huy Nguyen) #1994

With that said tho the xiaomi aqara (square one) I’ve had has been accurate and stayed connected for weeks so far no drops the aqara sensors have been very stable for me with @ArstenA device handlers for xiaomi aqara devices


Hi @a4refillpad

just stopped by to say a BIG thank you :slight_smile: I have around 10-15 of these Xiaomi sensors at home now, all of them working perfectly with your DHs :slight_smile:

(phil) #1996

So here is and interesting one I have 5 devices that show online but have not reported for two days. Usually when they drop off they go offline,

(phil) #1997

OK got my aquara temp sensors in , square not round, and I am pretty sure I am using the correct DTH. I was able to find them without the catchall. Found them right off the bat. That is the good news…bad news is that they have already fallen off at least 6 out of the 7. I hope that I am doing something wrong. I did notice that there is no battery percentage so something is up.

(Bernie H) #1998

V2 hub correct? If so try repairing and then let sit next to the hub for an hour. Then move them to where you want. You may need to power down the hub for 30 minutes after moving them to let the mesh rebuild.

(phil) #1999

nope I have one of the originals…V1

(phil) #2000

I was wrong… hub v2, US customer Rev E

(Huy Nguyen) #2001

Are you using the aqara device handlers? Also my temp sensor did fall off the network the first time I paired it, but then I re-paired it again and it has stayed connected since then.

(phil) #2002

I just paired them again and will leave them by the hub overnight to see if they stay paired. Can you point me to the DTH you are using? Want to make sure I have the right one because again I am getting nothing for the battery