GPS/Location update frequency

Is there any setting/option to set the GPS/location update frequency?

I see it updates ~1-2 minutes now and would like to be able to set that (from home assistant perspective - not the app) at desire.

I currently have GPS Logger (been using it for years) and the Home Assistant companion app for both myself and my wife. My GPS Logger app is set only to track “passive locations.” Most of the time if I look at the map when one or both of us is out, the GPS Logger entities will be where it needs to be, but the Home Assistant app entities lag up to 10 minutes.

Using GPS Logger as a reference of possible GPS/location settings would be a good start.

The app uses Google’s location provider so anytime it has an update for us and it meets the accuracy requirements we send it over

Are you sure about that?
I see this very often.

Almost constantly actually, but my sensor is not updating that often.
Which is odd, HA request a position but it’s not saved.

During the time I wrote this post, it has come up three times

Google?! please tell me my location data is NOT going via or to google!?

yes you can expect to see location updating that frequently that was why I said anytime google has an update for us and it meets the requirements we send it over. Sometimes you can see updates coming in every 30 seconds like if you are using google maps navigation for example.

Sensors update on a completely different interval…some update every 15 min and some update upon a state change. Location also updates when the sensors update.

If you are using the google play store version then yes, we recently released a minimal app version taht does not use any of googles services and therefore does not do location tracking, notifications nor use any of its API’s. We had a blog post about this a couple weeks back.

Why can’t the app just use “the phone’s” GPS? Without using google?

You know the app is built by developers who donate their own free time. We have not had a developer come by and create a location tracker that does not rely on Google as that takes a lot of time to build out.
Google provides APIs that are well tested and do not drain the battery and not to mention easier and faster to build out. We are open source so any developer is free to come along and add it!

5 Likes

Ok, fair enough I understand the opensource/development part. But I do not understand why asking the phone’s direct GPS location instead of Google doing it and send it to an app makes a battery difference :thinking:

1 Like

An alternative to solve the problem is to use the request_location_update service made available by Hassio.

In my case I was interested in the increased GPS update rate activity as I got closer to home. Through the proximity service, when I go below 3 kilometres, I make it intensify until I get home or stop, requesting an update every 10 seconds.

So I built an automation (which can be used for both Apple and Android) to do this. I leave you the corresponding piece of code if it helps:

- alias: "GPS - increase freq update Person position near home"

  trigger:
    - platform:  numeric_state
      entity_id: proximity.your_device
      below: 3
       
  action:
    - repeat:
          until:
            - condition: or
              conditions:
                - condition: state
                  entity_id: person.you
                  state: home
                - condition: state
                  entity_id: proximity.your_device
                  attribute: dir_of_travel
                  state: stationary
                - condition: state
                  entity_id: proximity.your_device
                  attribute: dir_of_travel
                  state: arrived
                - condition: numeric_state
                  entity_id: proximity.your_device
                  above: 3
          sequence:
            - service: notify.mobile_your_phone
              data:
                message: request_location_update
            - delay:
                hours: 0
                minutes: 0
                seconds: 10
                milliseconds: 0

Alternatively, you can also set the forced location update unconditionally as often as you like, but BE AWARE that (as written in the documentation) it could have a negative impact on the device’s battery.

I know it was an old post but I think this solution could be useful for anyone looking for an alternative.

3 Likes

Just curious if you can help figure out why I can’t get the same code to run on my instance. I’m super new to yaml so forgive me

- alias: "GPS - increase freq update Person position"

  trigger:
    - platform: numeric_state
      entity_id: person.regan
      below: 3

  action:
    - repeat:
        until:
          - condition: or
            conditions:
              - condition: state
                entity_id: person.regan
                state: home
              - condition: state
                entitiy_id: person.regan
                attribute: dir_of_travel
                state: stationary
              - condition: state
                entity_id: person.regan
                state: arrived
              - condition: numeric_state
                entity_id: person.regan
                above: 3
          sequence:
            - service: notify.device_tracker.regan_s_phone_2
              data:
                message: request_location_update
            - delay:
                hours: 0
                minutes: 0
                seconds: 10
                milliseconds: 0

