Skip to content

Instantly share code, notes, and snippets.

@sandervv
Last active March 3, 2023 08:34
Show Gist options
  • Save sandervv/6241a94c862691cabb30ae7bcc25d4fb to your computer and use it in GitHub Desktop.
Save sandervv/6241a94c862691cabb30ae7bcc25d4fb to your computer and use it in GitHub Desktop.
# Blueprint metadata
blueprint:
name: TRADFRI On/Off Switch - V2023.02.09
description: |
Control lights with a TRADFRI Dimmer Switch.
source_url: https://gist.github.com/sandervv/6241a94c862691cabb30ae7bcc25d4fb
domain: automation
#Define the inputs for the blueprint
input:
remote:
name: TRADFRI Wireless Dimmer
description: Select a remote to use with this blueprint
selector:
device:
integration: zha
manufacturer: IKEA of Sweden
model: TRADFRI on/off switch
entity:
domain: sensor
device_class: battery
# inputs for custom actions
button_on_short_press:
name: On button short press
description: Action to run on short on button press.
default: []
selector:
action:
button_on_long_press:
name: On button long press
description: Action to run on long on button press.
default: []
selector:
action:
button_off_short_press:
name: Off button short press
description: Action to run on short off button press.
default: []
selector:
action:
button_off_long_press:
name: Off button long press
description: Action to run on long off button press.
default: []
selector:
action:
mode: restart
max_exceeded: silent
# Trigger the automation when the selected remote sends an event
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input 'remote'
action:
- variables:
command: "{{ trigger.event.data.command }}"
- choose:
- conditions: '{{ command == ''on'' }}'
sequence: !input button_on_short_press
- conditions: "{{ command == 'move_with_on_off' }}"
sequence: !input button_on_long_press
- conditions: '{{ command == ''off'' }}'
sequence: !input button_off_short_press
- conditions: "{{ command == 'move' }}"
sequence: !input button_off_long_press
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment