Condition for Everyone Home

Hello Folks,

I have an automation to turn off the exterior lights at 10pm if me and my wife are home. Here’s a snippet from it:

automation 2:
  alias: Exterior lights Off at 10pm
  hide_entity: True
    platform: time
    after: '22:00:00'
    condition: state
    entity_id: group.all_devices
    state: home

I only want this to fire if both me and my wife are home. As you may have noticed, this will fire if even just one of us is home, because then the state of the group will be home.

Is there any way to either change the group to only have the state of “home” if all devices are home, or more cleanly write a condition for all devices being home?

Naturally I could simply do this with an “and” condition for both me and my wife, but then in a decade I would have to modify the automation when I have kids. :laughing:

Maybe this? Then you can use the state to set an input_boolean that indicates when everybody is home, and use that to drive those automations?

1 Like

You can list multiple conditions, one being that your device is home and the other being hers, and modify accordingly as the family grows.:grin:

Ah yes, that could do it! Instead of the input boolean, I suspect that I could have the lights off command inside of an if statement that checks if the number of people = total number of people. In looking at that script, in this case I’ll probably just use an “and” condition and no script, but, it might come in handy for another automation!

@billmi yes, but depending on how many children I have that could get cumbersome. :stuck_out_tongue:

Using an input boolean means you’ve only got one automation to update when the number goes to 3, or 4, or… That’ll be particularly useful as you write more automations that use presence.

1 Like

i made a group “devices” with my phone and my wfes phone… now if jjust one of us leaves… group is not_home. if both are there group becomes home


Interesting! I’m surprised that your custom group behaves differently than the ready made all devices group. Thanks!

All devices also includes other devices like TV or whatever u detect by device trackers .that’s why

I don’t have any others! I did at one time, but then I disabled auto discovery and cleaned up my known devices.