blueprint:
name: ZHA - IKEA Styrbar - Warm White Lights
description: Control a light with white spectrum and dimming via a Ikea Styrbar Remote connected trough ZHA
domain: automation
input:
remote:
name: IKEA Styrbar remote control
description: Select the remote control you wish to use.
selector:
device:
integration: zha
manufacturer: IKEA of Sweden
model: Remote Control N2
multiple: false
light:
name: Light
description: Select the light entity you wish to control.
selector:
entity:
domain: [light]
multiple: false
reorder: false
on_color_temp_kelvin:
name: Color temperature on ON
description: 0 = not set (use previous value)
default: 0
selector:
number:
min: 0
max: 6500
unit_of_measurement: K
on_brightness_pct:
name: Brightness on ON
description: 0 = not set (use previous value)
default: 0
selector:
number:
min: 0
max: 100
unit_of_measurement: "%"
mode: restart
max_exceeded: silent
variables:
var_light: !input light
var_on_color_temp_kelvin: !input on_color_temp_kelvin
var_on_brightness_pct: !input on_brightness_pct
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input remote
action:
- choose:
# --- ON: Color and Brightness is set ---
- conditions:
- condition: template
value_template: "{{ trigger.event.data.command == 'on' }}"
- condition: template
value_template: "{{ (var_on_color_temp_kelvin | int) > 0 and (var_on_brightness_pct | int) > 0 }}"
sequence:
- service: light.turn_on
target:
entity_id: !input light
data:
color_temp_kelvin: !input on_color_temp_kelvin
brightness_pct: !input on_brightness_pct
# --- ON: only Color is set ---
- conditions:
- condition: template
value_template: "{{ trigger.event.data.command == 'on' }}"
- condition: template
value_template: "{{ (var_on_color_temp_kelvin | int) > 0 and (var_on_brightness_pct | int) == 0 }}"
sequence:
- service: light.turn_on
target:
entity_id: !input light
data:
color_temp_kelvin: !input on_color_temp_kelvin
# --- ON: only Brightness is set ---
- conditions:
- condition: template
value_template: "{{ trigger.event.data.command == 'on' }}"
- condition: template
value_template: "{{ (var_on_color_temp_kelvin | int) == 0 and (var_on_brightness_pct | int) > 0 }}"
sequence:
- service: light.turn_on
target:
entity_id: !input light
data:
brightness_pct: !input on_brightness_pct
# --- ON: nothing is set -> old values are used ---
- conditions:
- condition: template
value_template: "{{ trigger.event.data.command == 'on' }}"
- condition: template
value_template: "{{ (var_on_color_temp_kelvin | int) == 0 and (var_on_brightness_pct | int) == 0 }}"
sequence:
- service: light.turn_on
target:
entity_id: !input light
# --- OFF ---
- conditions:
- condition: template
value_template: "{{ trigger.event.data.command == 'off' }}"
sequence:
- service: light.turn_off
target:
entity_id: !input light
# --- Dim up ---
- 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
# --- Dim down ---
- 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
# --- Set color temp colder (short press) ---
- 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:
color_temp: "{{ 153 if (state_attr(var_light, 'color_temp') | int(370)) - 25 < 153 else (state_attr(var_light, 'color_temp') | int(370)) - 25 }}"
transition: 0.5
# --- Set color temp colder (long press) ---
- 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:
color_temp: "{{ 153 if (state_attr(var_light, 'color_temp') | int(370)) - 25 < 153 else (state_attr(var_light, 'color_temp') | int(370)) - 25 }}"
transition: 0.5
- delay:
milliseconds: 500
# --- Set color temp warmer (short press) ---
- 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:
color_temp: "{{ 500 if (state_attr(var_light, 'color_temp') | int(370)) + 25 > 500 else (state_attr(var_light, 'color_temp') | int(370)) + 25 }}"
transition: 0.5
# --- Set color temp warmer (long press) ---
- 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:
color_temp: "{{ 500 if (state_attr(var_light, 'color_temp') | int(370)) + 25 > 500 else (state_attr(var_light, 'color_temp') | int(370)) + 25 }}"
transition: 0.5
default: []