Skip to content

Instantly share code, notes, and snippets.

@niro1987
Last active January 15, 2022 09:02
Show Gist options
  • Save niro1987/b677ee700ea85ffd6a71fdb0fb05d96e to your computer and use it in GitHub Desktop.
Save niro1987/b677ee700ea85ffd6a71fdb0fb05d96e to your computer and use it in GitHub Desktop.
Home Assistant - Blueprint - ZHA - IKEA TRADFRI - 2 Button Remote - Custom Actions
---
# This automation simulates the use of the IKEA TRADFRI Dimmer control
# connected through ZHA.
blueprint:
source_url: https://github.com/niro1987/homeassistant-config/blob/main/blueprints/automation/niro1987/zha_ikea_tradfri_2button_remote_custom.yaml
name: ZHA - IKEA TRADFRI - 2 Button Remote - Custom Actions
description: >-
This automation simulates the use of the IKEA TRADFRI on/off switch
connected through ZHA.
domain: automation
input:
remote:
name: IKEA TRADFRI remote control
description: Select the remote control you wish to use.
selector:
device:
integration: zha
manufacturer: IKEA of Sweden
model: TRADFRI on/off switch
on_short:
name: Short Press - On Button
description: The action to perform on Short Press of the On Button
selector:
action:
default: []
off_short:
name: Short Press - Off Button
description: The action to perform on Short Press of the Off Button
selector:
action:
default: []
on_long:
name: Long Press - On Button
description: The action to perform on Long Press of the On Button
selector:
action:
default: []
off_long:
name: Long Press - Off Button
description: The action to perform on Long Press of the Off Button
selector:
action:
default: []
mode: restart
max_exceeded: silent
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input remote
action:
- choose:
# Short-Press the on button
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "on" }}'
sequence: !input on_short
# Long-Press the on button
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "move_with_on_off" }}'
sequence: !input on_long
# Short-Press the off button
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "off" }}'
sequence: !input off_short
# Long-Press the off button
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "move" }}'
sequence: !input off_long
# Any other event will cancel the repeat loops (i.e. releasing the [on|off] button)
default: []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment