To tag and respond to a particular post, use the Reply button just below it and to the right, NOT the blue one at the bottom, which replies to the OP (no tag).
I think I understand what you are trying to do. If so, I do something similar. I recently acquired some Hue lights and integrated them into HA via ZHA. I started with buttons for each entity that let me control each individually. That just wasnāt cool enough. I then created a light group that included all of them, and created two scripts tied to buttons that would call a scene.apply
service to set the entire group (all lights) to either a warm tone or cool tone. All that was easy.
Then I created an automation to do a custom color loop where a color was chosen at random from a predefined set of colors for various color loop themes I created (e.g., cool, sunny, moody, etc.) defined by an input_select
. I can also control the transition and hold time of each color from the UI using input_numbers
. That all worked great, until I discovered that I may not want all lights to be in the color loop, or to have one stay white bright for reading while the rest looped, or some turned off during the loop.
I could turn individual lights off, but as soon as the loop started over with a new color, and set the GROUP to that color, ALL the lights in the group would turn on with the scene.apply
service call (just as they should).
So, I needed a way to filter out certain lights from both my warm/cool scene buttons and my color loop. What I decided to do was create an input_boolean
for each Hue light (I have 4 currently), connect them to buttons on my UI, and use the state of those to create my dynamic group.
Hereās the relevant code:
- service: group.set
data:
object_id: lamps_grp
entities: >
{% set result = states.light.hue_lr_lights_lgrp.attributes.entity_id -%}
{%- if is_state('input_boolean.hue_loop_include_go','off') -%}
{%- set result = result | reject("==",'light.hue_go') | list -%}
{%- endif %}
{%- if is_state('input_boolean.hue_loop_include_lr_table','off') -%}
{%- set result = result | reject("==",'light.hue_100w_lr_table') | list -%}
{%- endif %}
{%- if is_state('input_boolean.hue_loop_include_lr_floor','off') -%}
{%- set result = result | reject("==",'light.hue_75w_lr_floor') | list -%}
{%- endif %}
{%- if is_state('input_boolean.hue_loop_include_den_floor','off') -%}
{%- set result = result | reject("==",'light.hue_75w_den_floor') | list -%}
{%- endif -%}
{{ result }}
It works basically by removing entities from the predefined light group I defined in my config, based upon the input_booleans (there are probably 5 better, more effective ways to do this, but Iām still getting up to speed on templates). With my new group defined, I can do whatever I want with it (although reading color attributes from it is not possible like they are with a real light group). Note that I do also pre-define a regular group with these same entities, just so if something happens here, the regular group is still fully populated (so both a light group and a regular group with the same entities - I have a reason for this).
Here is what the Card in the UI looks like:
I really canāt see why anyone would use anything other than Home Assistant for home automation!