Instantly share code, notes, and snippets.
Last active
January 26, 2022 08:45
-
Save blizzrdof77/91341a37e4b2eb9db5047c1a20391953 to your computer and use it in GitHub Desktop.
HASS Blueprint | ZHA - Aqara Opple - Wireless 6-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 6-Button Scene Switch [Extended Support] | |
description: Control anything using an Aqara Opple six-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/91341a37e4b2eb9db5047c1a20391953/ | |
input: | |
remote: | |
name: Remote | |
description: Opple remote to use | |
selector: | |
device: | |
integration: zha | |
manufacturer: LUMI | |
model: lumi.remote.b686opcn01 | |
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: | |
assigned_device_id: !input 'remote' | |
linked_entity_id: !input 'linked_entity_id' | |
linked_entity: >- | |
{%- if linked_entity_id|string == '' -%} | |
{{ device_entities(assigned_device_id)|first|default('') }} | |
{%- else -%} | |
{{ linked_entity_id }} | |
{%- endif -%} | |
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', 'middle_left_')|replace('4', 'middle_right_')|replace('5', 'bottom_left_')|replace('6', 'bottom_right_') ) | trim -%} | |
{{ (btnarea|string).split('__')|first }} | |
push_type: >- | |
{%- set pushtype = ((event|string|replace(' ', '-')).split('_')|last)|replace('-', '_')|replace('release', 'hold_release')|replace('long_press', 'hold_in') -%} | |
{%- if not pushtype.startswith('hold') and '_press' not in pushtype -%} | |
{{ pushtype + '_press' }} | |
{%- else -%} | |
{{ pushtype }} | |
{%- endif -%} | |
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 + '_action'] }} | |
{%- endif -%} | |
default_service: 'script.custom_service_trigger' | |
default_service_data: | |
entity_id: '{{ linked_entity }}' | |
action_type: '{{ push_type }}' | |
button_area: '{{ "button_" + btn_area }}' | |
- service: system_log.write | |
data: | |
level: warning | |
logger: system_log.external.zigbee_blueprints | |
message: "Zigbee Custom Event Log Message -- \n\n default_service: {{ default_service }} \n\n default_service_data: {{ default_service_data }}" | |
- service_template: '{{ default_service }}' | |
data: '{{ dict(default_service_data) }}' | |
# - 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_middle_left_single_press' | |
# - conditions: | |
# - '{{ event == "3_double" }}' | |
# sequence: !input 'button_middle_left_double_press' | |
# - conditions: | |
# - '{{ event == "3_triple" }}' | |
# sequence: !input 'button_middle_left_triple_press' | |
# - conditions: | |
# - '{{ event == "3_release" }}' | |
# sequence: !input 'button_middle_left_hold_release' | |
# - conditions: | |
# - '{{ event == "3_long press" }}' | |
# sequence: !input 'button_middle_left_hold_in' | |
# - conditions: | |
# - '{{ event == "4_single" }}' | |
# sequence: !input 'button_middle_right_single_press' | |
# - conditions: | |
# - '{{ event == "4_double" }}' | |
# sequence: !input 'button_middle_right_double_press' | |
# - conditions: | |
# - '{{ event == "4_triple" }}' | |
# sequence: !input 'button_middle_right_triple_press' | |
# - conditions: | |
# - '{{ event == "4_release" }}' | |
# sequence: !input 'button_middle_right_hold_release' | |
# - conditions: | |
# - '{{ event == "4_long press" }}' | |
# sequence: !input 'button_middle_right_hold_in' | |
# - conditions: | |
# - '{{ event == "5_single" }}' | |
# sequence: !input 'button_bottom_left_single_press' | |
# - conditions: | |
# - '{{ event == "5_double" }}' | |
# sequence: !input 'button_bottom_left_double_press' | |
# - conditions: | |
# - '{{ event == "5_triple" }}' | |
# sequence: !input 'button_bottom_left_triple_press' | |
# - conditions: | |
# - '{{ event == "5_release" }}' | |
# sequence: !input 'button_bottom_left_hold_release' | |
# - conditions: | |
# - '{{ event == "5_long press" }}' | |
# sequence: !input 'button_bottom_left_hold_in' | |
# - conditions: | |
# - '{{ event == "6_single" }}' | |
# sequence: !input 'button_bottom_right_single_press' | |
# - conditions: | |
# - '{{ event == "6_double" }}' | |
# sequence: !input 'button_bottom_right_double_press' | |
# - conditions: | |
# - '{{ event == "6_triple" }}' | |
# sequence: !input 'button_bottom_right_triple_press' | |
# - conditions: | |
# - '{{ event == "6_release" }}' | |
# sequence: !input 'button_bottom_right_hold_release' | |
# - conditions: | |
# - '{{ event == "6_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