Select devices and entities by label

Hello
Apologies if this is the wrong section in which to ask this question.

Is there a plan to allow devices and entities to be addressed/selected using newly introduced labels in things such as automations and scripts. For example, a UI display card that shows all entities labelled as “Battery” and an automation that turns of all devices labelled “Lights” and “Sockets” when leaving the house?

I think such a capability would be incredibly powerful and would simplify HASS tremendously.

Thank you in advance

This can already be done in automations and scripts. There are also some cards that already support it on the frontend as well (Auto Entities, etc).

1 Like

Incredible work. Thank you for pointing out the capabilities.

Keep up the good work lads.

1 Like

How does one select trigger devices with a specific label?

I would like to set the trigger part so that any device labelled “humidity” gets to trigger an automation if humidity levels reach a certain threshold? or for devices labelled “radiator” to trigger an event when they begin heating.

For something like that, you’d want to use a template as your trigger and use the label_entities() function to get all the entities with that label. I’m currently mobile at the moment, but this [crappy :rofl:] example should get you started. I don’t have any humidity labels, but the concept is pretty much the same.

{% set lights_on = false %}
{% for entity in label_entities("light") %}
  {% if is_state(entity, 'on') %}
    {% set lights_on = true %}
    {% break %}
  {% endif %}
{% endfor %}
{{ lights_on }}

However, that only applies to entities. You don’t really trigger off devices, just entities.

1 Like

@code-in-progress do you know if there is a plan to add the option to select triggering entities by label to the automations UI?

I’ve not seen anything that suggests triggering off a label.