Wildcard operators for groups

My pull request for allowing the change of existing groups has been approved. Once we have a release that implements that, I’ll post here a custom component that’ll allow wildcard grouping. If it looks like something that is useful to others, we can see about getting it implemented as part of HA.

Stay tuned.

Ok, once you have 0.61 installed, try this:

See the notes in the gist. Also, I don’t use any of the “reload” functions on the configuration page. Those might break it as well.

1 Like

Thanks,
it looks like it works but it doesn’t include template sensors.
And I confirm the group_reload breaks it.

Any idea if this could be made more generic ? it would be very useful to have wildcard support for every components that uses entities lists. For example in the recorder component, exclude/include entities.

I only tested with things created after the initial load. Emby stuff specifically. The template sensors might be created before it hooks. Not sure.

It was quick and dirty.

your component does try to add the template sensor to the group, I can see the “Adding %s to group %s” message. So it’s probably an issue with the new feature that has just been commited into HA.

Would anybody want to reproduce this issue ? :slight_smile:

I not certain why it wouldn’t add a template sensor to the group. I would have try to duplicate it to see.
For group reloading, I’m not sure the best way to tackle that. There isn’t an event that tells me when a single group is created or all of them are reloaded.

It would be best if we could just put this functionality into the group component. Too lazy to read the thread/threads but I thought there was pushback against that, so that is why I did this.

Maybe we can either get the devs to allow us to pull this into group functionality, or maybe they’ll at least let us/me add events for when a group is created and when they are all created. Then we could hook that in this component.

creating, changing and reloading the groups through rest api will probably give you all options you need.
at least i can create, change and reload all groups from inside appdaemon.
thats why i created an app that uses wildcards.

Yes, but I’m trying to react to something else creating or reloading groups. I need HA to bubble events. Maybe it is, and I’m just not paying close enough attention. I’ll poke at it and see what happens.

reloading is done by a service call so it creates an event.

I see that EVENT_STATE_CHANGED is called for the group. I’ll see if I can use that to work around the group.reload issue @lolorc mentioned.

Edit: I updated my globber in an attempt to detect group creation (which happens with a reload). Overall, this solution feels fragile and dirty.

1 Like

Already using the group globber of @rhodges. It’s working fine!
The only thing I’m missing is a way to order the entities on the group. Since the group is created in advance, I was expecting that any entities created with it would stay on top. But they appear among the other entities added with the group_globber component.

is there any rhyme or reason as to how it ordered the entities in the group? Seems to be random with each reboot.

Also i’m having an issue when adding templates as the first entity in the group. I had to add a hidden sensor as the first in the list in order for the rest of the template sensors to show up.

If I try with a group which already is created with group: nothing is generated. If I delete that group everything seems to pop up ok. Not sure why…

****** Edit it also looks like using the group_globber in more then one package breaks it :frowning: I was hoping to auto generate a handful of sensor cards which are each in their own package.

1 Like

Did this break in 0.80?
https://gist.github.com/randellhodges/96a0cd9bafa03fb90ada49040d65f1b0

I am uncertain. I stopped using this a while back and now I’m playing around with monster_card and lovelace.

I’m looking at implementing this fairly soon :grin:

2 Likes

I don’t want to nag, I know everyone has their own lives and jobs, and free time is limited, but are you still working on this? Is “farly soon” going to happen soon? This was two years ago… :grinning:

i dont think this works anymore, because of a lot of changes in HA.

Stopped contributing to HA some time back. I think however there might be something that does this.

this feature would be so great to use.

This would be a REALLY useful feature. I have just come across the need for it as I am creating a group with around 50 entities in it so want to do something like this:

group:
  switches:
    name: network_switches
    all: true
    entities:
      - binary_sensor.*_switch

3 Likes