Change Lights Back to Normal Settings (rgb_color)

Hey Everyone,

I’m trying to create an automation to set my hue lights back to original settings in the event the colors were changed at some point based on the rgb_color attribute. Below is the code I’m using and it passes but doesn’t seem to be firing. I’m sure I am overlooking something but cant wrap my head around it.

alias: Turn Lights to Normal
trigger:
  platform: state
  entity_id: light.all_hue_lights
  to: 'on'
condition:
  condition: template
  value_template: "{{ states.light.all_hue_lights.attributes.rgb_color != '(255,200,118)' }}"
action:
  - delay: 00:00:10
  - service: light.turn_on
    entity_id: light.all_hue_lights
    data:
      brightness: 254
      rgb_color: [255,200,118]

Thanks for any help you can provide.

Can you try it with a specific light, instead of ‘all_hue_lights’?

i see two concerns:

  • since you use the ‘to: on’ as the trigger, this will only fire when the light turns on. (that might be what you want, so that if it turns on after it was a different colour before it changes back)
  • because the action is for ‘all_hue_lights’ i think that it will turn on all lights, and not just the one that had a different colour. in other words if one had a different colour you now turn on every single light in your house, which is likely not what you want.

if it works with the individual lights you might have to repeat your automation X times for each one - unless someone more experienced than me has some other tips.

Have you tried making a group called group.all_hue_lights?

I have a similar set up for a bunch of Osram GU10 bulbs in my kitchen, making a group for them made it work.

I removed the to: ‘on’ and that did it with a single light. Thanks!

2 Likes

great! :ok_hand:

I do have group.all_lights. I don’t see rgb_color as an attribute via the front end. Would that still work?

EDIT: all_lights are the lights I want (3 hue lights)

1 Like

If you create a group like this, you will end up with the entity group.kitchen

kitchen:
  name: Kitchen
  entities:
  - light.p16tw_01
  - light.p16tw_02
  - light.p16tw_03
  - light.p16tw_04

It would be better to use a specific group for now as you may add future lights you add to your system. Every light you add will most likely find it’s way into group.all_lights, so making individual groups will future-proof things a little.