More reliable iOS location updates

Thought I’d share a little trick I implemented a while ago, to help improve iOS location updates.

I’m currently using the iOS app, with a home zone, and work zone, and firing automations based on “home” or “not_home”. As we all know this is a little hit and miss.

I started using the Traccar custom component by @koen01 which can be found here.

In a nutshell, the automation monitors if my car (reported by the traccar component) transitions from “not_home” to “home”, and if it does, to ask the iOS app for a location update, but only if the iPhone still isn’t “home”.

The theory is, if my car is home, chances are I’m home as well…

The Code:
automations.yaml:

- id: iPhone Location Update
  alias: iPhone Location Update
  trigger:
    platform: state
    entity_id: device_tracker.car
    from: 'not_home'
    to: 'home'
    for:
      seconds: 30
  condition:
    condition: state
    entity_id: device_tracker.ios_xxx_iphone
    state: not_home
  action:
    service: homeassistant.turn_on
    entity_id: script.iphone_location_update 

scripts.yaml:

  iphone_location_update:
    alias: 'iPhone Location Update'
    sequence:
    - service: notify.ios_xxx_iphone
      data:
        message: "request_location_update"
    - delay: 30
    - service: notify.ios_xxx_iphone
      data:
        message: "request_location_update"

I’ve been using this for a few weeks now, and my “home” location automation now fires about 95% of the time, vs about 60% of the time without.

Hope this helps somebody!

2 Likes