There’s a light model I own that appears to be 500 Kelvin below where it should be. I wanna setup an automation to bump the color up 500 Kelvin when the color temperature is changed.
To do that, I need a way to get a list of all devices that have that model name.
Then I can do some {{ trigger.SOMETHING }} to check what changed and bump only that light’s Kelvin value.
I read a thread on a similar topic. It’s close, but not exactly what I’m looking for:
set() (simplistically) builds a list without duplicates.
The list is made up from the device_id corresponding to every entity on the system, with null entries (device-less entities) removed — this gives you a list of all device IDs.
We then select those with a model attribute corresponding to MODEL_NAME.
Finally, we turn those device IDs into device names and return a list.
Not really. You’d be better off generating a list of entities within those devices and hard-coding that list into a state trigger with the attribute specified, although you’d need to make sure that the correction didn’t re-trigger the automation.
Alternatively, create Template Lights for each that handle the colour temperature adjustment.
It’s basically a virtual light where you build up what it does from an on/off, brightness, colour temp perspective.
You can get it to transform the colour temperature both going out to the real light and coming back from it. You’ll have to check how to read and write the temperature to your lights, which can vary by model, but something like:
[...all the other bits of config...]
temperature_template: "{{ state_attr('light.your_light', 'color_temp') - 500 }}"
set_temperature:
service: light.turn_on
target:
entity_id: light.your_light
data:
color_temp_kelvin: "{{ color_temp + 500 }}"
Is it possible to get a list of all lights of a certain type and create a template for them?
The config you sent has entity_id in it, but it would be a list of them. Is that possible using the template that gets a list of all those specific light models?
I still don’t get how to use this. I’ve read that Template Light page multiple times, and I don’t see how this is related. The Template Light page shows how to setup theater lights, but not how to say which lights are theater lights.
I’m also not sure if most fields are optional (passthrough), so I can focus on only adding 500 to the color temp.
Are you saying I add this to the bottom of configuration.yaml?
Absolutely not, no. The theatre light in the docs is just an example of its use. You’d need to set up all the bits of it you want / need to replicate all the functionality of your existing lights. The final example at the bottom of the doc might be more useful to you.
It’s not “passthrough by default”, you’d have to declare all if the get/set templates/actions; and if you want individual control over those lights you’d need a template light for each one.
It’s not a quick or easy solution, but would get you what you wanted.
This is also the first time I’ve used the “And if” section. I always use “Choose” and have to go through this complicated UI. It’d be neat if it split that in 2 and had a “true” and “false” side like how you visualize the pipelines.
Either way, that’s the code I had. I currently have this disabled as I do some testing. It appears this issue has been fixed which explains why the lights have looked so white recently.