Everyone asleep or away trigger

I’m trying to trigger an automation when everyone is either away or asleep (i.e. everyone who’s home is asleep). I’m using the focus sensor from the iOS app to detect sleep (not perfect, I know). Is there an easy way to configure something like that besides configuring a template away_or_asleep binary sensor for every person in the household and grouping them?

Any ideas?

i went down the bed sensor way

not the sleep logic but know where you are in or out of bed

Thanks, but I guess my question wasn’t clear.
For each person, I have a sensor to say whether they are home, and one to say whether they’re asleep. I’m looking for a way to combine them into a single everyone-who’s-home-is-asleep sensor.

I realize this is old, but here’s how I do it…

I have a group for all of my person entities and a group for all of my sleeping entities.
Each person’s sleep sensor can only be on if they’re home. Then I compare the number of people home to the number of people sleeping. If they’re equal, everyone is sleeping.

binary_sensor template:

  everyone_is_sleeping:
    unique_id: everyone_is_sleeping
    delay_off: 
      minutes: 3
    value_template: >
      {{ expand('group.family') | selectattr('state','eq','home') | list | count == 
          expand('group.someone_is_sleeping') | selectattr('state','eq','on') | list | count }}
1 Like

Thanks! The entities in group.someone_is_sleeping are templates that AND whether they’re home with whether they’re sleeping?
It might actually be easier to do a template away_or_asleep per person and then group them.