WTH, Entity Lists for reuse (old world groups)

I have a couple of situations where I want to use something like groups to list entities so I can references them in multiple places. The issue with groups for this is that they essentially create a new entity based on the group type with a derived state. ie. a sensor group creates a new sensor with the state derived from the group members. However in doing so you lose details of the members (such as last updated date, friendly name etc.). This makes templating far more difficult.

Eg. I have a list of temperature sensors that drive my heating so are pretty critical. I want to be able to send a notification if any of these hasn’t updated in the last two hours. I also want to use that same list of sensors in a few other places. If I create a sensor group, that creates a new sensor combining all the values in some way I determine but then I lose the last updated date of each sensor.

Another related case is where I have TRVs and I need to determine whether any of these are calling for heat. You can’t create a climate group but I want to be able to use the list of valves in a few different places and only have one place to update them,

Currently I have old style groups defined in groups.yaml

trvs:
  entities:
    - climate.bedroom_thermostat
    - climate.lounge_thermostat
    - climate.study_thermostat

which allows me to create groups and allows me to do

{{ expand('group.trvs') | selectattr('attributes.hvac_action', 'eq', 'heating') | list | count}}

Other examples are things like being able to create a list of critical battery devices to display on a dashboard. As these can be spread across multiple integrations it is difficult to achieve any other way. In one place you can easily just list out the entities you want but as soon as the same list is needed in two places it gets difficult to keep them in sync.

The functionality is already there in the old world groups but it would be nice to have a better way of creating groups purely for listing and reuse rather than trying to generate a combined state (perhaps the state of these lists would just be the number of members)

This is what labels are for. It creates a ‘group’ without the group.

i.e. add label climates to your climate devices and your template is

{{ label_entities('climate') | select('is_state_attr', 'hvac_action', 'heating') | list | count }}
1 Like

I had missed the label functions. I had just used them in the front end for filtering and didn’t see I could swap them.

That is one of the last bits of yaml config I had left so now gone :smiley: