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
222 stars 84 forks source link

ZHA Tradfri 5 button long press also triggers short press #148

Closed tomjschwanke closed 1 year ago

tomjschwanke commented 1 year ago

Hi, I created a ZHA Blueprint for the 5 button tradfri remote, however I think I might not be able to contribute it here, as the on/off button long press action always sends the short press action as well, with no real way to discern between the two. Does this disqualify the blueprint from submission or would it still be considered "good enough"?

Both long press and short press send the same

event_type: zha_event
data:
  device_ieee: [redacted]
  unique_id: [redacted]
  device_id: [redacted]
  endpoint_id: 1
  cluster_id: 6
  command: toggle
  args: []
  params: {}
origin: LOCAL
time_fired: "2023-07-04T15:23:32.371046+00:00"
context:
  id: 01H4GR0VMKM1FHF795G01R2C4X
  parent_id: null
  user_id: null

just that the long press also sends other events to identify it as a long press

Any idea if possible how to get around that?

Blueprint:

name: IKEA TRÅDFRI Remote
service: ZHA
event_type: zha_event
identifier_key: device_id
buttons:
buttons:
  - d: "m 125.39779,325.9315 c -14.57895,-22.6964 -22.32903,-49.1038 -22.32903,-76.0792 0.0512,-26.9598 7.84298,-53.3385 22.44891,-75.9998 l 3.22616,-4.917 c 26.33697,-37.4943 69.27512,-59.8234 115.09414,-59.8559 45.80207,0.068 88.70764,22.415 115.01856,59.9067 l 3.42148,4.7856 c 14.58025,22.6965 22.33164,49.1038 22.33164,76.0792 -0.052,26.9598 -7.84455,53.3385 -22.45152,75.9985 l -3.22616,4.9174 c -26.33828,37.493 -69.27512,59.8221 -115.09414,59.8533 -45.80077,-0.068 -88.70504,-22.415 -115.01596,-59.9054 z"
    actions:
      - title: press
        conditions:
          - key: command
            value: toggle
      - title: hold
        conditions:
          - key: command
            value: press
          - key: params.param1
            value: 2
          - key: params.param2
            value: 0
          - key: params.param3
            value: 0
  - d: "M 243.83797,23.1208 A 226.71716,226.71716 0 0 0 57.617181,120.9753 l 66.888079,44.9669 a 145.95894,145.95894 0 0 1 119.33661,-62.0619 145.95894,145.95894 0 0 1 119.25844,62.1153 l 67.13043,-45.1323 A 226.71716,226.71716 0 0 0 243.84057,23.1208 Z"
    actions:
      - title: press
        conditions:
          - key: command
            value: step_with_on_off
      - title: hold
        conditions:
          - key: command
            value: move_with_on_off
      - title: hold (released)
        conditions:
          - key: command
            value: stop_with_on_off
  - d: "M 124.57692,333.7494 57.443885,378.8817 A 226.71716,226.71716 0 0 0 243.83406,476.6242 226.71716,226.71716 0 0 0 430.05484,378.7697 L 363.16676,333.8028 A 145.95894,145.95894 0 0 1 243.83015,395.8621 145.95894,145.95894 0 0 1 124.57432,333.7494 Z"
    actions:
      - title: press
        conditions:
          - key: command
            value: step
      - title: hold
        conditions:
          - key: command
            value: move
      - title: hold (released)
        conditions:
          - key: command
            value: stop
  - d: "m 54.065279,125.9253 a 226.71716,226.71716 0 0 0 -36.948383,123.9048 226.71716,226.71716 0 0 0 37.042197,123.841 l 66.872437,-44.9577 a 145.95894,145.95894 0 0 1 -23.15251,-78.8846 145.95894,145.95894 0 0 1 23.2763,-78.8011 z"
    actions:
      - title: press
        conditions:
          - key: command
            value: press
          - key: params.param1
            value: 257
          - key: params.param2
            value: 13
          - key: params.param3
            value: 0
      - title: hold
        conditions:
          - key: command
            value: hold
          - key: params.param1
            value: 3329
          - key: params.param2
            value: 0
      - title: hold (released)
        conditions:
          - key: command
            value: release
          - key: button_last_state.0.title
            value: hold
  - d: "m 433.51163,126.0556 -66.87245,44.9565 a 145.95894,145.95894 0 0 1 23.15512,78.8845 145.95894,145.95894 0 0 1 -23.2789,78.8012 l 67.09004,45.1036 a 226.71716,226.71716 0 0 0 36.94838,-123.9048 226.71716,226.71716 0 0 0 -37.04219,-123.841 z"
    actions:
      - title: press
        conditions:
          - key: command
            value: press
          - key: params.param1
            value: 256
          - key: params.param2
            value: 13
          - key: params.param3
            value: 0
      - title: hold
        conditions:
          - key: command
            value: hold
          - key: params.param1
            value: 3328
          - key: params.param2
            value: 0
      - title: hold (released)
        conditions:
          - key: command
            value: release
          - key: button_last_state.0.title
            value: hold
Sian-Lee-SA commented 1 year ago

If press is always being initiated once touched, then you should call it init then double check there isn't another payload for press that could differentiate from a hold

nwithan8 commented 1 year ago

@tomjschwanke I'd recommend looking at this blueprint for the commands: https://github.com/niro1987/homeassistant-config/blob/main/blueprints/automation/niro1987/zha_ikea_tradfri_5button_remote_custom.yaml