Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save PaulHibbertMasterOfTheUniverse/1f514dad102fffcdcf495a7810f294b8 to your computer and use it in GitHub Desktop.

Select an option

Save PaulHibbertMasterOfTheUniverse/1f514dad102fffcdcf495a7810f294b8 to your computer and use it in GitHub Desktop.
Shelly BLU 4 button Home Assistant automation creator
blueprint:
name: Shelly BLU RC Button 4 ZB (ZHA) – 4 buttons (single/double/triple/hold)
description: >
ZHA blueprint for the Shelly BLU RC Button 4 ZB.
Lets you select your remote, then assign actions for:
single press, double press, triple press, and hold-release for each of the 4 buttons.
Note: “hold” here is the HOLD-RELEASE event (scene_id 11). The repeating “step” spam is ignored.
domain: automation
input:
remote_device:
name: Remote (ZHA device)
description: Select your Shelly BLU RC Button 4 ZB device from ZHA
selector:
device:
integration: zha
# Button 1
b1_single:
name: Button 1 – Single press
default: []
selector:
action: {}
b1_double:
name: Button 1 – Double press
default: []
selector:
action: {}
b1_triple:
name: Button 1 – Triple press
default: []
selector:
action: {}
b1_hold:
name: Button 1 – Hold (release)
default: []
selector:
action: {}
# Button 2
b2_single:
name: Button 2 – Single press
default: []
selector:
action: {}
b2_double:
name: Button 2 – Double press
default: []
selector:
action: {}
b2_triple:
name: Button 2 – Triple press
default: []
selector:
action: {}
b2_hold:
name: Button 2 – Hold (release)
default: []
selector:
action: {}
# Button 3
b3_single:
name: Button 3 – Single press
default: []
selector:
action: {}
b3_double:
name: Button 3 – Double press
default: []
selector:
action: {}
b3_triple:
name: Button 3 – Triple press
default: []
selector:
action: {}
b3_hold:
name: Button 3 – Hold (release)
default: []
selector:
action: {}
# Button 4
b4_single:
name: Button 4 – Single press
default: []
selector:
action: {}
b4_double:
name: Button 4 – Double press
default: []
selector:
action: {}
b4_triple:
name: Button 4 – Triple press
default: []
selector:
action: {}
b4_hold:
name: Button 4 – Hold (release)
default: []
selector:
action: {}
mode: single
triggers:
- trigger: event
event_type: zha_event
conditions: []
actions:
- variables:
selected_device_id: !input remote_device
evt_device_id: "{{ trigger.event.data.device_id }}"
endpoint_id: "{{ trigger.event.data.endpoint_id | int(0) }}"
cluster_id: "{{ trigger.event.data.cluster_id | int(0) }}"
command: "{{ trigger.event.data.command }}"
scene_id: >-
{% if trigger.event.data.params is defined and trigger.event.data.params.scene_id is defined %}
{{ trigger.event.data.params.scene_id | int }}
{% else %}
{{ none }}
{% endif %}
# Only process events from the chosen remote
- condition: template
value_template: "{{ evt_device_id == selected_device_id }}"
- choose:
# -------------------------
# SINGLE presses (cluster 6)
# -------------------------
# Button 1 single: endpoint 1, cluster 6, command "on"
- conditions:
- condition: template
value_template: "{{ cluster_id == 6 and endpoint_id == 1 and command == 'on' }}"
sequence: !input b1_single
# Button 2 single: endpoint 1, cluster 6, command "off"
- conditions:
- condition: template
value_template: "{{ cluster_id == 6 and endpoint_id == 1 and command == 'off' }}"
sequence: !input b2_single
# Button 3 single: endpoint 2, cluster 6, command "on"
- conditions:
- condition: template
value_template: "{{ cluster_id == 6 and endpoint_id == 2 and command == 'on' }}"
sequence: !input b3_single
# Button 4 single: endpoint 2, cluster 6, command "off"
- conditions:
- condition: template
value_template: "{{ cluster_id == 6 and endpoint_id == 2 and command == 'off' }}"
sequence: !input b4_single
# ----------------------------------------------------
# DOUBLE / TRIPLE / HOLD-RELEASE (cluster 5 scene recall)
# scene_id: 1=double, 2=triple, 11=hold-release
# endpoint_id: 1..4 identifies the button for recall events
# ----------------------------------------------------
# Button 1
- conditions:
- condition: template
value_template: "{{ cluster_id == 5 and command == 'recall' and endpoint_id == 1 and scene_id == 1 }}"
sequence: !input b1_double
- conditions:
- condition: template
value_template: "{{ cluster_id == 5 and command == 'recall' and endpoint_id == 1 and scene_id == 2 }}"
sequence: !input b1_triple
- conditions:
- condition: template
value_template: "{{ cluster_id == 5 and command == 'recall' and endpoint_id == 1 and scene_id == 11 }}"
sequence: !input b1_hold
# Button 2
- conditions:
- condition: template
value_template: "{{ cluster_id == 5 and command == 'recall' and endpoint_id == 2 and scene_id == 1 }}"
sequence: !input b2_double
- conditions:
- condition: template
value_template: "{{ cluster_id == 5 and command == 'recall' and endpoint_id == 2 and scene_id == 2 }}"
sequence: !input b2_triple
- conditions:
- condition: template
value_template: "{{ cluster_id == 5 and command == 'recall' and endpoint_id == 2 and scene_id == 11 }}"
sequence: !input b2_hold
# Button 3
- conditions:
- condition: template
value_template: "{{ cluster_id == 5 and command == 'recall' and endpoint_id == 3 and scene_id == 1 }}"
sequence: !input b3_double
- conditions:
- condition: template
value_template: "{{ cluster_id == 5 and command == 'recall' and endpoint_id == 3 and scene_id == 2 }}"
sequence: !input b3_triple
- conditions:
- condition: template
value_template: "{{ cluster_id == 5 and command == 'recall' and endpoint_id == 3 and scene_id == 11 }}"
sequence: !input b3_hold
# Button 4
- conditions:
- condition: template
value_template: "{{ cluster_id == 5 and command == 'recall' and endpoint_id == 4 and scene_id == 1 }}"
sequence: !input b4_double
- conditions:
- condition: template
value_template: "{{ cluster_id == 5 and command == 'recall' and endpoint_id == 4 and scene_id == 2 }}"
sequence: !input b4_triple
- conditions:
- condition: template
value_template: "{{ cluster_id == 5 and command == 'recall' and endpoint_id == 4 and scene_id == 11 }}"
sequence: !input b4_hold
default: []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment