Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Home Assistant - Blueprint - ZHA - IKEA TRADFRI - 2 Button Remote - OnOff and Brightness
---
# 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 brightness |
# | off (long) | Decrease brightness |
blueprint:
source_url: https://github.com/niro1987/homeassistant-config/blob/main/blueprints/automation/niro1987/zha_ikea_tradfri_2button_remote_brightness.yaml
name: ZHA - IKEA TRADFRI - 2 Button Remote - OnOff and Brightness
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
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:
brightness: 254
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:
brightness_step_pct: 10
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:
brightness_step_pct: -10
transition: 0.5
- delay:
milliseconds: 500
# Any other event will cancel the repeat loops (i.e. releasing the [on|off] button)
default: []
@cylonr
Copy link

cylonr commented Feb 6, 2021

Hi :)
Thansk 4 your work :)
It´s possible to when i turn on the light, it will keep the last dimm %?
thanks

@leocaseiro
Copy link

leocaseiro commented Nov 23, 2021

Hey @cylonr you can remove line 63, and should work as you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment