Last active
September 26, 2025 12:10
-
-
Save andrioid/20876cc481970d152726dba51a8ed919 to your computer and use it in GitHub Desktop.
smarthjemmet zha button 4-way
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| blueprint: | |
| name: Smarthjemmet 4-way ZHA | |
| description: > | |
| Handle button presses from a Zigbee remote with 4 buttons via ZHA. | |
| Match on device IEEE, endpoint (1..4), and a gesture name (single/double/hold/release). | |
| If your remote uses different command names, override them below. | |
| domain: automation | |
| input: | |
| switch: | |
| name: Smarthjemmet QUAD-ZIG-SW | |
| description: Smarthjemmet QUAD-ZIG-SW knap | |
| selector: | |
| device: | |
| integration: zha | |
| multiple: false | |
| single_command: | |
| name: Gesture name for "single press" | |
| default: single | |
| selector: | |
| text: | |
| double_command: | |
| name: Gesture name for "double press" | |
| default: double | |
| selector: | |
| text: | |
| hold_command: | |
| name: Gesture name for "hold/long" | |
| default: hold | |
| selector: | |
| text: | |
| release_command: | |
| name: Gesture name for "release" | |
| default: release | |
| selector: | |
| text: | |
| # Button 1 actions | |
| b1_single_action: | |
| name: Button 1 — Single | |
| default: [] | |
| selector: | |
| action: {} | |
| b1_double_action: | |
| name: Button 1 — Double | |
| default: [] | |
| selector: | |
| action: {} | |
| b1_hold_action: | |
| name: Button 1 — Hold | |
| default: [] | |
| selector: | |
| action: {} | |
| b1_release_action: | |
| name: Button 1 — Release | |
| default: [] | |
| selector: | |
| action: {} | |
| # Button 2 actions | |
| b2_single_action: | |
| name: Button 2 — Single | |
| default: [] | |
| selector: | |
| action: {} | |
| b2_double_action: | |
| name: Button 2 — Double | |
| default: [] | |
| selector: | |
| action: {} | |
| b2_hold_action: | |
| name: Button 2 — Hold | |
| default: [] | |
| selector: | |
| action: {} | |
| b2_release_action: | |
| name: Button 2 — Release | |
| default: [] | |
| selector: | |
| action: {} | |
| # Button 3 actions | |
| b3_single_action: | |
| name: Button 3 — Single | |
| default: [] | |
| selector: | |
| action: {} | |
| b3_double_action: | |
| name: Button 3 — Double | |
| default: [] | |
| selector: | |
| action: {} | |
| b3_hold_action: | |
| name: Button 3 — Hold | |
| default: [] | |
| selector: | |
| action: {} | |
| b3_release_action: | |
| name: Button 3 — Release | |
| default: [] | |
| selector: | |
| action: {} | |
| # Button 4 actions | |
| b4_single_action: | |
| name: Button 4 — Single | |
| default: [] | |
| selector: | |
| action: {} | |
| b4_double_action: | |
| name: Button 4 — Double | |
| default: [] | |
| selector: | |
| action: {} | |
| b4_hold_action: | |
| name: Button 4 — Hold | |
| default: [] | |
| selector: | |
| action: {} | |
| b4_release_action: | |
| name: Button 4 — Release | |
| default: [] | |
| selector: | |
| action: {} | |
| mode: queued | |
| max: 20 | |
| trigger: | |
| - platform: event | |
| event_type: zha_event | |
| event_data: | |
| device_id: !input switch | |
| variables: | |
| # Normalize endpoint (button index) | |
| endpoint: >- | |
| {% if trigger.event.data.endpoint_id is defined %} | |
| {{ trigger.event.data.endpoint_id }} | |
| {% elif trigger.event.data.args is mapping and trigger.event.data.args.endpoint_id is defined %} | |
| {{ trigger.event.data.args.endpoint_id }} | |
| {% else %} | |
| 0 | |
| {% endif %} | |
| # Normalize gesture. Some ZHA devices put "single/double/hold" in args.click_type, others in "command". | |
| raw_command: "{{ (trigger.event.data.command | string) | lower }}" | |
| click_type: >- | |
| {% set a = trigger.event.data.args %} | |
| {% if a is mapping and a.click_type is defined %} | |
| {{ (a.click_type | string) | lower }} | |
| {% else %} | |
| {{ raw_command }} | |
| {% endif %} | |
| # Expected gesture names (from inputs) | |
| single_cmd: !input single_command | |
| double_cmd: !input double_command | |
| hold_cmd: !input hold_command | |
| release_cmd: !input release_command | |
| action: | |
| - choose: | |
| # -------- Button 1 -------- | |
| - conditions: "{{ endpoint | int == 2 and click_type == (single_cmd | lower) }}" | |
| sequence: !input b1_single_action | |
| - conditions: "{{ endpoint | int == 2 and click_type == (double_cmd | lower) }}" | |
| sequence: !input b1_double_action | |
| - conditions: "{{ endpoint | int == 2 and click_type == (hold_cmd | lower) }}" | |
| sequence: !input b1_hold_action | |
| - conditions: "{{ endpoint | int == 2 and click_type == (release_cmd | lower) }}" | |
| sequence: !input b1_release_action | |
| # -------- Button 2 -------- | |
| - conditions: "{{ endpoint | int == 3 and click_type == (single_cmd | lower) }}" | |
| sequence: !input b2_single_action | |
| - conditions: "{{ endpoint | int == 3 and click_type == (double_cmd | lower) }}" | |
| sequence: !input b2_double_action | |
| - conditions: "{{ endpoint | int == 3 and click_type == (hold_cmd | lower) }}" | |
| sequence: !input b2_hold_action | |
| - conditions: "{{ endpoint | int == 3 and click_type == (release_cmd | lower) }}" | |
| sequence: !input b2_release_action | |
| # -------- Button 3 -------- | |
| - conditions: "{{ endpoint | int == 4 and click_type == (single_cmd | lower) }}" | |
| sequence: !input b3_single_action | |
| - conditions: "{{ endpoint | int == 4 and click_type == (double_cmd | lower) }}" | |
| sequence: !input b3_double_action | |
| - conditions: "{{ endpoint | int == 4 and click_type == (hold_cmd | lower) }}" | |
| sequence: !input b3_hold_action | |
| - conditions: "{{ endpoint | int == 4 and click_type == (release_cmd | lower) }}" | |
| sequence: !input b3_release_action | |
| # -------- Button 4 -------- | |
| - conditions: "{{ endpoint | int == 5 and click_type == (single_cmd | lower) }}" | |
| sequence: !input b4_single_action | |
| - conditions: "{{ endpoint | int == 5 and click_type == (double_cmd | lower) }}" | |
| sequence: !input b4_double_action | |
| - conditions: "{{ endpoint | int == 5 and click_type == (hold_cmd | lower) }}" | |
| sequence: !input b4_hold_action | |
| - conditions: "{{ endpoint | int == 5 and click_type == (release_cmd | lower) }}" | |
| sequence: !input b4_release_action |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment