Rgb_color as condition: trace and debugging unclear

Hi Guys,

i am currently struggling to get a simple condition in my automation working.
I currently want to achieve to get my lights from one color to another and switch between them. So for now I want to go from Red to Green to Blue (very basic)
Now i tried different approaches but lets make it simple and transit from Red → Green for now (which already does not work for me)


if:
  - condition: state
    entity_id: light.zha_grp_wohnzimmer
    attribute: rgb_color
    state: 255, 0, 0
then:
  - action: light.toggle
    metadata: {}
    data: {}
    target:
      entity_id: light.zha_grp_wohnzimmer

I already tried

state: 
  - 255
  - 0
  - 0

This is the trace when doing the above in visual editor:

but when I edit it in YAML, the trace is also negative:

This is the trace for every try:

I already looked into the forum but could not find anything related to it…do you guys have an Idea how to do this right? Thx in advance.

Your condition probably does not work because rgb_color actually seems to not be a list, it is a tuple. Thus you may be required to use a template condition in order to get a match.

- condition: template
  value_template: "{{ is_state_attr('light.zha_grp_wohnzimmer', 'rgb_color', (255, 0, 0)) }}"

Another possible issue is that your light does not actually have the exact rgb_color you think it has. For example, if I attempt to set one of my Philips Hue lights to [255, 0, 0] it will very briefly show that exact color in the attributes, but then for some reason it changes to [255, 43, 0]. No idea if this is because the light cannot reproduce that exact color and is algorithmically changed to what Philips/Signify deems the closest color it can do, or due to conversions to/from the light’s native XY color space.

1 Like

This did the trick! Thx alot.
I pasted the code in case someone has the same issue.
Funfact: changing to 0, 0, 255 changes the value to 11, 0, 255 for some reason in my case.
But to be honest: i just added a “or” operator and just accepted it. (in case someone reviews the code)


conditions: []
actions:
  - choose:
      - conditions:
          - condition: template
            value_template: >-
              {{ is_state_attr('light.zha_grp_wohnzimmer', 'rgb_color', (255, 0,
              0)) }}
            alias: If Red
        sequence:
          - action: light.turn_on
            metadata: {}
            data:
              rgb_color:
                - 0
                - 255
                - 0
              transition: 2
            target:
              entity_id: light.zha_grp_wohnzimmer
      - conditions:
          - condition: template
            value_template: >-
              {{ is_state_attr('light.zha_grp_wohnzimmer', 'rgb_color', (0, 255,
              0)) }}
            alias: If Green
        sequence:
          - if:
              - condition: template
                value_template: >-
                  {{ is_state_attr('light.zha_grp_wohnzimmer', 'rgb_color', (0,
                  255, 0)) }}
            then: []
          - action: light.turn_on
            metadata: {}
            data:
              rgb_color:
                - 0
                - 0
                - 255
              transition: 2
            target:
              entity_id: light.zha_grp_wohnzimmer
        alias: If Green
      - conditions:
          - condition: or
            conditions:
              - condition: template
                value_template: >-
                  {{ is_state_attr('light.zha_grp_wohnzimmer', 'rgb_color', (11,
                  0, 255)) }}
              - condition: template
                value_template: >-
                  {{ is_state_attr('light.zha_grp_wohnzimmer', 'rgb_color', (0,
                  0, 255)) }}
        sequence:
          - action: light.turn_on
            metadata: {}
            data:
              rgb_color:
                - 255
                - 0
                - 0
              transition: 2
            target:
              entity_id: light.zha_grp_wohnzimmer
        alias: If Blue
mode: single