I need to make my ikea styrbar remote change color on my ikea tradfri lightbulps, using a helper containing a dropdown helper, containing the color names.
Im using this blueprint: Malte/zha-ikea-four-button-remote-styrbar-for-lights-e2001-e2002.yaml
Bulps: TRADFRI bulb E27 CWS 806lm
Remote: Remote Control N2
sensor group: light.bedroom_lightbulps (containing both bulps)
Problem: When changing the bulp colors with input.select_next and input.select_previous - i changes the colors, but it seems a bit random, wich color is selected.
Now you just need to add the colors you want, you can find color names here:
or a shorter list here:
Don’t expect every color to be supported by your bulps.
Name the color list: Color List 1
alias: Soveværelse lys color cycle with Color Temperature Adjustment
description: ""
use_blueprint:
path: Malte/zha-ikea-four-button-remote-styrbar-for-lights-e2001-e2002.yaml
input:
remote: 129cd9955d663409e9870e58286a4f2c
light:
entity_id:
- light.sovevaerelse_paerer
button_left_short:
- service: input_select.select_option
data_template:
entity_id: input_select.color_list_1
option: >
{% set current_color = states('input_select.color_list_1') %} {% set
color_list = states.input_select.color_list_1.attributes.options %}
{% set max_index = color_list | length - 1 %} {% set current_index =
color_list.index(current_color) %} {{ color_list[current_index - 1]
if current_index > 0 else color_list[max_index] }}
- service: light.turn_on
data_template:
color_name: "{{ states('input_select.color_list_1') }}"
target:
entity_id: light.sovevaerelse_paerer
- service: input_text.set_value
data_template:
entity_id: input_text.bedroom_last_color_selected
value: "{{ states('input_select.color_list_1') }}"
- service: logbook.log
data_template:
name: Bedroom light color changed on left button press
message: Color changed to {{ states('input_select.color_list_1') }}
button_right_short:
- service: input_select.select_option
data_template:
entity_id: input_select.color_list_1
option: >
{% set current_color = states('input_select.color_list_1') %} {% set
color_list = states.input_select.color_list_1.attributes.options %}
{% set max_index = color_list | length - 1 %} {% set current_index =
color_list.index(current_color) %} {{ color_list[current_index + 1]
if current_index < max_index else color_list[0] }}
- service: light.turn_on
data_template:
color_name: "{{ states('input_select.color_list_1') }}"
target:
entity_id: light.sovevaerelse_paerer
- service: input_text.set_value
data_template:
entity_id: input_text.bedroom_last_color_selected
value: "{{ states('input_select.color_list_1') }}"
- service: logbook.log
data_template:
name: Bedroom light color changed on right button press
message: Color changed to {{ states('input_select.color_list_1') }}
button_left_long:
- repeat:
while:
- condition: template
value_template: >-
{{ state_attr('light.sovevaerelse_paerer', 'color_temp') |
default(454, true) | int > 250 }}
sequence:
- service: light.turn_on
data_template:
entity_id: light.sovevaerelse_paerer
color_temp: >
{% set current_temp = state_attr('light.sovevaerelse_paerer',
'color_temp') | default(454, true) | int %} {% set new_temp =
current_temp - 20 %} {{ [new_temp, 250] | max }}
- delay: 0.5
- service: logbook.log
data_template:
name: Bedroom light color temperature decreased on left long press
message: Color temperature decreased for light.sovevaerelse_paerer
button_right_long:
- repeat:
while:
- condition: template
value_template: >-
{{ state_attr('light.sovevaerelse_paerer', 'color_temp') |
default(250, true) | int < 454 }}
sequence:
- service: light.turn_on
data_template:
entity_id: light.sovevaerelse_paerer
color_temp: >
{% set current_temp = state_attr('light.sovevaerelse_paerer',
'color_temp') | default(250, true) | int %} {% set new_temp =
current_temp + 20 %} {{ [new_temp, 454] | min }}
- delay: 0.5
- service: logbook.log
data_template:
name: Bedroom light color temperature increased on right long press
message: Color temperature increased for light.sovevaerelse_paerer
If you look in the code you see i have 250 and 454 multiple times - These numbers are my min_mireds and max_mireds, so if your bulps have different numbers for min/max mireds, adjust in the code.
Last i want to say, i have no idea if this is the best way to doit or not… but it works
Hopefully this will save you some time, as i spent alot on figuring this out