How to tell not_home when in a zone?

So I’m trying to setup an automation that has a condition of myself and my wife not at home.
I have a binary sensor setup:

- platform: template
    sensors:
      everybody_home:
        value_template: >-
          {{ is_state('person.dad', 'home') and
             is_state('person.mom', 'home') }}

and this is kinda backwards, but if I set this up to say nobody home and try to use not_home then when I or my wife is in a zone other than home it doesn’t count as not_home. Which makes sense…I just don’t know how to compensate for it.

Any tips on how to make a simple sensor than can tell we are not home even if we are in a zone other than home?

Thanks

value_template: “{{ not (is_state(‘person.dad’, ‘home’) or is_state(‘person.mom’, ‘home’)) }}”

Not sure why you are using whitespace removal characters, they aren’t needed

Close. That would be “somebody isn’t home”, not “nobody is home”. :smile:

Try:

- platform: template
    sensors:
      nobody_home:
        value_template: >
          {{ not is_state('person.dad', 'home') and
             not is_state('person.mom', 'home') }}

EDIT: D’oh! WHAT AM I TALKING ABOUT!!! You were right! Never mind!!! :sweat_smile:

Did you have a Homer moment ?
:rofl:

(my post was edited, take a look at my first pass :rofl:, oh it doesn’t show, lucky me )

1 Like

When I copied to paste it here it doubled all the lines so I quickly tried to make it more readable for the forum. Maybe that is why the whitespace removal characters are there.

This is where I really wish I knew more about programming!
I’ll try this out today.

Thanks for the help.

Eh ?
I’m talking about the “-” in your : -

Some people seem to pepper their templates with them, and largely they aren’t needed.

Well I honestly have no clue! I wish I did!
I didn’t even know that was what that was…I assumed since it got strange when I copied and pasted that it came from that. If I copy and paste from the text on screen in the VSCode addon it shows up with double spacing after being pasted. I just tried it again, but didn’t see the “-” …I must have bumped the key or something. Thanks for the info though. I like being able to learn here even if it is only tidbits at a time.
Programming just isn’t my thing and I have so little time to devote to this I have to ask for help with simple things like this.

Putting the {{not is_state worked great.

All I can say is thank you to you guys for helping!