Instantly share code, notes, and snippets.
blueprint zha_ikea_tradfri_4button_remote_color
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 - IKEA TRADFRI - 4 Button Remote - Color Lights | |
description: | |
This automation simulates the use of the IKEA TRADFRI remote control | |
connected through ZHA. | |
domain: automation | |
input: | |
remote: | |
name: IKEA TRADFRI remote control 4 buttons | |
description: Select the remote control you wish to use. | |
selector: | |
device: | |
integration: zha | |
manufacturer: IKEA of Sweden | |
model: Remote Control N2 | |
light: | |
name: Light | |
description: Select the light entity you wish to control. | |
selector: | |
entity: | |
domain: light | |
speed: | |
name: Speed | |
description: The speed in which to update the light when the button is held. | |
selector: | |
number: | |
min: 100.0 | |
max: 1000.0 | |
step: 100.0 | |
unit_of_measurement: milliseconds | |
mode: slider | |
default: 500 | |
mode: restart | |
max_exceeded: silent | |
variables: | |
var_light: !input "light" | |
var_speed: !input "speed" | |
trigger: | |
- platform: event | |
event_type: zha_event | |
event_data: | |
device_id: !input "remote" | |
action: | |
- choose: | |
- conditions: | |
- condition: template | |
value_template: '{{ trigger.event.data.command == "on" }}' | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: !input "light" | |
data: | |
brightness: 100 | |
color_temp: 450 | |
- conditions: | |
- condition: template | |
value_template: '{{ trigger.event.data.command == "off" }}' | |
sequence: | |
- service: light.turn_off | |
target: | |
entity_id: !input "light" | |
- conditions: | |
- condition: template | |
value_template: | |
'{{ trigger.event.data.command == "move_to_level_with_on_off" | |
}}' | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: !input "light" | |
data: | |
brightness: 254 | |
hs_color: | |
- 38.222 | |
- 52.941 | |
- conditions: | |
- condition: template | |
value_template: '{{ trigger.event.data.command == "step_with_on_off" }}' | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: !input "light" | |
data: | |
brightness_step_pct: 20 | |
transition: "{{ (var_speed / 1000)|float }}" | |
- conditions: | |
- condition: template | |
value_template: '{{ trigger.event.data.command == "move_with_on_off" }}' | |
sequence: | |
- repeat: | |
while: [] | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: !input "light" | |
data: | |
brightness_step_pct: 10 | |
transition: "{{ (var_speed / 1000)|float }}" | |
- delay: | |
milliseconds: !input "speed" | |
- conditions: | |
- condition: template | |
value_template: '{{ trigger.event.data.command == "step" }}' | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: !input "light" | |
data: | |
brightness_step_pct: -20 | |
transition: "{{ (var_speed / 1000)|float }}" | |
- conditions: | |
- condition: template | |
value_template: '{{ trigger.event.data.command == "move" }}' | |
sequence: | |
- repeat: | |
while: [] | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: !input "light" | |
data: | |
brightness_step_pct: -10 | |
transition: "{{ (var_speed / 1000)|float }}" | |
- delay: | |
milliseconds: !input "speed" | |
- conditions: | |
- condition: template | |
value_template: '{{ trigger.event.data.command == "press" }}' | |
- condition: template | |
value_template: "{{ trigger.event.data.args == [256,13,0] }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: !input "light" | |
data: | |
hs_color: | |
- "{% if state_attr(var_light, \"hs_color\")[0] + 18 > 360 %}\n {{ state_attr(var_light,\ | |
\ \"hs_color\")[0] + 18 - 360 }}\n{% else %}\n {{ state_attr(var_light,\ | |
\ \"hs_color\")[0] + 18 }}\n{% endif %}" | |
- '{{ state_attr(var_light, "hs_color")[1] }}' | |
transition: "{{ (var_speed / 1000)|float }}" | |
- conditions: | |
- condition: template | |
value_template: '{{ trigger.event.data.command == "hold" }}' | |
- condition: template | |
value_template: "{{ trigger.event.data.args == [3328,0] }}" | |
sequence: | |
- repeat: | |
while: [] | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: !input "light" | |
data: | |
hs_color: | |
- "{% if state_attr(var_light, \"hs_color\")[0] + 18 > 360 %}\n {{ state_attr(var_light,\ | |
\ \"hs_color\")[0] + 18 - 360 }}\n{% else %}\n {{ state_attr(var_light,\ | |
\ \"hs_color\")[0] + 18 }}\n{% endif %}" | |
- '{{ state_attr(var_light, "hs_color")[1] }}' | |
transition: "{{ (var_speed / 1000)|float }}" | |
- delay: | |
milliseconds: !input "speed" | |
- conditions: | |
- condition: template | |
value_template: '{{ trigger.event.data.command == "press" }}' | |
- condition: template | |
value_template: "{{ trigger.event.data.args == [257,13,0] }}" | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: !input "light" | |
data: | |
hs_color: | |
- '{{ state_attr(var_light, "hs_color")[0] }}' | |
- |- | |
{% if state_attr(var_light, "hs_color")[1] + 33 < 100 %} | |
{{ state_attr(var_light, "hs_color")[1] + 33 }} | |
{% else %} | |
0 | |
{% endif %} | |
transition: "{{ (var_speed / 1000)|float }}" | |
- conditions: | |
- condition: template | |
value_template: '{{ trigger.event.data.command == "hold" }}' | |
- condition: template | |
value_template: "{{ trigger.event.data.args == [3329,0] }}" | |
sequence: | |
- repeat: | |
while: [] | |
sequence: | |
- service: light.turn_on | |
target: | |
entity_id: !input "light" | |
data: | |
hs_color: | |
- '{{ state_attr(var_light, "hs_color")[0] }}' | |
- "{% if state_attr(var_light, \"hs_color\")[1] - 10 < 0 %}\n {{ state_attr(var_light,\ | |
\ \"hs_color\")[1] - 10 + 100 }}\n{% else %}\n {{ state_attr(var_light,\ | |
\ \"hs_color\")[1] - 10 }}\n{% endif %}" | |
transition: "{{ (var_speed / 1000)|float }}" | |
- delay: | |
milliseconds: !input "speed" | |
default: [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment