I’m trying to figure out how to create a sensor group that automatically includes all sensors in a particular area, so that I can move sensors between rooms without having to rewrite my automations.
I’m trying to do something along these lines in my sensors.yaml, but am not sure I’ve got it right:
- platform: group
name: "Bedroom Temperature (Max)"
type: max
entities: >
{{ area_entities('bedroom') | expand
| selectattr('attributes.device_class', 'defined')
| selectattr('attributes.device_class', '==', 'temperature')
| map(attribute='entity_id')
| list }}
It is also possible to use an automation to populate a legacy style group. These ad hoc groups do not survive restart or reboot, so you need to set up the automation to fire on restart.