Using Home.Zone to trigger when nobody home?

Trying to setup my first automation. Turn Vacuum on when nobody home.

Was hoping I could do everything via the UI over diving into the YAML.
With the new UI for groups, but not having person groups yet, some reading and inspection of the zone.home seems to give reliable answers when both myself and my partner leave the house. (Using WiFi presence detection).

However, the below fails to trigger when I simulate both of us not being at home (turn both wifi off on our phones), but I can see that the home state is reporting 0 person home.

What do I need to adjust here?

alias: Stealth Vacuum
description: Vacuum when no-one at home
trigger:
  - platform: state
    entity_id:
      - zone.home
    attribute: persons
    to: "0"
    for:
      hours: 0
      minutes: 1
      seconds: 0
condition: []
action:
  - device_id: 5dbc82ccdcbeed1345bdbc0a22187ef6
    domain: vacuum
    entity_id: vacuum.roborock_vacuum_s6
    type: clean
mode: single

Will add conditions later for time of day.

The “persons” attribute on “zone.home” is an array, so if nobody is home it would be an empty array, not “0”. However, the state is a count of the number of persons, so I would think it should work if you just remove the “attribute: persons” line to make it work off the state instead of an attribute.

hey that worked! And it now makes sense. Thanks for that

just be careful about phone power saving that automatically turns off the wifi if you let it sit :stuck_out_tongue:

1 Like

If we both leave at the beginning of the day, it will start after one minute.
From my testing, I believe that it would not go into a loop of continous running because we are not home, right? The trigger needs to be someone coming home and then leaving again (so home.state is 0).

Saw a few other posts about using booleans or checking the roborock.vacuum.s6 Last clean end to make sure it only runs once a day. I am fine with the current logic as long as its only triggered when the house goes into a state of 0 and then stops.