Auto-generated Groups of Sensors/Lights per room

Ideally the end result would be that when using an auto-generated group in an automation (say, for motion lighting) you’d never need to change the automation when adding/changing sensors in a room. Just add the devices to the correct room and the automations will use them automatically. An average humidity and average temp would be nice for another example.

I understand these things can be done quite easily with the use of helpers, but this would still be a useful feature. I imagine it would make blueprints even simpler for people to set up too.

Yes! This would be wonderful, and is something I super miss from set ups like Homekit and Google Home. They’ll do “grouping” like that automatically by room and it just works. Would be really nice to see something similar in hass

1 Like

Thank you for the vote and sharing your point of view!

Isn’t this what happens when you choose to make your light automation point to an area?

1 Like

Sure you can turn on/off all of the lights in an area, but I’m hoping for a similar feature with motion sensors or temp/humidity etc. Even currently the generic.thermostat config only supports one temp sensor, although I believe you can use a helper group still. On that note, Google assistant always tries to report a humidity reading from the thermostat, which is unavailable. Maybe a bug I should check

Hard to see how you could generalise things that much, if you did an automation based on average temp sensor in a room people would say “what about the weather, if it is going to get cold in an hour I want the heating to turn up” or “if it cold in the hallway it affects the kitchen” or … whatever.

Of course you can do temp sensors that average, or weighted average, other sensors.

You could also add those conditions to your automation. I’m not sure but i say this kindly, I think you’ve missed the idea.

Prior to version 0.104, Home Assistant automatically generated a few groups. However, the founder decided to remove them (in favor of individual users deciding which groups they need to generate on startup using an automation). The odds of reverting this design decision are low.

Is there a way to use an automation to create groups of sensors based on area assignment?

Yes, the following basic template reports all sensors in a specified area. It can be enhanced to select only sensors of a certain device_class or other criteria.

{{ area_entities('kitchen') | select('match', 'sensor') | list  }}

Here’s a more sophisticated example employed in an automation that creates a sensors group on startup.

- alias: 'Create Kitchen Power Sensors Group'
  trigger:
  - platform: homeassistant
    event: start
  - platform: event
    event_type: 'call_service'
    event_data:
      domain: 'group'
      service: 'reload'
  action:
  - service: group.set
    data:
      name: 'Kitchen Power Sensors'
      entities: >
        {{ area_entities('kitchen') | expand   
          | selectattr('attributes.device_class', 'defined')
          | selectattr('attributes.device_class', '==', 'power')
          | map(attribute='entity_id')
          | list }}
3 Likes

this. I would love to see them add areas to helpers though so you can expose a room’s or a floor’s lights to homekit for example