Detect zone absence at two adjacent zones

After I found the expression ‘not_home‘ in the json file, I replaced the template like

condition: template
value_template: "{{ trigger.to_state.state == 'not_home' }}"

And, voila, this works!

There is still the problem, that the accuracy is bad, so that the trigger may fire later than 15 minutes after leaving home, but at least the automation is no longer triggered when changing between the two zones for now.

Thanks for that!

This topic led me to the device tracker documentation. There I found

A device tracker with GPS as a source can have any number of string states. The integration can return one of the following options:

  • Report GPS coordinates. The coordinates are then matched to a zone (which is set as state). If the home zone is matched, the state will be Home. If no zone was matched the state will be Not home.

Thus I came up with the idea to omit the first two triggers concerning leaving zone.home or zone.grundstuck and only check the trigger for being „not_home“? As I understand, „not_home“ would be true only, when I have left home and also not being in the garden. This is exactly my intention. I am a bit confused with this logic, sorry.

And, BTW, in the documentation, there is no state „away“ mentioned. Maybe this state is no longer valid? Could this be the reason, that checking for „away“ did not work, and only „not_home“ does the job?

No. not_home specifically means you are not in any known zone. If you are in the garden zone & the garden zone is not inside the home zone, then your zone should be marked as garden. Once you leave the garden zone you will be marked as not_home, provided you are not in any other zone.

Away is the “prettified” translation of not_home for the frontend. If you were using the automation UI to select it, then the underlying yaml will be translated to not_home. However, if you were using yaml directly, then typing in away will not work.

This is the same trigger in UI & yaml view.
UI:

Yaml:

from:
  - home
to:
  - not_home

Try this. You will probably need to switch to UI mode & replace garden with either Garten or grundstuck in the trigger, but otherwise it should work like you asked.

alias: Verandatür ist auf
description: ""
mode: single
triggers:
  - trigger: state
    entity_id:
      - device_tracker.sm_s908b
    from:
      - home
      - garden
    to:
      - not_home
conditions:
  - type: is_open
    condition: device
    device_id: 293f1bc7f630438d59833c67080458f0
    entity_id: 73c05cdd5c416385a0b2bd0c889de7d5
    domain: binary_sensor
    for:
      hours: 0
      minutes: 2
      seconds: 0
actions:
  - action: notify.mobile_app_phone
    metadata: {}
    data:
      message: Verandatür ist auf!

Keep in mind that you are also not_home when you just left work or some other zone.

Yes, that was my original idea, which I wanted to keep in mind, when considering the zone mode. What I did not get into my mind, was the device tracker system and the resulting states. What I was struggeling with, was, how to detect leaving both zones, but not changing between them. Considering the state is the clue for it. This way, it is much more stringent, but, for beginners like me, less obvious to look at these triggers.
Finally, I would have preferred, that „not_home“ is outside of zone.home, and „away“ is outside of any zone. But I can live with that.
Thanks for your support!