Xiaomi icon indicating copy to clipboard operation
Xiaomi copied to clipboard

"double-click" in Xiaomi Zigbee Button

Open tcholewa opened this issue 5 years ago • 17 comments

Hi @bspranger is there any chance to easy implement missing "double-click" action in original Xiaomi Zigbee Button?

double click catchall: 0104 0006 01 01 0100 00 5D4F 00 00 0000 0A 01 00802002

tcholewa avatar Mar 01 '19 15:03 tcholewa

The original Xiaomi Zigbee Button hardware supports double-click, triple-click, quadruple-click, and >5-click actions, but in the current SmartThings v2 and v3 firmware, all messages except single-click are filtered out.

The next SmartThings v2. v3 firmware update, v25.x, will open up more functionality, so I will be adding double-click, etc. functionality to the device handler.

That catchall message has nothing to do with the button click messages, by the way, but thanks for trying to help.

veeceeoh avatar Mar 01 '19 17:03 veeceeoh

oh, thanks for info. Is ST fw update date known? Or "sometime in the future"? :)

tcholewa avatar Mar 02 '19 10:03 tcholewa

Could I ask, why not parse the endpoint for doubleclick ? Like so:

in private Map parseReadAttrMessage(String description) {' def endpoint = description.split(",").find {it.split(":")[0].trim() == "endpoint"}?.split(":")[1].trim() then resultMap = mapButtonEvent(Integer.parseInt(value[2..3],16), Integer.parseInt(endpoint))

then in private mapButtonEvent(value, endpoint) { def buttonNum = endpoint if (value == 2) buttonNum+=3 and return [ name: 'button', value: eventType[value], data: [buttonNumber: buttonNum],

I'm not versed enough to make a github push request, sorry about that

SebyM avatar Mar 07 '19 17:03 SebyM

Could I ask, why not parse the endpoint for doubleclick ? Like so:

in private Map parseReadAttrMessage(String description) {' def endpoint = description.split(",").find {it.split(":")[0].trim() == "endpoint"}?.split(":")[1].trim() then resultMap = mapButtonEvent(Integer.parseInt(value[2..3],16), Integer.parseInt(endpoint))

then in private mapButtonEvent(value, endpoint) { def buttonNum = endpoint if (value == 2) buttonNum+=3 and return [ name: 'button', value: eventType[value], data: [buttonNumber: buttonNum],

I'm not versed enough to make a github push request, sorry about that

I just tried this and got 6 buttons: button1: Click, Hold button2: Click, Hold button3 = button1+button2 Hold button4 = button1 Double Click button5 = button2 Double Click button6 = button1+button2 Double Click

SebyM avatar Mar 07 '19 17:03 SebyM

@tcholewa

oh, thanks for info. Is ST fw update date known? Or "sometime in the future"? :)

The new SmartThings firmware version 25.20 was released yesterday - ONLY for v2 and v3 SmartThings hubs, please check this post for the schedule of deployment.

The new device handler (DTH) for the "original" round Xiaomi Button (model WXKG01LM) was released two days ago, and is ONLY for users with hubs running on firmware version 25.20 or newer. Please see this post for more details and a link to the new code.

@SebyM

Could I ask, why not parse the endpoint for doubleclick ?

Which device are you asking about? This thread is regarding the "original" round Xiaomi Button (model WXKG01LM), which only has one physical button.

Are you asking about the two-button Aqara Wireless Smart Wall Switch (model WXKG02LM)?

If yes then it sounds like you have one of the 2018 revision of the model WXKG02LM two-button Aqara Wireless Smart Wall Switch, and I am implementing exactly what you have described, because SmartThings firmware version 25.20 now allows the device handler to see the endpoint data.

I have already built a device driver for the Hubitat hub, which is groovy-based and works very similar to what is needed for a SmartThings device handler.

You can view the Hubitat device driver for all revisions and models of the Aqara Wireless Smart Wall Switches here.

veeceeoh avatar Mar 07 '19 18:03 veeceeoh

@veeceeoh Hmmm, weird, my hub was able to parse endpoints at 24.20 (as it hasn't updated yet)

Current FW: Firmware Version | 000.024.00020 Hardware Version | hub v2, UK customer bttn 1: Parsing 'read attr - raw: 26000100120A5500210100, dni: 2600, endpoint: 01, cluster: 0012, size: 0A, attrId: 0055, encoding: 21, value: 0001' bttn 2: Parsing 'read attr - raw: 26000200120A5500210100, dni: 2600, endpoint: 02, cluster: 0012, size: 0A, attrId: 0055, encoding: 21, value: 0001'

Yes I was referring to the WXKG02LM, just got it a few hours ago and couldn't help myself from playing with it. I feel like using all of the 8 (2^3) combinations will require me to write a manual for the rest of the house's users :)

SebyM avatar Mar 07 '19 18:03 SebyM

@SebyM

Hmmm, weird, my hub was able to parse endpoints at 24.20 (as it hasn't updated yet)

Yes, and I'm not surprised at all.

When I said that firmware version 25.20 allows the device handler to see the endpoint data, I am talking about both revisions of the Aqara Wireless Smart Wall Switches.

You've got a new revision of the two-button model WXKG02LM, which was only released late last year. I have a few of the original revision of WXKG02LM, and they send button press reports on cluster 0006, which was forwarded as an on/off: 1 message without endpoint data in firmware versions prior to 25.20.

Because I don't own any of the new revision of the Aqara Wireless Smart Wall Switches, I had to ask on the SmartThings and Habitat forums for help, and look for reports by users on other home automation platforms. And it's been difficult to get reports from people because they often don't even know they have one of the new revision Wireless Smart Wall Switches since the model number is the same as the original revision.

So, I only finalized the Hubitat device driver for the Aqara Wireless Smart Wall Switches some weeks ago, and was working on an update to the SmartThings device handler when I learned of the changes in the upcoming 25.x firmware update.

My intention has always to offer one device handler for both revisions of the Aqara Wireless Smart Wall Switch models. So I am now working on a completely new device handler, because it didn't make sense to keep a single combined device handler for all three revisions of the square Aqara Button and both revisions of the Aqara Wireless Smart Wall Switches.

In this new device driver, I've already set up what you suggested, but there are other aspects like changing what gets displayed in the main tile of the SmartThings Classic app (and people really seem to love having that feature), as well as correctly configuring everything when pairing the device.

Does that make sense?

Also, would you be able to do beta testing of the new device handler for Aqara Wireless Smart Wall Switches? 😁

veeceeoh avatar Mar 08 '19 18:03 veeceeoh

@veeceeoh

I see your point, a single DTH is the best option, I agree, and yes ofc I can test it! These days I'll poke around GitHUB and learn how to do a push request as well, maybe I can do more then just test!

I can't tell what revision my button is from looking at the outsides, so I opened it up and see this: Back plate: WXKG02LM CMIIT ID: 2016DP1247 Inside circuit board: LUMI LM15-WS R1.1

I'll be back with more data and maybe some code :)

SebyM avatar Mar 08 '19 19:03 SebyM

@SebyM

No need to worry about coding! I am nearly finished, and the code for the 2018 models should be working.

Grab the code from here (make sure to click "raw" then copy/paste): https://pastebin.com/4RgMcK0t

After assigning this DTH to your 2-button smart wall switch, go into the SmartThings Classic app, view the device, go into settings (gear icon), scroll down, and toggle on "Display debug log messages". That will help supply useful live logging messages for troubleshooting.

Thanks!

EDIT: I named the DTH "Aqara Wireless Smart Light Switch" so it won't be listed down with all of the Xiaomi DTHs. It will still be down towards the bottom of the list, where the custom DTHs are listed.

veeceeoh avatar Mar 08 '19 19:03 veeceeoh

Here is the testing result: https://pastebin.com/ESZMu7pt

Other than a config error on update (10:53:29 PM: error java.lang.NullPointerException: Cannot invoke method toJson() on null object @line 352 (initialize)) and a few text issues (. B01Right button was double-clicked (Button 5 pushed) - needs better spacing), it's working fine :)

SebyM avatar Mar 08 '19 20:03 SebyM

@SebyM Thanks for the feedback and log output! I've addressed those two issues and finished work on the initial beta release, starting at v0.9b.

The code is available here in the bspranger/Xiaomi repository. Direct link to raw code to copy from:

https://raw.githubusercontent.com/bspranger/Xiaomi/master/devicetypes/bspranger/xiaomi-aqara-wireless-switch.src/xiaomi-aqara-wireless-switch.groovy

veeceeoh avatar Mar 09 '19 03:03 veeceeoh

@veeceeoh Updated the DTH, will feedback with any issues I see

I'm curious if I can make 2 sub-tiles for each button for a better looking layout.

SebyM avatar Mar 09 '19 08:03 SebyM

See this gist for the updated device handler that uses the correct button capabilities for 2x-5x presses.

ericgla avatar Oct 02 '19 02:10 ericgla

excuse my off-topic,

Do you know, is it possible to re-flash this xiaomi button?

I see some nxp chip ns168 sms537 02 zxd846 But I cannot find what it is

I want to remove double click and hold. So, it will decreases delay before single click be outgone

a-x- avatar May 14 '20 11:05 a-x-

To decrease the hold time, change the value in in the device handler.

def holdTimeMillisec = Math.round((settings.waittoHeld?:2.0) * 1000)

If you would like to remove double click, change this line:

def clickType = [2: "pushed_2x", 3: "pushed_3x", 4: "pushed_4x", 5: "pushed_5x"]

The smartthings button schema expects the device handler to send 'pushed_2x'. If you change the string to something that is not in the schema, the event will not be sent.

For example try changing "pushed_2x" to "no_value" and you will no longer see the event.

ericgla avatar May 16 '20 15:05 ericgla

UPD: I’m sorry, I don’t use smartthings handlers, I need to decrease delays on the switch itself.

——

wow, how to change it? Are you know what IDE and toolchain I should use? And how to connect a programmer (flasher) device and what kind of programmer I need? And are you have a source code of firmware?

a-x- avatar May 17 '20 12:05 a-x-

195774D4-BA6E-4EB9-8DAA-33FE3DA3B5BF 3773B388-A498-49AB-B883-540D5F5B7B29 94910FD5-2365-44FD-B2DC-E75CD9AD575E

there is no even uart (or is there? tdi, tdo?)

a-x- avatar May 17 '20 12:05 a-x-