Geofence automation not working

I have a automation to turn off all the lights when both my wife and myself are out of the house. In my configuration.yaml file has this code and was rebooted. Tracked device in our person entity is our respective iphones.

proximity:
  home:
    devices:
      - person.spouse
      - person.my
    tolerance: 10

my automation

alias: Geofence - lights
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - proximity.home
    below: 0.1
    id: arriving-home
  - platform: numeric_state
    entity_id:
      - proximity.home
    id: leaving-home
    above: 0.1
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - leaving-home
          - condition: state
            entity_id: input_boolean.guest_mode
            state: "off"
          - condition: template
            value_template: >-
              {% set domain = 'light' %}

              {% set state = 'on' %}

              {% set count = states[domain] | selectattr('state','eq', state) |
              map(attribute='entity_id') | list | count > 0 %}

              {{ count }}
        sequence:
          - service: notify.mobile_app_my_iphone
            metadata: {}
            data:
              title: Leaving House
              message: >-
                {% set domain = 'light' %} {% set state = 'on' %}         {{
                states[domain] | selectattr('state','eq', state) |
                map(attribute='entity_id') | list | join(', ') }}
          - service: light.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: all
          - service: notify.mobile_app_my_iphone
            metadata: {}
            data:
              title: Leaving
              message: Lights turned off
      - conditions:
          - condition: trigger
            id:
              - arriving-home
          - condition: sun
            before: sunrise
            after: sunset
          - condition: state
            entity_id: input_boolean.guest_mode
            state: "off"
        sequence:
          - service: light.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: light.switch_familyroom
          - service: notify.mobile_app_my_iphone
            metadata: {}
            data:
              message: Family Room Light On
              title: Your Arriving Home
mode: single

When I test option 1/condition triggered by leaving-home it returns false when we are both out of the house. It should return true and run the remainder of the automation. Any thoughts on what’s wrong.

Can you post the debug trace from a time it triggered and did not run fully?

While making changes to see if I could get it working it must have restart the trace so earlier ones that would be helpful are now missing. I went into the developer tools and states and changed the proximity.home state to 4 and all the lights went out and I got my email notification. I’m guessing that means something is wrong with the proximity.home entity. The person entity for myself and my wife listed us as away in the person.me and person.wife but didn’t trigger the automation.

But were their last reported GPS coords outside the designated range and what was the value of proximity.home?

I believe when I checked, it was 4. Am I correct that the automation is fine as it works if I manual change the state of proximity.home but something is wrong with proximity.home?

Your triggers will only fire if the value of proximity.home crosses the 0.1 threshold. If it changes from 3 to 4, nothing will happen.

Can you paste the history chart for proximity.home? Like this (mine is set up in metres):

image

Here is the data from proximity.home from yesterday

Here is a test while we were both away from home yesterday.

By “test” do you mean you used the “Test” option from the condition’s menu? That will not work with trigger or template-based conditions.

Thanks that good to know.

Had the opportunity to test again. My tolerance was set to 50. I setup an entity on my dashboard to make it easy for my wife to check how far from my house we both were in the car. It kept reading 0 and then jumped to 2 eventually, at which time the lights turned off and I get a notification on my iphone.

Why did it not register when were 1 mile away?
Do I need to decrease the tolerance value? My automation is set to trigger the away state at 0.1 miles