Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save Mysli0210/326ed01ed1018b44260e5e1ed8ac3194 to your computer and use it in GitHub Desktop.

Select an option

Save Mysli0210/326ed01ed1018b44260e5e1ed8ac3194 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://gist.github.com/Mysli0210/326ed01ed1018b44260e5e1ed8ac3194
name: ZHA - IKEA TRADFRI - 2 Button Remote - RODRET - 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
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: []
on_long_repeat:
name: Long Press - On Button - Enable Repeat
description: Repeat the on button action while held
selector:
boolean:
default: false
on_long_repeat_delay:
name: Long Press - On Button - Repeat Delay
description: Delay in milliseconds between repeats (only used if repeat is enabled)
selector:
number:
min: 100
max: 2000
step: 50
unit_of_measurement: ms
mode: slider
default: 500
off_long:
name: Long Press - Off Button
description: The action to perform on Long Press of the Off Button
selector:
action:
default: []
off_long_repeat:
name: Long Press - Off Button - Enable Repeat
description: Repeat the off button action while held
selector:
boolean:
default: false
off_long_repeat_delay:
name: Long Press - Off Button - Repeat Delay
description: Delay in milliseconds between repeats (only used if repeat is enabled)
selector:
number:
min: 100
max: 2000
step: 50
unit_of_measurement: ms
mode: slider
default: 500
long_release:
name: Long Press - Release
description: The action to perform on Long Press Release
selector:
action:
default: []
mode: restart
max_exceeded: silent
variables:
on_long_repeat: !input on_long_repeat
off_long_repeat: !input off_long_repeat
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 in ['move_with_on_off', 'move'] }}"
- condition: template
value_template: "{{ trigger.event.data.params.move_mode == 0 }}"
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{ on_long_repeat }}"
sequence:
- repeat:
while: []
sequence:
- sequence: !input on_long
- delay:
milliseconds: !input on_long_repeat_delay
default: !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 in ['move_with_on_off', 'move'] }}"
- condition: template
value_template: "{{ trigger.event.data.params.move_mode == 1 }}"
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{ off_long_repeat }}"
sequence:
- repeat:
while: []
sequence:
- sequence: !input off_long
- delay:
milliseconds: !input off_long_repeat_delay
default: !input off_long
# Long-Press Release of/off button
- conditions:
- condition: template
value_template: "{{ trigger.event.data.command == 'stop_with_on_off' }}"
sequence: !input long_release
# 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