[OBSOLETE] Xiaomi Sensors and Button (beta)

Emersonvier, you should use a newer DH for those devices. I’ve added Gavin’s endpoint change for the door sensor and I’ve added an endpoint for the button to my version. This will make Smartthings detect the device once it’s paired (do the hold to reset, wait for blue light to blink repeatedly, wait until it blinks again after a short period, if you don’t see three blinks, press again until it either blinks once for not paired, or three times for paired). Once the device light blinks 3 times to indicate it’s paired, wait 10-20 seconds and the Thing should show up properly in the app.

I have mine here (I’ve updated my version of door sensor and button):

ArstenA also has his:
https://github.com/bspranger/Xiaomi/tree/master/devicetypes/a4refillpad

Gavin has his (for the door/window sensor):

4 Likes

Can I ask why the above guys don’t get together and produce just one DH?
Out of the above, which one is the best.

1 Like

i’m new to ST and Xiaomi and wonder the same as my devices are unstable with Brian’s DH. Not that I am blaming Brian in any way, but am keen to understand the same as @bobbles

I just bought the same Aquara devices (except for switch/button) and after a few attempts have them all working via @a4refillpad I had to use catchall method to add them

I bought brunch of Aqara Motion Sensor and start to add it on ST. Like everyone else I have having below issue.

  • Once device in pairing mode, scanning devices from the ST app take ages to detect the device. Many times, it detect nothing even with multiple times put the device to pairing mode. (even put the device close to the ST hub, rebooting ST hub won’t help)
  • Once the motion sensor get added, applying the DH (either with a4refillpad or bspranger code) will work but only for the first few hours then it died. (sometime less than an hour which I do not know why, even let the device idle)

Currently I am trying Inpier’s code and it has been working for few hours now. But will see whether it can last till tomorrow. However, with Inpier’s DH the battery tile show – with no value. I am not sure anyone get this working ? (saw lot of thread saying the battery section not working)

I am not a coder but I saw all the DH (for the Aqara Motion Sensor) have the parameter “battery”.
According to Aqara gateway communication protocol documentation (which is in Chinese) 1.0.9_2017.08.01 (this august version is the most updated one I can find), the change log stated that “the battery property has been changed to voltage on v1.0.6”. Wondering it will work if the “battery” get replace with “voltage” instead ?

There’s also a statement “The voltage range is 0-3300mv, in normal usage below 2800mv mean low voltage”; “lux range is between 0-1200”.

Property Reporting:
{“cmd”:“report”,“model”:“sensor_motion.aq2”,“sid”:“112316”,“short_id”:4343,“data”:"{“status”:“motion”}" }

Property Reporting:
{“cmd”:“report”,“model”:“sensor_motion.aq2”,“sid”:“112316”,“short_id”:4343,“data”:"{“lux”:“100”}" }

Heartbeat reporting (heartbeat interval 60 sec):
{“cmd”:“report”,“model”:“sensor_motion.aq2”,“sid”:“112316”,“short_id”:4343,“data”:"{“voltage”:3000,“lux”:“50”}" }

Hope this help.

Interesting the heartbeat says it reports Lux. That would be very useful every 60 seconds but I tested it and it only seems to update when there is motion.

There’s a lot of people who have forked from the original project (a4refillpad’s). I’m trying to merge my changes to bspranger’s (ArstenA), but it’s been pending. It seems like his project has the most contributions from others.

Of those three, I don’t think there’s any best, since they’re all pretty much the same code. I only have the door/window sensors and the button which I needed working, so my repo has working versions for both of those. The difference currently is mine will be detected properly in the SmartApp when the devices are paired (credit to Gavin’s door sensor DH, which is how I learned how to make it show up), and the battery reading shouldn’t constantly fluctuate. This is just for the Aqara button and door sensor.

I’ve got a ton of these working now and the buttons control my z-wave light switches through the smartapp with no issues so far. Battery reports properly, they pair up easily, and haven’t seen any drops in a while.

If the battery specs really are 3.3 to 2.8 volts, I’ve got a bunch of sensors already below half life left.

Hi @ArstenA

