Device Handler for Aqara Wired Wall Switch

I have a few ideas on how the DH might be improved. However, I want to clarify your expectations.
If I look at the behaviour of the equivalent unwired device I note that there is no expectation that the DH is synced with the bulb. However, what it does do is act as a toggle, such that it changes the on/off state of the bulb, irrespective of the initial state. When a switch is pressed the icon in the DH changes for about a second to blue and labelled “pressed” and then returns to its original state, gray and labelled “released”. This behaviour is preferable to the DH changing between “off” and “on” as there is no easy way to synchronise this with the state of the bulb, should that be changed by some other means, such as directly in the smarthings app. My point is that I have been trying to make the “unwired” switch on this device behave in the same way as the switches on the completely unwired device.
Another issue I have found is distinguishing between a simple press of the switch and the switch being held for a few seconds. The hardware produces different zigbee messages in these 2 cases. However, there is inevitably some latency in the system, a delay between the switch being pressed and the bulb responding. I suspect this leads the user to hold the switch until he/she sees a response, which may be long enough for the hardware to think it is being “held”. I’m wondering whether it would be better not to try to distinguish between pushed and held in the unwired case.
I’d value your views.

One other question. I’ve included the temperature in the DH as my device seems to give a sensible temperature. However, most of the Aqara devices give a temperature, but it is often not sensible. How does your device behave in this regard?

Hello and Good Evening!

I totally understand what you mean with the physical differences between the switch and the button and in our case make perfect sense.we need the “button” mode for the unwired tap.

Actually my first thought was using a wireless version of this zugebe switch, but unfortunately the package did not arrived from China and now I’m trying to improvise and this is how i got into this situation.

Regarding the second part I also agree with you.All of this devices have a totally normal lag in their function and who does not know that (like my wife for example) tend to over push the buttons.As a response to your question I would remove the “held” feature for now.

Regarding my problem, my switch still does not synchronize at all with SmartThings App :frowning: the DHT does not recognize my “hard” pushes.

Hope you can help me!

My devices all give some temperature informations, but it’s irrelevant because I think it’s the internal temperature of the device.
This is what i got:

Hope it helps!

I’ve just pushed a major update to GitHub with the following changes:

  1. Corrected a typo which meant that the button functionality didn’t work for unwired right switch.
  2. “Held” now works for the unwired switch (button1).
  3. Added a temperature offset, analogous to the Xiaomi temperature sensor. I’d be interested to know whether this helps to make the temperatuire measurement work properly.

I’ve also done a major rewrite of the logic which was designed to cope with receiving multiple, almost simultaneous, zigbee commands. Each push of these switches results in at least 2 zigbee commands. The previous version occasionally failed to respond properly as the responses to each command could interfere with each other.


Hi @aonghusmor !

This DHT update it’s a just great, a real game changer! :smiley:

My setup works now like a charm!

Thank you for your good work!

I posted an improved version on GitHub. This quietly catches a few error conditions, which might have caused the DH to fail.
This version can distinguish ‘pushed’ from ‘held’ for both the wired and the unwired switch.
On the unwired switch this appears as button1 to apps, such as ABC (Advanced Button Controller).
if both switches are pressed ABC will see button2.
I’ve also redesigned the main screen of the DH to give the 2 switches equal weight.

As an example I have mine configured such that a simple press of the unwired switch toggles the lamp to 40% brightness, but holding the switch for a second or so gives 100% brightness. Pressing both switches at the same time toggles a completely different lamp (just as a test) along with the
the wired lamp.

I know there is some doubt about precisely what temperature this device measures. I have left this capability in the DH, but have added the possibility of adding a constant shift to the measured temperature. I get sensible numbers, but I know that other people don’t.

1 Like

Hi, the temperature is coming back as Fahrenheit, how do I change it to Celcius?

HI! The temperature scale is set by the hub, not by the DH. The switch itself gives the temperature in Celsius, but that is converted to Fahrenheit by the DH, if the Hub is set that way. My switch gives sensible temperatures, but I know others have reported getting silly numbers. A typical Fahrenheit temperature should be about 70.
If you are able to look in the logs, with the ‘debug’ switch on, you should see a line containing ‘SmartShield’ followed by one containing ‘Map’. In the map you should see 3: followed by the raw temperature given by the device.
If you have other devices in your setup giving sensible Celsius temperatures, then your Hub is almost certainly set up OK.

Hi, aonghusmor

last night after I asked the question, I went thru the DH code and I must admit my knowledge of coding is abysmal having coded the last time in basic (commodore 64), yes I’m old… from my very limited know how I found this “temp = celsiusToFahrenheit(temp)” and added “//” before it making it look like this on the line " // temp = celsiusToFahrenheit(temp) "

well… that did it… it’s now reporting 19ºC which is about right… is it wrong? dunno… :wink:

The complete statement is

if ( getTemperatureScale() != “C” ) temp = celsiusToFahrenheit(temp)

It’s split over 2 lines, but that doesn’t matter.

So that suggests that ‘getTemperatureScale()’ is not returning “C”. It looks like your hub may be set for Fahrenheit.
The setting is well hidden in the smartthings classic app. If you go to the symbol with 3 horizontal lines (bottom right on the iOS app, but somewhere else on the Android one), then the wheel symbol, you come to a page where the temperature scale is set.

Hello @aonghusmor

I’ve updated the DHT with your latest release and first of all I noticed the new more friendly user interface which it’s great.After that I’ve noticed that there are some good improvement in terms of quickness of the unwired button.
The only problem that I’ve encountered was the fact that on some switches the right switch (always the wired one) sometimes enters in an ON-OFF loop. When I set it OFF it comes again ON and OFF and so on…After this problem I’ve decided to go back to the old DHT :smiley: It suits me better for now.

About the temperature, after setting the offset on each device, on some it’s showing the “real” temperature and on some devices it’s always showing the “wrong” temperature.

Thank you for your work,

Thanks for the feedback. Can you tell me whether the on-off looping happens when you use it as a hard or a soft switch, i.e. when the actual button is pressed or when it is done by software. If it’s intermittant it’s probably a timing issue. I’ll try to reproduce it.


It happens Both ways, it starts with hardware push then it does the same thing on soft push.


@aonghusmor Hi, I’m about to buy some Aqara wall switches. Thanks for your good dth for it with the holding and releasing functions.
But, I thought your DTH is for without-neutral version switches. Is it possible to apply this into the with-neutral version switches with just changing the model number in your dth? I just want to use releasing and holding button but it’s hard to find any DTH for the with-neutral aqara switch.

Hi! I see no reason why this shouldn’t work unless there is a significant difference between the firmware on the no neutral and with neutral versions. I have no way of testing this.

There are some differences.

See post number 45 in the thread above.

If that’s the only difference it shouldn’t be difficult to tweak my code to work for both. I’ll try to find time to look at it
Just to clarify: you say that the command that goes to endpoint 3 on the no neutral switch goes to endpoint 1 on the with neutral one. That means 1 and 2 refer to the right and left switches respectively? Is that correct?
I assume that also applies to the messages received from the switches, 1 and 2 refer to right and left (instead of 3 and 2).
What about the message received on endpoints 4 and 5?

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

I have no more info beyond that.

But my friend bought and installed the version with neutral wire required and I had to modify my code in that way to make it work for his installation.

I’m current don’t have any Aqara switches in my house to do verification tests either.

I never had looked at the returned messages as in prior versions of hub firmware, the catchall messages were filtered.

© 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.