I’ve spent days on this, searching both the web and this forum for answers. If anyone could point me in the right direction it would mean a lot to me!
I am trying to create “dynamic” groups, meaning that lights or other entities are added automatically to groups based on certain filters. I do this because adding new entities/devices manually every time I acquire a new smart device to my household seems inefficient (to put it mildly).
For this first example I am trying to create an “inside” light group, hence why I am filtering out the outside lights as you will see below. The code runs perfectly fine in the Developer Template tool which makes it even more strange. I am guessing it has something to do with what kind of values are accepted after entities. I’ve read the documentation but can’t see why this won’t work. Am I going about this the wrong way?
This is what I currently have in my lights configuration file, lights.yaml:
light:
- platform: group
name: Home Lights
entities: >
{{ states.light | map(attribute='entity_id') | reject('search', '.*outside*.') | join(',') }}
I’ve also tried the following in my groups configuration file, groups.yaml, with the same error:
String does not match the pattern of "^(?!.+__)(?!_)[\da-z_]+(?<!_)\.(?!_)[\da-z_]+(?<!_)\s?(?:,\s?(?!.+__)(?!_)[\da-z_]+(?<!_)\.(?!_)[\da-z_]+(?<!_))*$".
Please don’t hesitate to ask me if further information is required!
Basically, take that template and feed it to the group set service call and use homeasssistant start as your trigger. You don’t even need to create the group beforehand in yaml.
Thank you so much for your quick help! Did not know this. I thought I had read most that is to read about templating but obviously I missed something. Oh well, thanks for pointing it out!
Sounds like a great work-around, thank you! Does it have to trigger on home assistant starting up? It would be nice if it could trigger more often, perhaps on a set time interval? I will definitely look into this.
Hi,
binging this old stuff on top cause I found no rookie compatible solution
so I want to ask if the dynamic group is already succefull implemented
I personal have the Idea … to combine at least all “temperature” entities in one group
and I dont care if there is a new one … its automaticly entered
and in an happy day scenario I can see the date when or its colored if new
Is such a dynamic group and a related dynamic dashboard card not a good Idea for a HA basic functionality ( update sequence choseable by restart / time (daily 23:55 ) / press buton )
remove from list manually or after 30 days