Skip to content

Instantly share code, notes, and snippets.

@radimklaska
Last active October 25, 2023 20:12
Show Gist options
  • Save radimklaska/67ff2d5ffd776aaf1252e7169aba4fe9 to your computer and use it in GitHub Desktop.
Save radimklaska/67ff2d5ffd776aaf1252e7169aba4fe9 to your computer and use it in GitHub Desktop.
blueprint:
name: RK ZHA - IKEA Tradfri on/off switch
description: |
"Control your light(s) with IKEA Tradfri on/off switch
Select the Tradfri remote and your lights.
You can turn the lights On / Off, or hold the buttons to dim the lights"
domain: automation
input:
remote:
name: Remote
description: The remote that will control the lights
selector:
device:
integration: zha
manufacturer: 'IKEA of Sweden'
model: 'TRADFRI on/off switch'
light:
name: Light
description: The lights that will be controlled
selector:
target:
entity:
domain: light
mode: restart
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input 'remote'
action:
- variables:
command: "{{ trigger.event.data.command }}"
cluster_id: "{{ trigger.event.data.cluster_id }}"
endpoint_id: "{{ trigger.event.data.endpoint_id }}"
- choose:
- conditions:
- "{{ command == 'on' }}"
- "{{ cluster_id == 6 }}"
- "{{ endpoint_id == 1 }}"
sequence:
- service: light.turn_on
target: !input 'light'
data:
transition: 1
brightness_pct: 100
- conditions:
- "{{ command == 'off' }}"
- "{{ cluster_id == 6 }}"
- "{{ endpoint_id == 1 }}"
sequence:
- service: light.turn_off
target: !input 'light'
data:
transition: 1
- conditions:
- "{{ command == 'move_with_on_off' }}"
- "{{ cluster_id == 8 }}"
- "{{ endpoint_id == 1 }}"
sequence:
repeat:
while:
- condition: template
value_template: "{{ repeat.index < 10 }}"
sequence:
- service: light.turn_on
target: !input 'light'
data:
transition: 1
brightness_step_pct: 10
- delay: 1
- conditions:
- "{{ command == 'move' }}"
- "{{ cluster_id == 8 }}"
- "{{ endpoint_id == 1 }}"
sequence:
repeat:
while:
- condition: template
value_template: "{{ repeat.index < 10 }}"
sequence:
- service: light.turn_on
target: !input 'light'
data:
transition: 1
brightness_step_pct: -10
- delay: 1
- conditions:
- "{{ command == 'stop' }}"
- "{{ cluster_id == 8 }}"
- "{{ endpoint_id == 1 }}"
sequence:
- service: light.turn_on
target: !input 'light'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment