I am looking for guidance on how to create template lights that function like a “scene” in Home Assistant. The goal is to control a group of lights with parameters such as brightness, effects, and colors, and have the ability to turn them all off simultaneously.
Ideally, I would like to be able to easily replicate this code for multiple rooms and specific setups using variables to set the lights and get their states (if any) to determine the template light’s current status.
Here’s a non-functional example of what I have in mind:
Hi, I appreciate your response. I think template light is more suitable for my needs because it allows me to control individual lights with different settings, such as brightness, color, effect and so on. Light groups are more limited and can only turn a group of lights on and off, right?
My apologies, I was too simplistic in my explanation. You are right
My idea is to turn on a few different lights with their own specific settings, have their state as template (if any = true) and turn them off with a simple light.turn_off command.
Personally I wouldn’t. There are better controls for this. You are basically replicating scenes and scripts in a way that won’t be apparent to end users. And as such will become hard if not impossible to maintain.
Light groups for groups of lights that you want to control together. Scenes for sets of settings. Then you can use other controls to automate those.
Why. What happens when you want to change settings? Are you going to manually code each lamp setting into the template? (id strongly suggest not…). Who updates them?
In my setup I have an input select for each ‘room’ which is one of a bunch of states. (vacant, occupied, cleaning, locked, etc.) just image each as a program with a set of conditions to trigger it. When the conditions trigger a state, the automation then goes and looks up what scene is appropriate for the room at that time with the current condition…
Occupied midday with one person home is different than night with multiple people home…
Ive not built anything non-standard so anyone who knows HA can figure it out and more importantly my wife can edit the scenes without my help. The code is the code and the settings are the settings.
Thanks for taking the time to share your thoughts on this. I totally get your concerns about maintainability and ease of use for other users. But, as the only one managing the code in my setup, I’m not too worried about the complexity.
What I’m trying to do is create a template light that uses variables, so I can easily replicate it for different groups of lights. I need it to reflect the current state of all the selected lights, and I want to be able to control their individual turn-on properties (like brightness, effects, color, etc.) as a group, then turn them all off at once.
I’m aware of how to achieve this using light groups and scenes, but I’d like to create a more streamlined solution by using template lights with variables. This way, I can quickly set up as many template lights as needed by simply changing the variables.
I appreciate your input and the ideas you’ve shared, but I’m still hoping to find a solution that fits my specific needs. If you or anyone else in the Home Assistant community has any suggestions on how to accomplish this, I’d be super grateful for the help.
Thanks again for your response, and I look forward to any additional insights you might have.
What this does is on each home assistant start is it gets a list of all the lights in each area I defined in the for_each and appends them to a group called group.interior_lights.
I did this because I tinker a lot, adding and removing lights to areas pretty frequently, but don’t want to always have to rebuild my light groups.
This also uses the new is_hidden_entity feature to filter out hidden lights.