Device-tracker triggered

Hello,

I made an automation with this trigger :

trigger:
  - platform: state
    entity_id:
      - device_tracker.alex

Even if Alex is at school since 8:21:30 (for the whole day), the automation is triggered all the time f.e. :

image

Looking at the history nothing changes :

Why and how can I solve this ?

It is probably triggering on gps position changes. What do you want to accomplish, i.e. when do you want it to trigger? Coming or leaving home, or reaching some other destination?

Edit: I do see your point in that it is weird that the state itself hasn’t changed, just the attributes. Adding a template condition using this should fix it, but then again it should be implicitly true: (untested, maybe I got some of the syntax slightly wrong):

{{ trigger.from_state.state != trigger.to_state.state }}

Second edit: I like tom’s solution below better :slight_smile:

Supplying a null to state will only trigger on state changes and ignore attribute changes:

trigger:
  - platform: state
    entity_id: device_tracker.alex
    to:

Or better yet:

trigger:
  - platform: state
    entity_id: device_tracker.alex
    not_to:
      - unknown
      - unavailable
1 Like

Thank you Tom, works fine now !

Is there a simple way to calculate the distance between 2 positions (latitude, longitude) ?

https://www.home-assistant.io/docs/configuration/templating/#distance

{{ distance('device_tracker.1', 'device_tracker.2') }}