While setting labels to my HA instance I started thinking this.
In many cases entities belonging to device would be tagged with same labels as device it self. Yet there doesn’t seem to be option to have entities inherit labels.
I agree. I tried to build template sensors using 2 different approaches:
Tagging the devices: I have multiple door/window sensors and tagged them. Now I’m trying to set up a template sensor counting the number of open sensors. With a template, I can get the number of devices:
label_devices('Sicherheitsalarm')
| expand
| list
}}
However, I cannot filter this list of devices to get their entities with device_class = “door”. I tried | selectattr('device_class', '==', 'door') but since the devices do not have attributes the filter does not work…
Tagging the entities: Here I tagged the entities directly. I am counting battery entities that are below 50% power:
However; I’d prefer to just tag the devices instead of the entities for better visibility. I usually work with the “devices” view in HA, if you tag only the entities, you have no visibility here which are counted and which are not.
I’ve found that using a combination of temapltes and the “Spook” integration the following will easily popupalte the entities. I can understand why inheritance is not standard, this allows for chices at a level down the hierarchy.