How would you do that? I want this too – mimicking the original Ikea behaviour.
Hey poolcactus,
Thanks for the blueprint!
I modified it a bit to also support switches, my use cases being:
- being able to control ikea outlets to turn on/off the car engine heater in the winter (living in nordic country)
- being able to turn on/off light + outlet (Christmas led strips) at the same time
The outlets do not support dimming so a separate input was required. It’s still been able to dim the lights with an outlet if the same automation
“works on my home assistant” with Sky connect.
I found the repeat delay of 1s to be too long and set it to 300ms. I see no issues on my setup.
Here are the modifications:
blueprint:
name: ZHA - IKEA Tradfri on/off switch
description: 'Control your light(s) with IKEA Tradfri on/off switch
Select the Tradfri remote and your lights and or switch.
You can turn the lights and switches 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
multiple: false
light:
name: Light
description: The lights that will be controlled
default: {}
selector:
target:
entity:
- domain:
- light
switch:
name: Switch
description: The switches that will be controlled
default: {}
selector:
target:
entity:
- domain:
- switch
source_url: https://community.home-assistant.io/t/zha-ikea-tradfri-on-off-switch-incl-dimmer/255412
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: switch.turn_on
target: !input switch
- service: light.turn_on
target: !input light
data:
transition: 1
- conditions:
- "{{ command == 'off' }}"
- "{{ cluster_id == 6 }}"
- "{{ endpoint_id == 1 }}"
sequence:
- service: switch.turn_off
target: !input switch
- 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: 0.3
- 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: 0.3
- conditions:
- "{{ command == 'stop' }}"
- "{{ cluster_id == 8 }}"
- "{{ endpoint_id == 1 }}"
sequence:
- service: light.turn_on
target: !input light