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

Is the version you working on, is that the Version 1.2? Just updated the device handler to that version and will give that a go.

Yes, thatā€™s right. The GitHub comments thread on the link I gave has all my notes about the changes I made.

Great work guys!

The only thing I dont like is that the color on the temperature tiles are inconsistent from all the other devices I use. (Fibaro, Aeon multisensor, Netatmo etc)

Here is an example of the code used for other devices:

		backgroundColors:[
			[value: 31, 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"]
		]
	}

For me this seems to be the standard on all the official smartthings DTH, and the color will stay the same even if you switch between F and C

The color set to represent temperature display in the two Xioami Temp/Humidity sensor device handlers was derived directly from the SmartThingā€™s Developer Documentationā€™s Color Standards.

In that section of the documentation they link to an example Device Handler which accommodates both Celsius and Fahrenheit values:

The link is to the Ecobee Thermostat device handler code, and youā€™ll see the set of values is nearly the same - I think the Celsius values section of the color mapping for the Xiaomi DTHs were lowered a bit.

I have not seen this behavior, but certainly I can try the Fahrenheit-centric color set you quoted (same as on the ST Dev Docs) again and report my findings with screenshots back here.

I am getting duplicate notifications for each open and clsoe of one of these contact sensors. Anyone else see this behavior or know how to stop it ?

I am thinking of buying the square button (WXKG03LM) as this looks rather nice. Does this work with any of the DHā€™s? See that its mentioned the other type only (WXKG11LM)ā€¦

Another question is also whether it works dimming lights with this switch? E.g. by holding button for dimming?

1 Like

Iā€™ve only seen it happen now and then. No idea how to change it, because as far as I have seen, itā€™s based on messages sent directly by the hardware.

WXKG03LM <ā€” This one, right?

The wall surface-mounted Aqara Smart Light Switch model WXKG03LM can be used with the Aqara Button DH.

Sadly, the hardware only supports sending a button pressed message. Thereā€™s no multi-click or hold support.

Beware: The two-button Aqara Smart Light Switch model WXKG02LM does NOT work as two buttons with SmartThings. The technical reason for this is that the SmartThings ZigBee attribute report message parser strips out what is known as the endpoint number value. The two-button WXKG02LM model uses a different endpoint number for the left button press, right button press, and both-button press. The DH only receives all of those messages as coming from one button. Until SmartThings changes the way it handles ZigBee attribute reports with different endpoint numbers, the two button functionality of the WXKG02LM model will never work.

1 Like

what is the CATCHALL method ?

See my post here for the details.

Has anyone spoken to support to see if this is a bug or a ā€˜featureā€™ with the striping?

Hey guys, FYI the Xiaomi Zigbee Button handler as of v1.1 doesnā€™t actually work. Presses from the app tile work, but actual hardware presses donā€™t due to this line. buttonNumber should not be a String, removing the ā€œā€ makes it all work correctly.

They are most definitely aware of it. Whether itā€™s a bug or feature depends on who you ask.

The suggested workaround is to send commands to Zigbee devices asking them to send reports that include the endpoint data, but this does not work with Xiaomi device because they do not accept any commands. They only send reports to the hub.

1 Like

[UPDATE] ā€œoriginalā€ Xiaomi Button device hander to v1.2

Available immediately on the bspranger/Xiaomi GitHub repository. The updated code can be copied from this direct link.

New features

  • Button hold, which can set in preferences to send either a button 1 held or button 2 pushed event
  • Button status correctly displayed in main tile of mobile app UI, with a new custom icon
  • Live logging preference settings, with toggles for display of info (ā€œplainā€ English) and/or debug (technical) log messages. As a default, info log messages are displayed.
  • Improved webCoRE support

Important Notes

  • The minimum time required for held can be changed in the preference settings. The default based on extensive beta testing is 2.0 seconds, and decimal values are allowed. Note that shorter times may result in greatly reduced reliability (see note about SmartThings cloud execution limitations, below)
  • webCoRE users can make use of a number of custom attributes, some of which have been renamed from the previous version of the device handler:
    ā€¢ lastCheckinCoRE - updated on every single message received from the button
    ā€¢ lastPressedCoRE - updated when the button is physically pressed
    ā€¢ lastReleasedCoRE - updated when the button is physically released
    ā€¢ lastButtonMssg - updated every time the button is either physically pressed or released
  • Because the button held feature is not hardware-based, no events are sent until the button is physically released. This means that even if the minimum time to held setting is 2 seconds, if you hold the button for 10 seconds, the held event is sent at the 10 second point, not 2 seconds after the press started.
  • The device handler no longer sends button 1 released events. This is because SmartThingsā€™ button capability only supports pushed and held events.
  • The toggle mode option has been removed, because SmartThingsā€™ button capability doesnā€™t support button released events and also because most Smart Apps that work with buttons offer a toggle switch option already.
  • The SmartThings app UI display of button ā€œpushedā€ or ā€œheldā€ event lasts for about 1 second, and then will reset back to ā€œreleasedā€.
  • Limitation of cloud execution: During beta testing, I and the beta testers found the accuracy of the device handler registering pushed versus held correctly to be well over 90%, as long as the minimum held time was not too short. The problem is that because the code is ā€œcloudā€ executed every time a message is received from the button, sometimes the delays result in the release message being processed before the pressed message. The device handler decides whether a long press is a hold by comparing the press start time and release time, so if there are delays in the code execution, then even though you may hold the button long enough, the calculated time difference could be too short. There is really nothing that can be done to fix this other than physically holding the button for a longer time to compensate. However, I have made changes to the method used in the original a4refillpad device handler that improves on the level of reliability.

Screenshots:

2 Likes

Thanks for the bug report!

As luck would have it, a major update to v1.2 was ready to release today, after over a month of testing. The issue you identified is fixed in this new version.

1 Like

[UPDATE] Aqara Button device hander to v1.2

Available immediately on the bspranger/Xiaomi GitHub repository. The updated code can be copied from this direct link.

New features

  • Compatible with the new Aqara Button model WXKG12LM, which offers single-click, double-click, hold, and shake functions (see table below)
  • Compatible with Aqara Smart Light Switch models WXKG02LM / WXKG03LM (with limitations, see Important Notes, below)
  • Button status correctly displayed in main tile of mobile app UI, with a new custom icon
  • Live logging preference settings, with toggles for display of info (ā€œplainā€ English) and/or debug (technical) log messages. As a default, info log messages are displayed.
  • Improved webCoRE support

Aqara Model WXKG12LM Functions Table

Button action Event sent to hub
single-click button 1 pushed
hold button 1 held
double-click button 2 pushed
shake button 3 pushed

Note: the hold function is hardware-based, activated after 400ms according to Xiaomiā€™s specifications - which cannot be changed

Important Notes

  • Limitation: The ā€œoriginalā€ Aqara model WXKG11LM, and both models of Aqara Smart Light Switch only support button pushed. There is NO possibility of adding a hold feature for these models.
  • Limitation: The 2-button Aqara Smart Light Switch model WXKG02LM is only recognized as ONE button. This is because the SmartThings API ignores the data that distinguishes between left, right, or both-button presses.
  • webCoRE users can make use of a number of custom attributes, some of which have been renamed from the previous version of the device handler:
    ā€¢ lastCheckinCoRE - updated on every single message received from the button
    ā€¢ lastPressedCoRE - updated when the button is physically pressed (or shaken, for model WXKG12LM)
    ā€¢ lastReleasedCoRE - model WXKG12LM only updated when the button is physically released after being held
  • The device handler no longer sends button released events. This is because SmartThingsā€™ button capability only supports pushed and held events.
  • The toggle mode option has been removed, because SmartThingsā€™ button capability doesnā€™t support button released events and also because most Smart Apps that work with buttons offer a toggle switch option already.
  • The SmartThings app UI display of ā€œpushedā€ (or for model WXKG12LM, ā€œsingle-clickedā€, ā€œdouble-clickedā€, or ā€œshakenā€) lasts for about 1 second, and then will reset back to ā€œreleasedā€. When model WXKG12LMā€™s button is held, the UI will display ā€œheldā€ until the button is physically released, but note that the button 1 held event is always sent after the button has been held for 400ms.
4 Likes

thanks for your feedback - maybe a stupid question - how can I select the correct catchall ? - i select the closest catchall, create a device named it and put the device network id on it.There after I found it under things - and I paired it.
But it was empty when I try to open it. I am quiet sure I am using the correct device handler -( bspranger : xiaomi temerature humidity senser ā€“ not the type Aqara ).
There after I was confused - there was a lot of " catchalls - did a select the correct ?

( but I believe if I had select a wrong catchall I would not be able to find it under things - or would I ? )

PLS give me some feedback and have patience with me

Thanks for the update @veeceeoh - also working great with my WXKG03LMā€™s, so you can add those to the compability listā€¦
(still waiting for my WXKG12LMā€™s from Chinaā€¦) :crossed_fingers:

Just to avoid confusion - Shouldnā€™t this headline read WXKG12LM instead of WXKG11LM? :slight_smile:

// K

2 Likes

There can be other catchall messages listed in the hub events.

It should be similar to this:

09%20PM

Also, after pairing, there may be nothing displayed for the sensor in the SmartThings mobile app. It will only send reports when the temperature of humidity changes, and the first battery only comes about 1 hour after pairing.

So, after pairing, to check if you got the correct device Network ID, try blowing on the sensor to make it send temperature / humidity reports.

Yes, that was a mistake, and itā€™s fixed now - thanks!

I also noticed my direct link to the code was incorrect, and I listed the one-button Aqara Smart Wall Switch as model WXKG01LM, but it is actually model WXKG03LM, the same as you have - so yes that compatibility was intentional. :grin:

2 Likes

I have tested, and changing from C to F in the smartthings app will display the same color

Sensor 1:


Sensor 2: