How do you match an array in an automation trigger

I’m trying to trigger based on the RGB value of a color change event. I can look at the RGB values of the entity for the light however the string input on the automation doesn’t match the array value. Is there a standard? eg the following trigger doesn’t match the proceeding event. I’ve tried making it an array with no success. I’m not sure where in the docs to look.

Thanks

platform: state
entity_id:
  - light.moon_light
attribute: rgb_color
to: 255,4,10
for:
  hours: 0
  minutes: 5
  seconds: 0
event_type: state_changed
data:
  entity_id: light.moon_light
  old_state:
    entity_id: light.moon_light
    state: "off"
    attributes:
      min_color_temp_kelvin: 2202
      max_color_temp_kelvin: 4000
      min_mireds: 250
      max_mireds: 454
      effect_list:
        - colorloop
      supported_color_modes:
        - color_temp
        - xy
      effect: null
      color_mode: null
      brightness: null
      color_temp_kelvin: null
      color_temp: null
      hs_color: null
      rgb_color: null
      xy_color: null
      off_with_transition: false
      off_brightness: 254
      friendly_name: Moon Light
      supported_features: 44
    last_changed: "2024-05-15T01:04:10.349760+00:00"
    last_reported: "2024-05-15T01:05:33.341108+00:00"
    last_updated: "2024-05-15T01:04:10.349760+00:00"
    context:
      id: 01HXWWEDY8G5Y3M3W8YTXMQQTG
      parent_id: 01HXWWDGA4QKTTJXVCS6AMK9DN
      user_id: null
  new_state:
    entity_id: light.moon_light
    state: "on"
    attributes:
      min_color_temp_kelvin: 2202
      max_color_temp_kelvin: 4000
      min_mireds: 250
      max_mireds: 454
      effect_list:
        - colorloop
      supported_color_modes:
        - color_temp
        - xy
      effect: null
      color_mode: xy
      brightness: 254
      color_temp_kelvin: null
      color_temp: null
      hs_color:
        - 358.566
        - 98.431
      rgb_color:
        - 255
        - 4
        - 10
      xy_color:
        - 0.699
        - 0.299
      off_with_transition: false
      off_brightness: null
      friendly_name: Moon Light
      supported_features: 44
    last_changed: "2024-05-15T01:06:19.177785+00:00"
    last_reported: "2024-05-15T01:06:19.177785+00:00"
    last_updated: "2024-05-15T01:06:19.177785+00:00"
    context:
      id: 01HXWWJBKXD1RF36XGGBH27YSR
      parent_id: 01HXWWJBKX6CMNAAYBDS1SKET5
      user_id: null
origin: LOCAL
time_fired: "2024-05-15T01:06:19.177785+00:00"
context:
  id: 01HXWWJBKXD1RF36XGGBH27YSR
  parent_id: 01HXWWJBKX6CMNAAYBDS1SKET5
  user_id: null
platform: state
entity_id:
  - light.moon_light
attribute: rgb_color
to: [255,4,10]
for:
  hours: 0
  minutes: 5
  seconds: 0

i’m not positive if it’s 100% true always, but at least a good starting place is that if you want to trigger on an attribute, use the format you’d use to set that attribute.

so with that in mind, use this doc:

1 Like

If that doesn’t work, you could fall back to a template trigger:

  - platform: template
    value_template: "{{ state_attr('light.moon_light', 'rgb_color') == [255, 4, 10] }}"
1 Like

I never did get template triggers, or array matching to work out, but I did figure out how to solve my problem.

I was setting the color with a scene, and you can’t trigger on scenes. However you can have the scene set a helper to a value. So I created a input_text helper and had each scene set it’s name to the input_text value. Then I triggered on the helper.