|
--- |
|
# This automation simulates the use of the IKEA TRADFRI Remote control |
|
# connected through Zigbee2MQTT. |
|
|
|
# | Button | Action | |
|
# | -------- | -------------------- | |
|
# | Power | Toggle the light | |
|
# | Dim-Up | Increase brightness | |
|
# | Dim-Down | Decrease brightness | |
|
# | Right | Increase temperature | |
|
# | Left | Decrease temperature | |
|
|
|
blueprint: |
|
source_url: https://gist.github.com/niro1987/f6e84c27b304f0bf3be16a8f439e8efd |
|
|
|
name: Zigbee2MQTT - IKEA TRADFRI - 5 Button Remote - Warm White Lights |
|
|
|
description: >- |
|
This automation simulates the use of the IKEA TRADFRI Remote control |
|
connected through Zigbee2MQTT. |
|
|
|
domain: automation |
|
|
|
input: |
|
remote_entity: |
|
name: Remote Sensor Entity |
|
description: The sensor entity created by Zigbee2MQTT |
|
selector: |
|
entity: |
|
domain: sensor |
|
light_entity: |
|
name: Light |
|
description: The light entity to control. |
|
selector: |
|
target: |
|
entity: |
|
domain: light |
|
|
|
mode: restart |
|
|
|
variables: |
|
var_light_entities: !input light_entity |
|
|
|
trigger: |
|
- platform: state |
|
entity_id: !input remote_entity |
|
to: |
|
- "toggle" |
|
- "toggle_hold" |
|
- "brightness_up_click" |
|
- "brightness_down_click" |
|
- "arrow_left_click" |
|
- "arrow_right_click" |
|
- "brightness_up_hold" |
|
- "brightness_down_hold" |
|
- "arrow_left_hold" |
|
- "arrow_right_hold" |
|
- "brightness_up_release" |
|
- "brightness_down_release" |
|
- "arrow_left_release" |
|
- "arrow_right_release" |
|
|
|
action: |
|
- choose: |
|
# Short-Press on the power button. |
|
- conditions: |
|
- condition: template |
|
value_template: '{{ trigger.to_state.state == "toggle" }}' |
|
sequence: |
|
- service: light.toggle |
|
target: !input light_entity |
|
# Short-Press on the dim-up button. |
|
- conditions: |
|
- condition: template |
|
value_template: '{{ trigger.to_state.state == "brightness_up_click" }}' |
|
sequence: |
|
- service: light.turn_on |
|
target: !input light_entity |
|
data: |
|
brightness_step_pct: 20 |
|
transition: 0.5 |
|
# Short-Press on the dim-down button. |
|
- conditions: |
|
- condition: template |
|
value_template: '{{ trigger.to_state.state == "brightness_down_click" }}' |
|
sequence: |
|
- service: light.turn_on |
|
target: !input light_entity |
|
data: |
|
brightness_step_pct: -20 |
|
transition: 0.5 |
|
# Short-Press on the color-up button. |
|
- conditions: |
|
- condition: template |
|
value_template: '{{ trigger.to_state.state == "arrow_left_click" }}' |
|
sequence: |
|
- service: light.turn_on |
|
target: !input light_entity |
|
data: |
|
color_temp: >- |
|
{% if state_attr(var_light_entities.entity_id[0], "color_temp") - 18 < 153 %} |
|
{{ 153 }} |
|
{% else %} |
|
{{ state_attr(var_light_entities.entity_id[0], "color_temp") - 18 }} |
|
{% endif %} |
|
transition: 0.5 |
|
# Short-Press on the color-down button. |
|
- conditions: |
|
- condition: template |
|
value_template: '{{ trigger.to_state.state == "arrow_right_click" }}' |
|
sequence: |
|
- service: light.turn_on |
|
target: !input light_entity |
|
data: |
|
color_temp: >- |
|
{% if state_attr(var_light_entities.entity_id[0], "color_temp") + 18 > 500 %} |
|
{{ 500 }} |
|
{% else %} |
|
{{ state_attr(var_light_entities.entity_id[0], "color_temp") + 18 }} |
|
{% endif %} |
|
transition: 0.5 |
|
# Long-Press on the power button. |
|
- conditions: |
|
- condition: template |
|
value_template: '{{ trigger.to_state.state == "toggle_hold" }}' |
|
sequence: |
|
- service: light.turn_on |
|
target: !input light_entity |
|
data: |
|
brightness: 254 |
|
color_temp: 400 |
|
# Long-Press on the dim-up button. |
|
- conditions: |
|
- condition: template |
|
value_template: '{{ trigger.to_state.state == "brightness_up_hold" }}' |
|
sequence: |
|
- repeat: |
|
while: [] |
|
sequence: |
|
- service: light.turn_on |
|
target: !input light_entity |
|
data: |
|
brightness_step_pct: 10 |
|
transition: 0.5 |
|
- delay: |
|
milliseconds: 500 |
|
# Long-Press on the dim-down button. |
|
- conditions: |
|
- condition: template |
|
value_template: '{{ trigger.to_state.state == "brightness_down_hold" }}' |
|
sequence: |
|
- repeat: |
|
while: [] |
|
sequence: |
|
- service: light.turn_on |
|
target: !input light_entity |
|
data: |
|
brightness_step_pct: -10 |
|
transition: 0.5 |
|
- delay: |
|
milliseconds: 500 |
|
# Long-Press on the color-up button. |
|
- conditions: |
|
- condition: template |
|
value_template: '{{ trigger.to_state.state == "arrow_left_hold" }}' |
|
sequence: |
|
- repeat: |
|
while: [] |
|
sequence: |
|
- service: light.turn_on |
|
target: !input light_entity |
|
data: |
|
color_temp: >- |
|
{% if state_attr(var_light_entities.entity_id[0], "color_temp") - 18 < 153 %} |
|
{{ 153 }} |
|
{% else %} |
|
{{ state_attr(var_light_entities.entity_id[0], "color_temp") - 18 }} |
|
{% endif %} |
|
transition: 0.5 |
|
- delay: |
|
milliseconds: 500 |
|
# Long-Press on the color-down button. |
|
- conditions: |
|
- condition: template |
|
value_template: '{{ trigger.to_state.state == "arrow_right_hold" }}' |
|
sequence: |
|
- repeat: |
|
while: [] |
|
sequence: |
|
- service: light.turn_on |
|
target: !input light_entity |
|
data: |
|
color_temp: >- |
|
{% if state_attr(var_light_entities.entity_id[0], "color_temp") + 18 > 500 %} |
|
{{ 500 }} |
|
{% else %} |
|
{{ state_attr(var_light_entities.entity_id[0], "color_temp") + 18 }} |
|
{% endif %} |
|
transition: 0.5 |
|
- delay: |
|
milliseconds: 500 |
|
# Any other event will cancel the repeat loops. |
|
default: [] |
Hey again, I found the issue and how to fix it. When you select one entity, it adds it differently than when you add multiple. You have to edit the automation as yaml and correct it.
Wrong:
light_entity:
entity_id: light.0xbc...
Correct:
light_entity:
entity_id:
- light.0xbc...
Have a good day