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

New Blueprint: Matching `1` and `0` does not work #166

Closed hco closed 1 year ago

hco commented 1 year ago

Hey, thanks for this nice tool!

I'm using ZHA and am trying to implement a blueprint for IKEAs e2123. I based my work on the existing Zigbee2MQTT-yaml, which saves me the trouble of creating the shapes :-)

My YAML looked finished, but only some of the buttons worked. I have issues with list-conditions in some cases. I created a small example. Look for move_mode in my example that caused problems. Using a template condition fixed it.

name: Aaa Ikea Debug 
service: ZHA
event_type: zha_event
identifier_key: device_id
buttons:
  # VOLUME UP
  # Does not work
  - d: "M192.3,137.86h116.38c14.78,0,28.17,5.91,37.97,15.49l118-118C442.81,13.51,412.64,0,379.31,0 H120.69c-33.33,0-63.5,13.51-85.34,35.35l118.48,118.48C163.67,143.97,177.27,137.86,192.3,137.86z"
    actions:
      - title: press
        conditions:
        - key: command
          value: "move_with_on_off"
          # The following does not work
        - key: params.move_mode
          value: 1 
  # VOLUME DOWN
  # Works using template condition
  - d: "M347.02,347.02c-9.82,9.79-23.37,15.84-38.34,15.84H192.3c-15.21,0-28.96-6.26-38.82-16.34 L35.35,464.65C57.19,486.49,87.36,500,120.69,500h258.63c33.33,0,63.5-13.51,85.34-35.35L347.02,347.02z"
    conditions: "{{ data.params.move_mode == 1 }}"
    actions:
      - title: press
        conditions:
          - key: command
            value: "move_with_on_off"
      - title: hold
        conditions:
          - key: command
            value: "move"
  # DOT 2 
  - d: "M362.99,250v58.55c0,15.03-6.11,28.63-15.97,38.47l117.64,117.64 c21.84-21.84,35.35-52.01,35.35-85.34V250H362.99z"
    conditions:
      - key: command
        value: "shortcut_v1_events"
      - key: params.shortcut_button
        value: 2
    actions:
      - title: press
        conditions:
          - key: params.shortcut_event
            value: 1
      - title: double press
        conditions:
          - key: params.shortcut_event
            value: 2
      - title: hold
        conditions:
          - key: params.shortcut_event
            value: 3

The following contains an example event from the debug tools:

{
    "data": {
        "device_ieee": "...",
        "unique_id": "...",
        "device_id": "...",
        "endpoint_id": 1,
        "cluster_id": 8,
        "command": "move_with_on_off",
        "args": [
            0,
            255
        ],
        "params": {
            "move_mode": 0,
            "rate": 255
        },
        "variables": null,
        "switch_id": "0",
        "button_last_state": [
            null,
            {
                "action": 0,
                "title": "press",
                "timestamp": 1692207090.4696858
            },
            {
                "action": 2,
                "title": "hold",
                "timestamp": 1692207083.1211245
            }
        ],
        "timestamp": 1692207098.615152
    },
    "event": "incoming"
}

Any idea if this is a bug or if I am doing something wrong? :)

hco commented 1 year ago

Sneaked in some debug code into https://github.com/Sian-Lee-SA/Home-Assistant-Switch-Manager/blob/master/custom_components/switch_manager/models.py#L22, and apparently the value is actually a MoveMode-enum, which means casting it to string will result in the string MoveMode.Up

Sian-Lee-SA commented 1 year ago

Will keep communication on this over in the PR thread