Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

double and long press function for xiaomi aqara button #274

Closed
faltim opened this issue Jan 25, 2018 · 9 comments
Closed

double and long press function for xiaomi aqara button #274

faltim opened this issue Jan 25, 2018 · 9 comments

Comments

@faltim
Copy link

faltim commented Jan 25, 2018

Thx for this awesome plugin!
Is it possible with deconz to add double and long press function for xiaomi aqara button (2)?

@ebaauw
Copy link
Owner

ebaauw commented Jan 25, 2018

Double press: yes, in v0.5.66.

Long press: no, see dresden-elektronik/deconz-rest-plugin#349 (comment).

@faltim
Copy link
Author

faltim commented Jan 26, 2018

Thx for information! Double press works.

@tomky
Copy link

tomky commented Nov 3, 2018

Hi, I would like to bring this up again as I find that there is a significant delay in the single press event triggered by Aqara switch compared with Philips Hue Dimmer switch. I feel that it could be due to the support of double press in Aqara switch so it must wait for a while to distinguish these two events. In some cases like light switching, this extra delay (around 1 sec) could be annoying.

If that is really the cause, could we disable double press event in exchange for faster single press detection?

@ebaauw
Copy link
Owner

ebaauw commented Nov 3, 2018

Not in deCONZ; the Aqara switch sends different messages for single press vs double press. You would have to change this in the Aqara firmware (which is not upgradable over-the-air).

@tomky
Copy link

tomky commented Nov 3, 2018

It seems to me that there are 1000 (press) and 1002 (release) events, and single press is triggered by 1002 so far. What if single press is triggered by 1000 so it will be triggered as soon as a press occurs?

If this brokes other mechanisms, what if we replace “long press” in homebridge with 1000 event so users who would like rapid single press can use this instead (although ironic)

@ebaauw
Copy link
Owner

ebaauw commented Nov 3, 2018

The Hue dimmer switch sends events on press vs release, the Aqara switch doesn’t. As I said before, it sends events on single press vs double press instead. Unfortunately the ZigBee standard doesn’t define this, and each manufacturer handles this differently.

@tomky
Copy link

tomky commented Nov 4, 2018

Actually, I find that this idea really works. I redirect the PRESS case to trigger LONG_PRESS event in hkZLLSwitchAction instead of NULL, and change the button type to SINGL_DOUBLE_LONG. I can see the following log:

Nov 04 09:34:46 pi homebridge[4640]: [11/4/2018, 9:34:46 AM] [Hue] lumi.sensor_switch_2 Button: homekit button long press
Nov 04 09:34:47 pi homebridge[4640]: [11/4/2018, 9:34:47 AM] [Hue] Light 3: homekit on changed from 0 to 1
Nov 04 09:34:47 pi homebridge[4640]: [11/4/2018, 9:34:47 AM] [Hue] lumi.sensor_switch_2 Button: homekit button single press
Nov 04 09:34:52 pi homebridge[4640]: [11/4/2018, 9:34:52 AM] [Hue] lumi.sensor_switch_2 Button: homekit button long press
Nov 04 09:34:52 pi homebridge[4640]: [11/4/2018, 9:34:52 AM] [Hue] Light 3: homekit on changed from 1 to 0
Nov 04 09:34:53 pi homebridge[4640]: [11/4/2018, 9:34:53 AM] [Hue] lumi.sensor_switch_2 Button: homekit button single press

As you can see, a long press is triggered before a single press for around 1 sec earlier and triggered the homekit action. Also in the double press event, there will be two long press actions. So I need to remove both single press and double press actions to avoid conflicts. But I'm satisfied with the rapid "Long Press" action.

I also doubt maybe I'm actually using an old version of Xiaomi round button switch instead of Aqara version. Not sure where to check this.

@ebaauw
Copy link
Owner

ebaauw commented Nov 4, 2018

I think the lumi.sensor_switch is indeed the Mi switch, not the Aqara one. I don't have one of those, so cannot test myself, but from the deCONZ code, it does send different messages for press vs release, https://github.com/dresden-elektronik/deconz-rest-plugin/blob/3ebf00f010f591a19dca1fe123b221ca7c52d38a/sensor.cpp#L272-L283.

I redirect the PRESS case to trigger LONG_PRESS event in hkZLLSwitchAction instead of NULL

I'm not going to make that change homebridge-hue. It will break existing logic, and it will break compatibility with the Hue bridge. Unlike deCONZ, the Hue bridge doesn't send push notifications, so homebridge-hue relies on polling to receive buttonevents from the Hue bridge. The initial press is often missed because of that.

@tomky
Copy link

tomky commented Nov 4, 2018

Yes, I agree that it is a hack and will be unsuitable for general purpose. I will maintain my own fork. Thanks for the assistance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants