Sian-Lee-SA / Home-Assistant-Switch-Manager

Switch manager is a centralised component to handle button pushes for your wireless switches. This includes anything passed through the event bus. The component relies on switch blueprints which is easily made to allow GUI configuration of your switches and their button pushes. This helps remove clutter from the automations.
Other
232 stars 85 forks source link

Philips Hue Smart Button short press / long press #161

Closed Drealine closed 1 year ago

Drealine commented 1 year ago

Hi How can I check short and long press with my philips hue smart button ? I would like to use hold action to change random color of my light but when set the automation, it trigger also press button so the light turn off after it.

Tk

Sian-Lee-SA commented 1 year ago

Might be a firmware issue (Chinese knock off?) or your zigbee server what ever that may be. Otherwise check and debug against the blueprint and/or contact the author of that blueprint

wbsantos commented 1 year ago

Hello,

I was having the same problem. After checking out the blueprint I realized that the "press" action is actually being triggered by the "release" event of zigbee2mqtt. The release event is also triggered when holding the button (and then releasing it).

The "press" event of zigbee2mqtt cannot be used as the press event in the blueprint because it is triggered before the holding event, but it is instead mapped to the "init" event of the switch manager. That because it doesn't matter how you use the button, the "press" event of zigbee2mqtt will always be the first to fire, so it serves as the "init" in switch manager.

The solution I came up with is simple: after the "press" event we just have to check if the last state of the button was "init" for "single press" or something else for "hold", "step forward" or "step backward".

I added a stop condition as the first action to my automation to simplify things.

choose:
  - conditions:
      - condition: template
        value_template: "{{ data.button_last_state[0].title != \"init\" }}"
        alias: Not a single press
    sequence:
      - stop: Not a single press (propably hold)`
github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 1 year ago

This issue was closed because it has been inactive for 14 days since being marked as stale.