Trouble with enter zone automation

I’ve been having some trouble with an automation which should trigger when a particular tracked device (my mobile phone) enters a particular zone (around a bus stop). My automation looks something like this (I’ve changed the device name and message from the actual one).

- id: at_bus_stop
  alias: At Bus Stop
  trigger:
  - entity_id: device_tracker.device_name
    event: enter
    platform: zone
    zone: zone.bus_stop
  condition: []
  action:
  - alias: ''
    data:
      message: Device is at the bus stop
    service: notify.notify

This morning the automation fired at around 7:35 AM, despite being in another zone (work, which is approximately 10 minutes walk away) between 7:10 AM and 3:30 PM. AT that point I was walking towards the bus stop zone and arrived at 3:39 PM. Strangely, now that the device was actually at the bus stop, the automation did not trigger.
The history for the device shows the device at the work zone between 7:10 AM and 3:39 PM and at the bus stop zone between 3:39 PM and 3:44 PM.
The Logbook also doesn’t show the device at being in the zone prior to the automation being triggered and does show it in the zone when it was not triggered.

Does anybody have any idea why this automation triggered when I was not at the zone and not when I was?

That does seem weird. Unfortunately I haven’t tried using the zone trigger, so I don’t have any experience with that to share.

But, what I have seen is that the device_tracker state will update to the name of a zone when the device is in the zone. So could you do something like this instead:

- id: at_bus_stop
  alias: At Bus Stop
  trigger:
    platform: state
    entity_id: device_tracker.device_name
    to: bus_stop
  action:
    service: notify.notify
    data:
      message: Device is at the bus stop

Thanks for the suggestion. I changed the automation to use the state like you said and it worked correctly today. Hopefully it will carry on working.

1 Like