Use Light State as condition of automations

Hello,

I want to create automations that check the color of a smart bulb in my house before running an action.

The trouble im running into is the smart bulb does not report back the current RGB state. Is there a way to assume the state of the bulb based off of the last action for it in HA?

So far I have:

alias: Dryer Started
description: Dryer has started
trigger:
  - type: motion
    platform: device
    device_id: a3b2ea62106ddafcb8b812ecdddead0a
    entity_id: 244d37944640e7df0861b8bea3444296
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 30
condition:
  - condition: state
    entity_id: light.night_light_light
    state: 0, 251, 255
action:
  - metadata: {}
    data: {}
    target:
      entity_id: light.fireplace_bulb
    action: light.turn_off
  - data:
      entity_id: switch.adaptive_lighting_home
      lights:
        - light.night_light_light
      adapt_color: true
      adapt_brightness: true
      turn_on_lights: true
    action: adaptive_lighting.apply
mode: single

Save the RGB of the light in a trigger-based sensor.

It should, but not like this:

You are missing the color attribute.

condition:
  - condition: state
    entity_id: light.night_light_light
    attribute: rgb_color
    state: 
      - 0
      - 251
      - 255
1 Like

Thank you! That makes sense!

I implemented the attribute but the condition is still failing. This is the traces page for the failed condition:

Could you tell me why it is failing? Iā€™m still new to home assistant and learning a lot!

Do it as a Template Condition:

condition:
  - condition: template
    value_template: |
      {{ is_state_attr('light.night_light_light', 'rgb_color', (0,251,255)) }}
1 Like

Thank you! That did the trick!