Aqara WXKG03lm Single Wireless button

Hi I am trying to use the above buttone, I am using the Smartthings driver developed by bspranger and although the logs show this:-

dev:5132018-10-21 13:47:08.846:infoXiaomi Aqara Single Button Light Switch was single-clicked (Button 1 pushed)

I cannot get it to do anything under the button app or rules if I double tap the Button then it cahnges to:-

dev:5132018-10-21 13:48:55.321:infoXiaomi Aqara Single Button Light Switch was double-clicked (Button 2 pushed)

Am I missing something?

Cheers Pete

We have a different button implementation than what that driver is using, so you will have to make some changes to it in that regard.

Thanks for the reply, I have now got the code working and it will detect a single click as button 1 and a double click as button 2 and control whatever device I want, I want to also be able to detect a hold which it does but yet again I cannot seem to control anything with the held command, the log shows:

dev:5132018-10-22 17:28:22.724:infoXiaomi Aqara Single Button Light Switch was held (Button 3 held)

what is the command for hold/held?

Regards Peter

I am maintaining a collection of Hubitat device drivers for Xiaomi devices here:

I don't own the single button wireless wall switch so there isn't a specific driver for it, but since you have one I can add support for it in one of the existing drivers (either the device driver for the Aqara button or the 2-button wireless wall switch (WXKG02LM) if you don't mind testing it.

However, from my experience with the 2-button WXKG02LM and based on my research, the 1-button WXKG03LM does not support double-click or hold in hardware. It only sends one type of message, when the button is pressed. So double-click functionality would have to be "emulated" using a timer in the device handler (the code for which I've worked on in both the "original" and Aqara button bspranger DTHs for SmartThings.)

Hi I have succesfully modded the driver to work with the single button and it does single click and double click, each one as if pressing a differant button, I have it working and switches on the hall light with one click and a double click switches on the hall light and outside light at the same time. It also detects hold but for some reason it doesnt seem to do anything, I have set it to hold and when hold is detected push button 3 but I can't seem to make it do anything unlike the single and double click, it is seen in the log file as:

dev:5132018-10-22 20:32:03.537:infoXiaomi Aqara Single Button Light Switch was held (Button 3 held)

So I am playing with this at the moment :slight_smile:
Pete

Oh and I have the no neutral aqara double relay switch working now as well

Pete

that's not how the schema was designed, its a single button controller, the button id will always be one, single click == event name:pushed, value:1, double clicked == event name:doubleTapped, value: 1

what you have done will obviously work, but it will likely confuse anyone using your driver.

Thanks, it's amazing what ignorance can do, not too sure why it should confuse, simply put if you click once ot looks as if button 1 was pressed, if you click twice it looks as if button 2 was pressed and if held it looks as if button 3 was pressed. These can be used in the button controller with no problems. The held doesnt work yet though it is reported.

Pete

its confusing because our implementation is centered around each physical button having a distinct id, numbered top to bottom, you have one physical button, not 3.
Additionally, some apps query for the button count via the numberOfButtons attribute, they use this to present the user the options available, per button and the capabilities.

A user using any of the button controller apps is expecting to program against pushed, held, released and doubleTapped if these are available.

They aren't expecting to have to look at the driver code to figure out that for this single button controller, held is really pushed 2, and doubleTapped is pushed 3...

As I said, its your driver so you can do whatever you want with it, however this also means that you get to support any user questions about why this button controller doesn't work like all the other button controllers...

Aaaah I see, the button controller is supposed to give pressed, double pressed and long press so i'll look at implementing the driver using your examples.

cheers pete

Just a quick question, if I manage to implement the button controller how would you use the button controller app to implement held or double press as it only gives you the option of push.

there are separate capabilities for each
capability "PushableButton" //<< mandatory for all button controllers
capability "HoldableButton"
capability "ReleasableButton"
capability "DoubleTapableButton"

You can look at my ported Almond click driver as an example. There is other code in there to fix a double report issue that you can ignore...but it's a single button device that support, push, held and doubleclick.

I've finished working on a brand new device driver. It is based on the previously released Aqara Smart Light Switch - 2 button model WXKG03LM device driver, but adds in parsing of messages from the single button WXKG02LM model. For now, I'm calling it a beta version.

Because Hubitat supports distinct pushed, doubleTapped, and held events, all of those are assigned to button 1 when the device driver is used with model WXKG02LM, and they should show up as available to use as triggers in any Hubitat app (including Rule Machine).

Unfortunately, there's no way to check the model during pairing that I'm aware of, so the number of buttons is set to 3 initially (to accommodate the 2 button model WXKG03LM), and then it's set again to 1 button on the first button message received if the device driver is used with model WXKG02LM.

Since I don't own any of the 1-button model WXKG02LM, I can only test the code with my 2-button wireless wall switches. Any testing by any model WXKG02LM owners would be greatly appreciated!

The new driver code can be grabbed from here.

Just got in, and about to hit the bed, quickly ran this and get this in the logs, first was one press the double press the hold

dev:5132018-10-24 22:26:53.620:errorgroovy.lang.MissingMethodException: No signature of method: dev15404163678112127518072.formatDate() is applicable for argument types: () values: [] on line 83 (parse)

dev:5132018-10-24 22:26:51.312:errorgroovy.lang.MissingMethodException: No signature of method: dev15404163678112127518072.formatDate() is applicable for argument types: () values: [] on line 83 (parse)

dev:5132018-10-24 22:26:49.203:errorgroovy.lang.MissingMethodException: No signature of method: dev15404163678112127518072.formatDate() is applicable for argument types: () values: [] on line 83 (parse)

Pete

Quick play, took out line 83 and now get

2018-10-24 22:35:59.101:errorgroovy.lang.MissingMethodException: No signature of method: dev1540416775098427154909.formatDate() is applicable for argument types: () values: [] on line 153 (parse)

dev:5132018-10-24 22:35:59.071:infoXiaomi Aqara Single Button Light Switch: Button was held

dev:5132018-10-24 22:35:59.068:infoXiaomi Aqara Single Button Light Switch: Number of buttons set to 1 for model WXKG03LM

dev:5132018-10-24 22:35:40.754:errorgroovy.lang.MissingMethodException: No signature of method: dev1540416775098427154909.formatDate() is applicable for argument types: () values: [] on line 153 (parse)

dev:5132018-10-24 22:35:40.682:infoXiaomi Aqara Single Button Light Switch: Button was pressed

dev:5132018-10-24 22:35:40.678:infoXiaomi Aqara Single Button Light Switch: Number of buttons set to 1 for model WXKG03LM

dev:5132018-10-24 22:33:29.214:errorgroovy.lang.MissingMethodException: No signature of method: dev1540416775098427154909.formatDate() is applicable for argument types: () values: [] on line 153 (parse)

dev:5132018-10-24 22:33:29.191:infoXiaomi Aqara Single Button Light Switch: Button was double-tapped

dev:5132018-10-24 22:33:29.187:infoXiaomi Aqara Single Button Light Switch: Number of buttons set to 1 for model WXKG03LM

The results are wrong though, 0=held 1=pushed and 2=double tap

Right time for bed will play more tomorrow

Cheers Pete

check the device data value "model" within the installed method, use that to set the numberOfButtons event

1 Like

Great - I'll give it a try, thanks!

I've fixed those groovy errors. The formatDate() is apparently a SmartThings-specific function call to produce a human-readable current date/time stamp. So I've replaced it with new Date().toLocaleTimeString() new Date().toLocaleString() which is used to log events to custom attributes that can be used in the Hubitat Dashboard to display the date/time for the last button pressed, double-tapped, and held events.

Sorry about that - I was rushing through my lunch break to produce this new device handler. I have also fixed this as well.

I will look at reading the device data value of model to determine which model is being used with the device handler later, when I am at home and can test it with my 2-button switches.

The updated code can be grabbed from the same link on GitHub here.

Thanks for helping test this new device driver!

EDIT: I mistakenly used the wrong time/date stamp call. It needs to be new Date().toLocaleString() in order to work on Hubitat.

Also, I have changed the initialization code used at pairing as mike suggested to set the correct number of buttons based on the model of wireless switch.

That works nicely for the single button, should the dual button work as well?If so I get:

2018-10-25 19:14:31.634:errorjava.lang.NullPointerException: Cannot invoke method getAt() on null object on line 117 (parse)

dev:62018-10-25 19:14:29.965:errorjava.lang.NullPointerException: Cannot invoke method getAt() on null object on line 117 (parse)

Using my double button

Pete