All my integers stay red for whatever reason (which I assume indicates an error of some kind

I also get the following error upon trying to save:
“Message malformed: extra keys not allowed @ data[‘0’]”

your notify service call looks incorrect

it should be notify.mobile_app_* where * is replaced with your device name

Thank you for the help! I am starting to learn little bits of YAML bit by bit.

So I now have the following code:

- alias: "GPS - increase freq update Person position near home"

  trigger:
    - platform:  numeric_state
      entity_id: proximity.device_tracker.regan_s_phone_2
      below: 3
       
  action:
    - repeat:
          until:
            - condition: or
              conditions:
                - condition: state
                  entity_id: person.regan
                  state: home
                - condition: state
                  entity_id: proximity.device_tracker.regan_s_phone_2
                  attribute: dir_of_travel
                  state: stationary
                - condition: state
                  entity_id: proximity.device_tracker.regan_s_phone_2
                  attribute: dir_of_travel
                  state: arrived
                - condition: numeric_state
                  entity_id: proximity.device_tracker.regan_s_phone_2
                  above: 3
          sequence:
            - service: notify.mobile_app_device_tracker.regan_s_phone_2
              data:
                message: request_location_update
            - delay:
                hours: 0
                minutes: 0
                seconds: 10
                milliseconds: 0

Still doesn’t work and fires the following error:
Message malformed: extra keys not allowed @ data[‘0’]

I’m beginning to suspect I am using incorrect entity IDs perhaps. Below are screenshots of the entities I have been using…

image
image
image

Any other thoughts? Once again, any help greatly appreciated

yes your entity IDs and your notify service call are incorrect.

The correct format is always domain.name notice how its only 1 period separating it

so for example below is correct

this is not correct and you have it listed 3 times, there is only 1 period in the entity ID

the service call also looks to have an issue, maybe it was a copy and paste mistake :slight_smile:

check developer tools > actions for the correct service to use

OK, making slow and steady progress here. Using the developer tools was definitely helpful. I’ve gotten to the following code and realized some things.

  1. my proximity integration was set in feet, so I upped the distance to 1000 feet
  2. for the entity ids under the proximity conditions I found the following
    image

and

image

I presume I am using those correctly within the code.

Given those assumptions, I now have the following which is still throwing the same “Message malformed: extra keys not allowed @ data[‘0’]” error

- alias: "GPS - increase freq update for Dave position near home"

  trigger:
    - platform:  numeric_state
      entity_id: sensor.home_dave_distance
      below: 1000
       
  action:
    - repeat:
          until:
            - condition: or
              conditions:
                - condition: state
                  entity_id: person.piccinati
                  state: home
                - condition: state
                  entity_id: sensor.home_dave_direction_of_travel
                  attribute: dir_of_travel
                  state: stationary
                - condition: state
                  entity_id: sensor.home_dave_direction_of_travel
                  attribute: dir_of_travel
                  state: arrived
                - condition: numeric_state
                  entity_id: sensor.home_dave_distance
                  above: 1000
          sequence:
            - service: notify.mobile_app_dave_s_iphone
              data:
                message: request_location_update
            - delay:
                hours: 0
                minutes: 0
                seconds: 10
                milliseconds: 0

Once again, I appreciate all the hand holding here. If it’s too much just let me know and I may give up on this until I gain more experience in the future!

Interestingly, I started just using the visual editor to get some of the right syntax and ended up merging with your original build. I now have the following and was able to save. I’ll test it with some generic text here tomorrow but either way…progress!

Thank you again for your diligence with helping me!

alias: GPS test for Dave
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.home_dave_distance
    below: 1000
action:
  - repeat:
      until:
        - condition: or
          conditions:
            - condition: state
              entity_id: person.piccinati
              state: home
            - condition: state
              entity_id: sensor.home_dave_direction_of_travel
              state: stationary
            - condition: state
              entity_id: sensor.home_dave_direction_of_travel
              state: arrived
            - condition: numeric_state
              entity_id: sensor.home_dave_distance
              above: 1000
      sequence:
        - data:
            message: request_location_update
          action: notify.mobile_app_dave_s_iphone
        - delay:
            hours: 0
            minutes: 0
            seconds: 10
            milliseconds: 0