Not_home Automation Not Triggering Script

I am having an issue getting a script to run when both my wife and I leave the house. The “goodbye” script works when I call it manually or from alexa on the way out the door, but it is not being triggered by the zone change. My automations for zone changes coming home work fine. Is there something wrong in my automation or should I be looking elsewhere? I just updated to the latest version this morning, then started trying to figure this out and I am not getting any errors. My wife isn’t home right now and I am setting my state manually and nothing is triggering, nor does my history show that this script was triggered at anytime that I didn’t do it manually.

#Lock doors and turn out lights when we leave
- alias: 'Goodbye When Not Home'
  initial_state: true
  trigger:
    - platform: zone
      entity_id: device_tracker.bret
      zone: zone.home
      event: leave
    - platform: zone
      entity_id: device_tracker.jess
      zone: zone.home
      event: leave
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: device_tracker.bret
        state: 'not_home'
      - condition: state
        entity_id: device_tracker.jess
        state: 'not_home'
  action:
    service: script.turn_on
    entity_id: script.goodbye

what happens when you take out the conditions?

I ask because you might have other zones…and the condition isn’t evaluated to being ‘true’.

triggering manually skips the conditions altogether, so that would be expected.

btw you can write:

  condition:
    - condition: state
      entity_id: device_tracker.bret
      state: 'not_home'
    - condition: state
      entity_id: device_tracker.jess
      state: 'not_home'

or even better, (at least, checkable in the dev-template)

  condition:
    - condition: template
      value_template: >
        {{is_state('device_tracker.bret','not_home') and 
          is_state('device_tracker.jess','not_home') }}

Hi,

you can use the simple way :slight_smile:

device_tracker:
  - platform: ping
    interval_seconds: 60
    consider_home: 180
    hosts:
      YurPhoneName: 192.168.x.x
      YurWifePhoneName : 192.168.x.x

when no more connect to wifi,

the trigger will be on.

I stop using “device_tracker”, it will drop down my battery very fast and its a brand new phone…

You could also use the “group.presence” detection method. If any person (or device) in the group is at home, the state will be “home”. If nobody is home, the state of the group changes to “not_home”

I think the problem I had was that I have my home radius then I have a larger radius around that for unlocking the doors when I get home and an even larger one for turning the lights on. My all devices group for some reason was unknown so I created a group and changed my automation to just trigger when that group changes to not_home. Seems to work perfect now.

I use automations and zone triggers that are way out of the reach of my wifi. I do see extra battery draw on my phone, but most days its not an issue for me. I have my gps logger update about every 20 seconds. A buddy of mine used proximity and has his update ever 2 minutes. I haven’t had the time to play with method yet.