Instantly share code, notes, and snippets.
Last active
January 26, 2022 08:46
-
Save blizzrdof77/8f5151136fdd14f055874bd5e05fdc30 to your computer and use it in GitHub Desktop.
HASS Blueprint | ZHA - Aqara Opple - Wireless 4-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 4-Button Scene Switch [Extended Support] | |
description: Control anything using Aqara Opple four-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/8f5151136fdd14f055874bd5e05fdc30 | |
input: | |
remote: | |
name: Remote | |
description: Opple remote to use | |
selector: | |
device: | |
integration: zha | |
manufacturer: LUMI | |
model: lumi.remote.b486opcn01 | |
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_top_left_single_press: | |
name: Top left button - Single press | |
description: Action to run on a single press of the top left button | |
default: [] | |
selector: | |
action: {} | |
button_top_left_double_press: | |
name: Top left button - Double press | |
description: Action to run on a double press of the top left button | |
default: [] | |
selector: | |
action: {} | |
button_top_left_triple_press: | |
name: Top left button - Triple press | |
description: Action to run on a triple press of the top left button | |
default: [] | |
selector: | |
action: {} | |
button_top_left_hold_release: | |
name: Top left button - Hold release | |
description: Action to run when top left button was held in and released | |
default: [] | |
selector: | |
action: {} | |
button_top_left_hold_in: | |
name: Top left button - Hold in | |
description: Action to run when top left button is held in | |
default: [] | |
selector: | |
action: {} | |
button_top_right_single_press: | |
name: Top right button - Single press | |
description: Action to run on a single press of the top right button | |
default: [] | |
selector: | |
action: {} | |
button_top_right_double_press: | |
name: Top right button - Double press | |
description: Action to run on a double press of the top right button | |
default: [] | |
selector: | |
action: {} | |
button_top_right_triple_press: | |
name: Top right button - Triple press | |
description: Action to run on a triple press of the top right button | |
default: [] | |
selector: | |
action: {} | |
button_top_right_hold_release: | |
name: Top right button - Hold release | |
description: Action to run when top right button was held in and released | |
default: [] | |
selector: | |
action: {} | |
button_top_right_hold_in: | |
name: Top right button - Hold in | |
description: Action to run when top right button is held in | |
default: [] | |
selector: | |
action: {} | |
button_middle_left_single_press: | |
name: Middle left button - Single press | |
description: Action to run on a single press of the middle left button | |
default: [] | |
selector: | |
action: {} | |
button_middle_left_double_press: | |
name: Middle left button - Double press | |
description: Action to run on a double press of the middle left button | |
default: [] | |
selector: | |
action: {} | |
button_middle_left_triple_press: | |
name: Middle left button - Triple press | |
description: Action to run on a triple press of the middle left button | |
default: [] | |
selector: | |
action: {} | |
button_middle_left_hold_release: | |
name: Middle left button - Hold release | |
description: Action to run when middle left button was held in and released | |
default: [] | |
selector: | |
action: {} | |
button_middle_left_hold_in: | |
name: Middle left button - Hold in | |
description: Action to run when middle left button is held in | |
default: [] | |
selector: | |
action: {} | |
button_middle_right_single_press: | |
name: Middle right button Single press | |
description: Action to run on a single press of the middle right button | |
default: [] | |
selector: | |
action: {} | |
button_middle_right_double_press: | |
name: Middle right button Double press | |
description: Action to run on a double press of the middle right button | |
default: [] | |
selector: | |
action: {} | |
button_middle_right_triple_press: | |
name: Middle right button triple press | |
description: Action to run on a triple press of the middle right button | |
default: [] | |
selector: | |
action: {} | |
button_middle_right_hold_release: | |
name: Middle right button Hold release | |
description: Action to run when middle right button was held in and released | |
default: [] | |
selector: | |
action: {} | |
button_middle_right_hold_in: | |
name: Middle right button Hold in | |
description: Action to run when middle right button is held in | |
default: [] | |
selector: | |
action: {} | |
button_bottom_left_single_press: | |
name: Bottom left button - Single press | |
description: Action to run on a single press of the bottom left button | |
default: [] | |
selector: | |
action: {} | |
button_bottom_left_double_press: | |
name: Bottom left button - Double press | |
description: Action to run on a double press of the bottom left button | |
default: [] | |
selector: | |
action: {} | |
button_bottom_left_triple_press: | |
name: Bottom left button - Triple press | |
description: Action to run on a triple press of the bottom left button | |
default: [] | |
selector: | |
action: {} | |
button_bottom_left_hold_release: | |
name: Bottom left button - Hold release | |
description: Action to run when bottom left button was held in and released | |
default: [] | |
selector: | |
action: {} | |
button_bottom_left_hold_in: | |
name: Bottom left button - Hold in | |
description: Action to run when bottom left button is held in | |
default: [] | |
selector: | |
action: {} | |
button_bottom_right_single_press: | |
name: Bottom right button - Single press | |
description: Action to run on a single press of the bottom right button | |
default: [] | |
selector: | |
action: {} | |
button_bottom_right_double_press: | |
name: Bottom right button - Double press | |
description: Action to run on a double press of the bottom right button | |
default: [] | |
selector: | |
action: {} | |
button_bottom_right_triple_press: | |
name: Bottom right button - Triple press | |
description: Action to run on a triple press of the bottom right button | |
default: [] | |
selector: | |
action: {} | |
button_bottom_right_hold_release: | |
name: Bottom right button - Hold release | |
description: Action to run when bottom right button was held in and released | |
default: [] | |
selector: | |
action: {} | |
button_bottom_right_hold_in: | |
name: Bottom right button - Hold in | |
description: Action to run when bottom right 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_top_left_single_press' | |
- conditions: | |
- '{{ event == "1_double" }}' | |
sequence: !input 'button_top_left_double_press' | |
- conditions: | |
- '{{ event == "1_triple" }}' | |
sequence: !input 'button_top_left_triple_press' | |
- conditions: | |
- '{{ event == "1_release" }}' | |
sequence: !input 'button_top_left_hold_release' | |
- conditions: | |
- '{{ event == "1_long press" }}' | |
sequence: !input 'button_top_left_hold_in' | |
- conditions: | |
- '{{ event == "2_single" }}' | |
sequence: !input 'button_top_right_single_press' | |
- conditions: | |
- '{{ event == "2_double" }}' | |
sequence: !input 'button_top_right_double_press' | |
- conditions: | |
- '{{ event == "2_triple" }}' | |
sequence: !input 'button_top_right_triple_press' | |
- conditions: | |
- '{{ event == "2_release" }}' | |
sequence: !input 'button_top_right_hold_release' | |
- conditions: | |
- '{{ event == "2_long press" }}' | |
sequence: !input 'button_top_right_hold_in' | |
- conditions: | |
- '{{ event == "3_single" }}' | |
sequence: !input 'button_bottom_left_single_press' | |
- conditions: | |
- '{{ event == "3_double" }}' | |
sequence: !input 'button_bottom_left_double_press' | |
- conditions: | |
- '{{ event == "3_triple" }}' | |
sequence: !input 'button_bottom_left_triple_press' | |
- conditions: | |
- '{{ event == "3_release" }}' | |
sequence: !input 'button_bottom_left_hold_release' | |
- conditions: | |
- '{{ event == "3_long press" }}' | |
sequence: !input 'button_bottom_left_hold_in' | |
- conditions: | |
- '{{ event == "4_single" }}' | |
sequence: !input 'button_bottom_right_single_press' | |
- conditions: | |
- '{{ event == "4_double" }}' | |
sequence: !input 'button_bottom_right_double_press' | |
- conditions: | |
- '{{ event == "4_triple" }}' | |
sequence: !input 'button_bottom_right_triple_press' | |
- conditions: | |
- '{{ event == "4_release" }}' | |
sequence: !input 'button_bottom_right_hold_release' | |
- conditions: | |
- '{{ event == "4_long press" }}' | |
sequence: !input 'button_bottom_right_hold_in' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment