Is it possible to modify or trigger lights “favorite colors” via YAML or the UI ?
I’ve searched documentation and forums but couldn’t find much other than a feature request to create favorite profiles
Is it possible to modify or trigger lights “favorite colors” via YAML or the UI ?
I’ve searched documentation and forums but couldn’t find much other than a feature request to create favorite profiles
Yes…
Why it is not ?
All I can find in the forum is this same question… Moreover it is very tricky to make a permutation between favorite light colors if you do an automation, because when I send the command [255, 0, 0] to my Philipps Hue, the light “decides” randomly a color close to this one…
So, I finally succeeded to make an automation that anyone can use until there is something integrated:
- conditions:
- condition: trigger
id:
- lightChangeColor
sequence:
- variables:
next_color: >
{% set colors = [ [255, 43, 0], [192, 239, 255], [255, 165, 0],
[144, 238, 144], [138, 43, 226] ] %}
{% set current_color=state_attr('light.bureau', 'rgb_color') %}
{% set tolerance = 50 %}
{% set ns = namespace(next_color = colors[0]) %}
{% set color_match = colors[0] %}
{% for color in colors %}
{% if ((color[0] - current_color[0]) | abs < tolerance) and ((color[1] - current_color[1]) | abs < tolerance) and ((color[2] - current_color[2]) | abs < tolerance) %}
{% set color_match = color %}
{% set next_index = (colors.index(color_match) + 1) % colors | length %}
{% set ns.next_color = colors[next_index] %}
{% endif %}
{% endfor %}
{{ ns.next_color }}
- action: light.turn_on
data:
rgb_color: |
{{ next_color }}
target:
entity_id: light.bureau
PS: it is much more easier to make a permutation between effects because the effect list is already defined, this would be cool to have the same for colors
At first glance, it looks like your automation will cycle the RGB values you have manually defined; but it won’t affect the “favorite colors”? just a workaround right?
exactly, just a workaround, my fav colors are defined manually.
But the tricky part was to get back the color status of the light in order to define correctly the next color, because when you set a color to your lightbulb, this one choose another color close enough, but never the exact hexa code of the color you have in the list.