Skip to content

Instantly share code, notes, and snippets.

@niro1987
Last active January 15, 2022 08:56
Show Gist options
  • Save niro1987/eb20ded3d1b955e2547bafb3bb134b79 to your computer and use it in GitHub Desktop.
Save niro1987/eb20ded3d1b955e2547bafb3bb134b79 to your computer and use it in GitHub Desktop.
Home Assistant - Blueprint - ZHA - IKEA TRADFRI - 2 Button Remote - OnOff and Temperature
---
# This automation simulates the use of the IKEA TRADFRI Dimmer control
# connected through ZHA.
# | Button | Action |
# | ----------- | -------------------- |
# | on (short) | Turn the light on |
# | off (short) | Turn the light off |
# | on (long) | Increase temperature |
# | off (long) | Decrease temperature |
blueprint:
source_url: https://github.com/niro1987/homeassistant-config/blob/main/blueprints/automation/niro1987/zha_ikea_tradfri_2button_remote_temperature.yaml
name: ZHA - IKEA TRADFRI - 2 Button Remote - OnOff and Temperature
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
light:
name: Light
description: Select the light entity you wish to control.
selector:
entity:
domain: light
mode: restart
max_exceeded: silent
variables:
var_light: !input light
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:
- service: light.turn_on
target:
entity_id: !input light
data:
hs_color:
- 38.222
- 52.941
transition: 1
# Long-Press the on button
- 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:
color_temp: >-
{% if state_attr(var_light, "color_temp") + 18 > 500 %}
{{ 500 }}
{% else %}
{{ state_attr(var_light, "color_temp") + 18 }}
{% endif %}
transition: 0.5
- delay:
milliseconds: 500
# Short-Press the off button
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "off" }}'
sequence:
- service: light.turn_off
target:
entity_id: !input light
data:
transition: 1
# Long-Press the off button
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "move" }}'
sequence:
- repeat:
while: []
sequence:
- service: light.turn_on
target:
entity_id: !input light
data:
color_temp: >-
{% if state_attr(var_light, "color_temp") - 18 < 153 %}
{{ 153 }}
{% else %}
{{ state_attr(var_light, "color_temp") - 18 }}
{% endif %}
transition: 0.5
- delay:
milliseconds: 500
# 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