Hello, just set up my first home assistant hub and trying to script my first automation to start learning the syntax.
My ideal end goal is to have an automation that goes through each light in my office at sunset, if the light is on and has a temperature above 4000K it would then shift it to 2700/3000K.
So far, playing with one light only, I have not got it to read the current color, and only got it to turn off or set a scene. I would be okay if I can’t read the current color, but do want to keep it from turning on every light if possible, just shifting the ones that are on.
Any tips or pointers would be great, once I understand how these commands work I feel I will be off to the races. Thank you for any help/guidance!
The following example assumes all the lights in your office have been assigned to an area named Office. If you haven’t done that then let me know and I can show you how to modify the automation accordingly.
The variable named lights creates a list of entity_ids for all lights in the Office area that are on and have a color temperature greater than or equal to 4000. If there are none then the automation exits. If there’s one or more, the automation sets their color temperature to 2700.
This is working great! Though if any of my lights are set to a RGB value it seems to fail for all so I had to add a “| selectattr('attributes.color_temp_kelvin', '!=', None)” and now it all seems happy.