Now that we have labels, is it possible to make an automation based on all the items within a label or room

I have been looking for a way to automatically create groups based on types for a bit now… Made a post circa 2021 to ask the same question:

forward 2024, we now have labels… Is it possible to make an automation with for example, when motion is detected turn off all the light entities in the room or turn off all the light entities that have the label inside for example.

Why do I find this useful. Every few months or so, I may add a motion sensor, or move it, and this may cause me to rename it. when I rename it, all the automations stop working… I then go in each files and rename them. Some automations/UI managed entities need to be changed in the UI and then the files managed entities then need to be changed separately…

Does someone have a good alernative to automatically created groups?

Yes. The light turn off action accepts labels as a target. You can test it in the Developer Tools → Actions menu:

We can’t dynamically create a group and gather state from a collection of entities in a label yet, however. (unless you know something I don’t, Tom?)

I wish though. I’d love to just tag the motion detector(s) in a room and get state for all devices that match the select statement…

No I don’t. You still have to manage the entity label manually.

1 Like

BTW, renaming an entity should not affect your automations. Changing the entity_id would.

1 Like

Correct I also would rename the entity_id as well. Although you’re giving me an idea, maybe my devices should have generic names like

motion_sensor_{brand}_{5 char hash} or something like that, and then rename when I need instead of having to move the entity name.

The way I use my setup, this would be for me the ultimate hack… select all entities of this label that go from on to off as a trigger… and then turn off the lights in that room!

This is similar to what I do - for example a motion detector is M05 Aqara - and then I put a “M05” sticker on it.

With Spook label management can be done programmatically.

Not sure if it’s quite what I’m looking for…spook will automatically add labels to entities from what it seems, i’m trying to create groups based on a label…

Ahh, no idea how to do that inside HA.
I use Node Red for that, sort of, because it is not a group in HA, but it can be acting like a group trough Node Red.