Could I have a link to your DHs? Sorry I couldnt find it. I am currently using a4refill’s DH and I have battery issues. Would like to give yours a go.
Thanks

Sorry I just found them above… :slight_smile:

2 Likes

I tried a Google search for that documentation, but couldn’t find it.

Would you mind sharing the URL for this Aqara communication protocol documentation?

Also - for anyone interested - while doing my Google search I discovered that someone figured out how to hack a Xiaomi sensor into a ZigBee network sniffer! It involves writing new firmware, but perhaps this could be a way to get more reliable information on the data Xioami devices transmit?

His blog post is here (in French). Apologies if this has been mentioned before - I’ve read through a lot, but not read every single post in every single thread relating to Xiaomi sensors.

EDIT: After reading more posts by the author of the blog, Frédéric Dubois, I now see he has become something of an authority on Xiaomi’s ZigBee protocol, and has developed a “universal” ZigBee to USB/TTL gateway device called ZiGate (website in French), born out of a successfully funded Kickstarter campaign (again in French).

1 Like

When trying different device handlers , how do you choose which handler handles your sensor?

Ok, here is a link describing the button data.

Here is some info for the temp/humidity

Potentially more info to look at:

It have this statement :
“Aqara body illumination sensor:
The human body sensor detects that someone moves and reports a report immediately, and also reports the light value “lux”. In the case of someone moving, in order to save electricity, the body sensor sends a report as soon as a minute. The body sensor also reports the current lux value at each heartbeat. In the remaining cases, the human sensor does not report the value of light intensity.”

See this link https://aqara.gitbooks.io/lumi-gateway-lan-communication-api/content/

As expected, all my motion sensor was dead last night (including the door/window sensor) on ST app marked as unavailable (last status show as inactive". It will never get back online even I press the button on the device it self or restarted the ST app. I guess remove the device from the app and re-add back is the only way. Any idea how to fix this ?

Hi @IoTUser, Thank you very for your help :slight_smile: , what DH do you use for Aqara Button?

If you paired them properly and not using catchall then try going into the app and hit the Add Thing button. Then press the pairing button a few times and see if that helps.

If you used catchall then there is no way to get it back as the Network ID would have changed. Remove from ST, press and hold the pairing button for until the LED stops flashing (about 8 ot 10 seconds I think) then press and hold it again, this time you will get a series of very fast flashes, wait until they stop it is now reset completely.

Pair it back up via the app and not catchall. As mentioned numerous times, make sure you turn off ALL other hard wired Zigbee devices at the mains, so all bulbs, power outlets etc. before you start to pair te sensors, this prevents the sensors routing via any other devce and connect directly to the ST hub.

Hit the Add button in the app, press the pairing button on the sensor, wait a few seconds for he LED to respond, press again wait for the LED response. Keep doing this until the LED responds with 3 flashes, again keep repeating in the same manner, it will eventually appear in the app, once it does press the button again and wait for the LED response. Save the Sensor in the app and after that I would press the button again, wait for the LED, do this a couple of times. To be safe I would keep the other Zigbee devices turned off until the battery starts reporting. Once this happens then you know you know the sensor has connected directly to the hub properly and chances are it will never drop again.

I have paired over 30 sensors this way ( actually carried out over 300 pairings a few months back when we had an issue after a Hub F/W update) and all of them have stuck without issue. Well with the exception of one that is a great distance from the hub and has dropped a few times but a few quick presses of the button brings it straight back.

I use my own (xiaomi-zigbee-button.src
https://github.com/snalee/Xiaomi/tree/master/devicetypes/a4refillpad/xiaomi-zigbee-button.src).
It’s a bit laggy (sometimes the event isn’t triggered) with the SmartThings
app, but it works.

1 Like

You can either edit the device and select the handler for that device or I just edit the DH code that is already associated with the devices, save the changes and publish to self. The new code then gets applied to all associated devices. The only thing I’m not sure about is if it updates the configuration on the device if the DH configuration code changes.

Does anyone have a Xiaomi Button handler that supports multi-clicks? (Double, triple, and quadruple clicks)