Is it possible to modify or trigger lights "favorite colors" via YAML or the UI?

Yes… :see_no_evil:
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 :wink:

2 Likes