Hi. I was frustrated that I couldn’t make a seemingly simple config to control IKEA bulbs with IKEA Styrbar controller.
Binding doesn’t work for new models, and the “Awesome” HA Blueprints do not work for me at all (and many others), and the complexity of it is immense when I tried to debug it.
So here I have a simple automation (no, it’s not even a blueprint, suit yourself) that implements what I wanted, with the behavior of IKEA lights and controllers (3 scenes: warm, normal, cold).
You need to manually create a scene helper of type input number with range from 0 to 1.
alias: Children/Juli ceiling light controller
description: ""
trigger:
- platform: state
entity_id:
- sensor.potatotheta_action
attribute: action
to:
- "on"
- "off"
- arrow_left_click
- arrow_right_click
- brightness_move_down
- brightness_move_up
- brightness_stop
condition: []
action:
- variables:
command: "{{ trigger.to_state.state }}"
low_brightness: 10
default_brightness: 20
high_brightness: 100
step_pct: 10
speed: 300
light: light.childrenceilinglight
scene: "{{ states('input_number.children_scene') | int }}"
warm: 2202
day: 3000
cold: 4000
- choose:
- conditions:
- condition: template
value_template: "{{ command == 'on' }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ light }}"
data:
brightness_pct: "{{ default_brightness }}"
- conditions:
- condition: template
value_template: "{{ command == 'off' }}"
sequence:
- service: light.turn_off
target:
entity_id: "{{ light }}"
- conditions:
- condition: template
value_template: "{{ command == 'brightness_move_up' }}"
sequence:
- repeat:
while: []
sequence:
- service: light.turn_on
target:
entity_id: "{{ light }}"
data:
brightness_step_pct: "{{ step_pct | int }}"
transition: "{{ (speed / 1000) | float }}"
- delay:
milliseconds: "{{ speed }}"
- conditions:
- condition: template
value_template: "{{ command == 'brightness_move_down' }}"
sequence:
- repeat:
while: []
sequence:
- service: light.turn_on
target:
entity_id: "{{ light }}"
data:
brightness_step_pct: >
{% set current_brightness = state_attr(light,
'brightness') | default(0) | int %} {% set new_brightness
= current_brightness - (step_pct * 2.55) %} {% if
new_brightness < (low_brightness * 2.55) %}
{{ -((current_brightness - (low_brightness * 2.55)) / 2.55) | int }}
{% else %}
{{ -step_pct | int }}
{% endif %}
transition: "{{ (speed / 1000) | float }}"
- delay:
milliseconds: "{{ speed }}"
- conditions:
- condition: template
value_template: "{{ command == 'arrow_right_click' }}"
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{ scene < 2 }}"
sequence:
- service: input_number.set_value
target:
entity_id: input_number.children_scene
data:
value: "{{ scene + 1 }}"
- service: light.turn_on
target:
entity_id: "{{ light }}"
data:
kelvin: |
{% if scene == 0 %}
{{ day }}
{% else %}
{{ cold }}
{% endif %}
- conditions:
- condition: template
value_template: "{{ command == 'arrow_left_click' }}"
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{ scene > 0 }}"
sequence:
- service: input_number.set_value
target:
entity_id: input_number.children_scene
data:
value: "{{ scene - 1 }}"
- service: light.turn_on
target:
entity_id: "{{ light }}"
data:
kelvin: |
{% if scene == 2 %}
{{ day }}
{% else %}
{{ warm }}
{% endif %}
default: []
mode: restart