Problem with location based automation

looking for some assistance in setting up an automation, and where i went wrong.

it’s a location based automation to turn on a light when someone enters the “home” zone. they have the iOS app installed, and i can see their location on the map. in their person profile their device tracker for the iphone is applied to their profile.

when they entered the zone nothing happened, so i assume i have something set up a little wrong.

alias: Hall Light When Approaching Home
description: ""
triggers:
  - trigger: zone
    entity_id: person.sarah_jane
    zone: zone.home
    event: enter
  - trigger: zone
    entity_id: person.simon
    zone: zone.home
    event: enter
conditions: []
actions:
  - action: light.turn_on
    metadata: {}
    data: {}
    target:
      device_id: b7c59356ca04deaccbe01ee607b28734
mode: single

as a test i went into developer tools > states > set state on that automation and the light came on, so i assume the issue is with the location based trigger?

Are sure your zone names begin with zone.?

What do you get when you type this into developer tools → template:

{{ states('person.simon') }}

Hi,

I have configured it this way

alias: Betreden ZONE Thuiskomen
description: ""
triggers:
  - device_id: 83****
    domain: device_tracker
    entity_id: c9****
    type: enters
    zone: zone.thuiskomen
    trigger: device
conditions:
  - condition: state
    entity_id: sun.sun
    state: below_horizon
actions:
  - action: scene.turn_on
    target:
      entity_id:
        - scene.voordeur_aan
        - scene.oprit_aan
    data: {}
mode: single

i selected the zone from the list so i would assume that is correct

{{ states('person.simon') }} gives home as the result

i didn’t create the automation manually in YAML, i set up it up using the UI

Okay, I see that it’s correct to use the zone. prefix.

I am not sure what else to suggest here but hopefully others on the forum will have ideas.

Another way to look at this if it helps you is to trigger on the state of zone.home.
If it’s 0, noone is home.
It stores the number of persons in the home zone.

how does that help with turning the light on when anyone enters the zone?
isn’t it more complicated to count the value of that state to decide if the light is turned on or not?

also, the automation may only apply to certain people, the state count doesn’t know “who” is in the zone.

Just offering alternatives if they fit.
What you are doing is as right as anything else, but would be a bit annoying if you wanted to apply it to an everyone light, for instance.

Add a map card on your dashboard and set the hours to show a few hours, then you should be able to see what HA believes your position is in comparison to when the light turns on. Take note what time you arrived home.

I have a feeling the position tracking is lacking behind and because of this the light turns on when you already sit in the sofa.

i was tracking the location on the map, and saw the person move inside the zone, and the state change from away to home.

the light never turned on, not even once they were physically in the house

related to that, is there a setting in the iOS where you can increase/decrease the location reporting?

Did the automation trigger?
Does it have a trace?

With iOS, not sure. Don’t think so.
Android has more options as far as I know.

it didn’t trigger from what i can tell, the light certainly didn’t turn on
in developer tools > states > set state - the light turns on

no idea, this was yesterday and we’ve not had an instance yet today where it would be triggered - both are currently at home.

i would need to wait again today to see what happens when someone leaves then re-enters the home zone. the home zone is wide enough to pick them up as they enter the street.

You can set the state of the two persons to not_home then back to home

ok i changed the state of me person.simon to not_home.
waited about 10 seconds then changed it back to home

checked the light and it didn’t turn on
not sure what to check next to see why it didn’t turn on

alias: Hall Light When Approaching Home
description: ""
triggers:
  - trigger: zone
    entity_id: person.sarah_jane
    zone: zone.home
    event: enter
  - trigger: zone
    entity_id: person.simon
    zone: zone.home
    event: enter
conditions: []
actions:
  - action: light.turn_on
    metadata: {}
    data: {}
    target:
      device_id: b7c59356ca04deaccbe01ee607b28734
mode: single

if i click set state on this the light turns on

You are running the automation, so yes…

But in that case there is something wrong with your triggers.

ok, what might the issue be with the triggers?

this is how it visually looks in the UI

and the yaml

alias: Hall Light When Approaching Home
description: ""
triggers:
  - trigger: zone
    entity_id: person.sarah_jane
    zone: zone.home
    event: enter
  - trigger: zone
    entity_id: person.simon
    zone: zone.home
    event: enter
conditions: []
actions:
  - action: light.turn_on
    metadata: {}
    data: {}
    target:
      device_id: b7c59356ca04deaccbe01ee607b28734
mode: single

Try a different trigger.
Or as suggested before use the count of the state of zone home just for testing.

But I would rather use the state trigger than the zone trigger.

  - trigger: state
    entity_id:
      - person.sarah_jane
      - person.simon
    to: home

the person state is defintely working, as my partner is now out the house and their state is showing as not_home

so at least i know that part is working correctly.
it changed to not_home shortly after leaving the house (enough time get out the zone defined area)

So you are you suggesting something like this?

alias: Hall Light When Approaching Home
description: ""
  - trigger: state
    entity_id:
      - person.sarah_jane
      - person.simon
    to: home
conditions: []
actions:
  - action: light.turn_on
    metadata: {}
    data: {}
    target:
      device_id: b7c59356ca04deaccbe01ee607b28734
mode: single

I had a terrible time trying to use people, I now use the home zone as below and have no issues.

trigger: numeric_state
entity_id:
  - zone.home
below: 1
for:
  hours: 0
  minutes: 0
  seconds: 20