Instantly share code, notes, and snippets.
Last active
January 26, 2022 08:46
-
Save blizzrdof77/7dfb360c78596e0d39557ae3449fc75b to your computer and use it in GitHub Desktop.
HASS Blueprint | ZHA - Aqara Opple - Wireless 2-Button Scene Switch [Extended Support]
This file contains 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: ZHA - Aqara Opple - Wireless 2-Button Scene Switch [Extended Support] | |
description: Control anything using an Aqara Opple two-button remote. This version has linked entity support -- meaning you can link an entity_id to assign actions, target devices, and target areas by using custom attributes in customize.yaml. | |
domain: automation | |
source_url: https://gist.github.com/blizzrdof77/7dfb360c78596e0d39557ae3449fc75b | |
input: | |
remote: | |
name: Remote | |
description: Opple remote to use | |
selector: | |
device: | |
integration: zha | |
manufacturer: LUMI | |
model: lumi.remote.b286opcn01 | |
linked_entity_id: | |
name: Linked Entity (Optional) | |
description: Optionally link an entity to use it's custom attributes defined in customize.yaml. | |
default: "" | |
selector: | |
entity: {} | |
button_left_single_press: | |
name: Left button - Single press | |
description: Action to run on a single press of the Left button | |
default: [] | |
selector: | |
action: {} | |
button_left_double_press: | |
name: Left button - Double press | |
description: Action to run on a double press of the Left button | |
default: [] | |
selector: | |
action: {} | |
button_left_triple_press: | |
name: Left button - Triple press | |
description: Action to run on a triple press of the Left button | |
default: [] | |
selector: | |
action: {} | |
button_left_hold_release: | |
name: Left button - Hold release | |
description: Action to run when Left button was held in and released | |
default: [] | |
selector: | |
action: {} | |
button_left_hold_in: | |
name: Left button - Hold in | |
description: Action to run when Left button is held in | |
default: [] | |
selector: | |
action: {} | |
button_right_single_press: | |
name: Right button - Single press | |
description: Action to run on a single press of the right button | |
default: [] | |
selector: | |
action: {} | |
button_right_double_press: | |
name: Right button - Double press | |
description: Action to run on a double press of the right button | |
default: [] | |
selector: | |
action: {} | |
button_right_triple_press: | |
name: Right button - Triple press | |
description: Action to run on a triple press of the right button | |
default: [] | |
selector: | |
action: {} | |
button_right_hold_release: | |
name: Right button - Hold release | |
description: Action to run whenRight button was held in and released | |
default: [] | |
selector: | |
action: {} | |
button_right_hold_in: | |
name: Right button - Hold in | |
description: Action to run whenRight button is held in | |
default: [] | |
selector: | |
action: {} | |
mode: restart | |
max_exceeded: silent | |
trigger: | |
- platform: event | |
event_type: zha_event | |
event_data: | |
device_id: !input 'remote' | |
action: | |
- variables: | |
linked_entity: !input 'linked_entity_id' | |
event: >- | |
{%- if trigger.event.data is defined and trigger.event.data.command is defined -%} | |
{{ trigger.event.data.command }} | |
{%- endif -%} | |
btn_area: >- | |
{%- set btnarea = (event|replace('1', 'top_left_')|replace('2', 'top_right_')|replace('3', 'bottom_left_')|replace('4', 'bottom_right_')) -%} | |
{{ (btnarea|string).split('__')|first }} | |
push_type: >- | |
{%- set pushtype = (event|string).split('_')|last -%} | |
{{ pushtype }} | |
opts: >- | |
{%- set area_opts = state_attr(linked_entity, 'button_' + btn_area ) -%} | |
{{ area_opts }} | |
target_entity: >- | |
{%- if linked_entity|string != '' -%} | |
{{ state_attr(linked_entity, 'button_' + btn_area)['target_entity_id'] }} | |
{%- endif -%} | |
target_service: >- | |
{%- if linked_entity|string != '' -%} | |
{{ state_attr(linked_entity, 'button_' + btn_area)[push_type + '_press_action'] }} | |
{%- endif -%} | |
- choose: | |
- conditions: | |
- '{{ event == "1_single" }}' | |
sequence: !input 'button_left_single_press' | |
- conditions: | |
- '{{ event == "1_double" }}' | |
sequence: !input 'button_left_double_press' | |
- conditions: | |
- '{{ event == "1_triple" }}' | |
sequence: !input 'button_left_triple_press' | |
- conditions: | |
- '{{ event == "1_release" }}' | |
sequence: !input 'button_left_hold_release' | |
- conditions: | |
- '{{ event == "1_long press" }}' | |
sequence: !input 'button_left_hold_in' | |
- conditions: | |
- '{{ event == "2_single" }}' | |
sequence: !input 'button_right_single_press' | |
- conditions: | |
- '{{ event == "2_double" }}' | |
sequence: !input 'button_right_double_press' | |
- conditions: | |
- '{{ event == "2_triple" }}' | |
sequence: !input 'button_right_triple_press' | |
- conditions: | |
- '{{ event == "2_release" }}' | |
sequence: !input 'button_right_hold_release' | |
- conditions: | |
- '{{ event == "2_long press" }}' | |
sequence: !input 'button_right_hold_in' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment