Original & Aqara Xiaomi Zigbee Sensors (contact, temp, motion, button, outlet, leak, etc)

I am not a developer and surely miss something here.
Can someone tell me what to do with the src file I find for the sensor in question?

Thanks for your help.


@Jani -

This sounds a lot like the “ghost device” issue that I’ve experienced twice now. Rebooting my hub did not help the paired & working device actually appear on my hub’s device list as it did for you, however.

What I had to do is figure out the Device Network ID (DNI) for the device and manually add a device in the IDE with that DNI and assign the correct device handler.

The possible reason for this issue, so-called “stale” device handlers (DTHs) is explained this post I made last week. The advice to avoid it is to view all of the custom device handlers installed on your hub, and re-save and republish them.

I don’t quite understand what you mean here, but I can say this:

Support for the new SmartThings Samsung Connect app in all of the Xiaomi / Aqara device handlers cannot be promised until Samsung officially begins support for devices with custom device handlers. As of today, here is what I see in terms of developer support and documentation on this SmartThings Developer’s page:

Hub-connected device

Currently you can connect ZigBee or Z-Wave devices with either a SmartThings hub or Samsung Connect Home hub. We will offer developer tools and guides for hub-connected devices soon.

Some users have reported some success using some Xiaomi / Aqara devices with the new app, but until full documentation is provided, there is no way to know how to code device handlers to work correctly and take full advantage of the new app.

Personally, I don’t use the new app (in fact, I use another type of hub, Hubitat, with nearly all of my home automation devices and have just continued making improvements and updates to the Xiaomi / Aqara device handlers out of kindness towards the SmartThings Community). But based on all the posts I’ve read about it, I would not at all be surprised that it can’t handle backwards compatibility like what you are describing.

I find it hilarious that this option even shows up when the device handler doesn’t include code to support it.

Although full developer documentation for integrating hub-connected devices to the new SmartThings platform isn’t available, there are some bits and pieces, including an updated Capabilities Reference. Capabilities are the core of SmartThings automation as they define the types of events the device can create for apps to use and/or commands that can be sent by apps to control or manipulate the device.

This updated list of Capabilities includes a new Button Capability definition, which is significantly different from the previous definition. However, both the old and new Button Capability definition support a number of buttons to be set for a device, so presumably the new Samsung Connect app should work with that.

The newest version of the Xiaomi Button DTH, v1.3, does in fact include code to set the number of buttons available to SmartApps, right on line 350. If you had updated from a previous version of the DTH, it’s really important that you followed the note I included in my post announcing the new Xiaomi / Aqara Button device handlers:

If you had updated to the new Xiaomi Button DTH from a previous version, did you follow these instructions? If not, then the correct number of buttons available to SmartApps will not be set.

Either way, I am not sure why the Pressed 2 Times option appears in the new Samsung Connect app, because the current version device handler does not include code shown in the new Capabilities Reference to set the supported button values.

Maybe without that code, the default supported list includes pushed, held, and pushed twice? If that’s true, then what you’re experiencing will happen to anyone using a button with a custom device handler, not just Xiaomi / Aqara ones.

I am testing a significantly reworked Aqara Button device handler which sets the supported button values based on the button model, but this will require users to change automations so the correct trigger is used (for example, change button two pushed for a double-click automation trigger to button pushed twice.) The button values set by the device handler appear as choices in the older SmartThings “classic” app, so hopefully they will work in the new app as well.

After finishing and releasing the next Aqara Button DTH update, I plan to re-work the Xiaomi Button DTH next. I can share an early beta with you if you like. Please just PM me.

You do not need to be a developer to install a custom Device Handler (also known as “DTH”). You will need to install the Device Handler code to your SmartThings Hub.

There’s a very thorough FAQ on installing custom Device Handler or Smart App code here:

1 Like

Thanks. I had not followed the steps to save the preferences so that the number of buttons gets saved. Unfortunately it didn’t help in the new app because it still did not recognize that there was more than 1 button. The new app lists these possible device statuses when programming.

Hello, can the Xiaomi aqara read the atmosphere progression?


I finally installed the new SmartThings (Samsung Connect) mobile app, and my initial experience is that it is a total exercise in frustration. I can’t believe this is public release software, honestly.

Anyhow, I am going to have a really really hard time troubleshooting and supporting any Xiaomi / Aqara devices in the new app because for the majority of them, when I try to view them I get a blank screen and nothing ever happens. I have to force-quit the app to use it again. I am using the iOS version of the app, and I have no plans to spend money on an Android device just to get it working. Samsung needs to make sure their platform development teams are on the same page.

However, I think I might have found a workaround for you for the time being.

If you log into the IDE, then edit the Xiaomi Button to use SmartThings’s SmartSense Button device handler, save, and then change back to the Xiaomi Button device handler and save, it should limit the list of supported button values just to pushed, held, and pushed twice. More importantly, I was able to choose the button number, at least when setting up an automation in SmartThings’ Smart Lighting app:

However, I’m not at home to test whether a double-click results in both button two pushed and also button pushed twice events.

At this point, I should state that besides getting a blank screen when trying to view the devices, also seeing that the preference settings section of device handlers is missing, I am not sure how I would be able to properly support the use of Xiaomi / Aqara devices with the new SmartThings mobile app.

Yes, the device handler for the Aqara Temperature / Humidity Sensor supports reading and displaying atmospheric pressure. It does not display the current trend of atmospheric pressure, however (for example “pressure increasing” or pressure decreasing).

Just want to inform that my new Aqara Wireless Relay Control Module is working with no neutral switches DH !! Thank you veeceeoh !!
This is not the best DH since :

  1. There is no way to config the mechanical button as toggle switch or short press button (can do in fibaro)
  2. The DH did not show two switches to control. I found that only L2 can be control. But L1 can’t.
  3. I was able to add the switch to automation by ST and also to control from SharpTools. Alexa can control it too but it says : Sorry, [device name] is not responding, even though the light came ON or OFF.

Regarding the physical connection :

  1. You need to follow the instruction and connect the mechanical SW input to the L-IN short (came with short) of the module and remove the connection to the L (not like fibaro)
  2. I had only single lamp , in order to make it work from mechanical switch i needed to short S1 and S2, i don’t know the reason but it worked from me.

I’ll be happy to read other opinions. This is a picture of the connection i did:
connection Aqara Wireless relay.


Hello, On Xiaomi aqara temperature sensor can I modify the time refresh? It is too long time, about 1or 2 grades difference…thanks

Actually, all thanks for that DTH should go to @johndoyle who made the original version and @1mb4k4 who updated it to work with the changes in SmartThings Hub Firmware 25.27.

I believe a “child” device needs to be created, but I would recommend reading this thread focused on the Aqara Wired Switch models, and maybe asking about issues there.

I am planning to buy one of this relay model myself, so I can also work on the DTH, but I won’t receive it until late June probably.

No, this cannot be changed. The hardware is “locked” to report based on temperature / humidity / pressure changes, not based on time.

The Aqara Temperature / Humidity Sensor hardware only reports when:

  • the temperature changes more than 0.5° C, or
  • humidity level changes more than 6%
  • a change in atmospheric pressure (I cannot confirm the number)

Lot lot of thanks. There are other option soldering wires like on the motion sensor?? :slight_smile:

No, not for the Temperature / Humidity Sensor, sadly.

That’s great. I have time… I’ll wait for you to improve this DH. Meanwhile I will ask in the tread you mention regarding the child device and Amazon Alexa integration that need to be improved. Hope they’ll have some amswers.

Your DH works !! but need some improvements.

  1. Temperature is not calibrated. I’m seeing 150deg. this is too hot. How to calibrate ?
  2. Please resume last power state after power failure or at least let the user decide to resume last state or to go to off mode.
    Great thanks for your wonderful work with Xiaomi devices :+1::sunglasses:

Just ordered one from Aliexpress…
20$ and 14-20 days delivery to Denmark…
Planning to use it to control my bathroom ventilator - last device to get automated here for a 100% smart room… :blush:

1 Like

(Except for the toilet) :stuck_out_tongue_winking_eye:

1 Like

Thank you! After trying the new DTH I now have a useful Aqara double switch that I have in my Gazebo controlling the fan and the lights! Up until now this switch has sat in the closet for nearly a year doing nothing because I couldn’t get the two buttons to be recognized independently! I really appreciate the effort you’ve put into getting this code updated and working so well!


I’ve been trying to get a xaiomi door/window sensor to pair with my UK V2 hub. I’ve followed the instructions and have seen the zbjoin appear in the event log but it’s not showing up in the “add a thing” page on the app. Any suggestions?

New here. Can’t seem to find for the life of me how one actually integrates github thing to smartthings. I don’t see github in the ST app!

Which mobile app are you using - the SmartThings “Classic” app or the new Samsung Connect app? The “classic” app should be when pairing Xiaomi / Aqara devices.

If you are using the “classic” app, then there’s a way to manually add the device with information from the zbjoin event. I’d need to see a screenshot of the event details to walk you through it.

Hi, and welcome! GitHub integration is accomplished when logged into your hub’s Groovy IDE (Integrated Development Environment). The IDE is a webpage that you log into, either from a computer or mobile device, rather than an app.

I’d suggest reading through this FAQ:

And SmartThings’s official documentation on GitHub integration is here.

1 Like

Thanks for the response. I’ve managed to add it manually since posting that. FYI I was using the classic app.

I updated to latest dth and now the temp for the zigbee outlet is showing 170 degrees. Any idea why this is now inaccurate?

Can someone explain this code to me?
def tempValue = zigbee.parseHATemperatureValue("temperature: " + (convertHexToInt(descMap.value) / 2), "temperature: ", tempScale) + (tempOffset ? tempOffset : 0)

I changed it to
def tempValue = (convertHexToInt(descMap.value) / 2) + (tempOffset ? tempOffset : 0)

and it seems more accurate now I think. Although I still need to confirm the offset…

© 2019 SmartThings, Inc. All Rights Reserved. Terms of Use | Privacy Policy

SmartThings; SmartApps®; Physical Graph; Hello, Home; and Hello, Smart Home are all trademarks of the SmartThings, Inc.