Device tracker automation trigger when tracker stop for 5 minutes

I want to fire automation trigger when tracker device stop in one possition (lat - lon - radius) for 5 minutes.

I think is good option when I go on a trip i activate this automation and send notifications when i stop for x minutes, is a warning for accidents , i combine with accionable notifications for say i stay good.

Something can helps me??

Thanks and sorry for my english

This may depend on the specifics of the particular device_tracker platform(s) you are using.

In my case, I’m using Life360 with a custom platform I wrote. Life360 reports the length of time you’re at a given location, which I make an attribute of the device_tracker entity. The tricky part is, you need something to trigger the automation with. But triggers are based on events, and by its nature, not moving is the lack of events. In theory you could use a state trigger with for: set to 5 minutes, but then again, whether or not that works depends on your particular device_tracker platform. This (probably) wouldn’t work with my Life360 platform, because the entity changes (at least it’s last_updated attribute does) whenever Life360 provides an update, even if the user isn’t moving. So, instead, I could use a time trigger that triggers, say, every minute, and then I could check the at_loc_since attribute, something like this:

  - alias: Notify when I haven't moved for 5 minutes
      platform: time
      minutes: '/1'
      seconds: 0
      condition: template
      value_template: >
        {{ now().timestamp() - as_timestamp(state_attr('','at_loc_since')) > 5 * 60 }}
      service: notify...

EDIT: The above would need something to make it only notify once until the condition becomes false then true again. Not saying it’s a complete solution as-is. Just putting ideas out there.

But if you had to do something like this just using the latitude and longitude attributes of the device_tracker, I’m not exactly sure how you’d do that. My guess would be you’d have to have an automation that triggers whenever the device_tracker changes and records the current lat/lon and the current time, if lat or lon changed (since the last time it was recorded.) Then you’d have to have another automation that triggers if the time recorded doesn’t change for 5 minutes. Something along those lines.

wow, great answer, thanks a lot, i think i can use your information

Are you using my Life360 custom platform? If not, then more than likely, your device_tracker doesn’t have that attribute. But maybe my other ideas might help. :slight_smile:

I use life360 services with a owntrack device tracker through mosquitto , i dont know exists life360 custom platform. When i have time i try it , thnks for create it.

The Life360 integration you’re using may expose at_loc_since as well, since this is reported by the Life360 server. However, if you’re interested in giving my integration a try, you can find more info about it here.