Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix location updates on core <2022.2 #3030

Merged

Conversation

jpelgrom
Copy link
Member

@jpelgrom jpelgrom commented Nov 2, 2022

Summary

It turns out that #2969 breaks location updates for people on core <2022.2, which wasn't intended. This PR fixes that.

Always including location_name breaks compatibility with previous versions as it will reject updates: Received invalid webhook payload: string value is None for dictionary value @ data['location_name']. Got None. Updates would look like this:

{"type":"update_location","data":{"gps":[1, 2],"gps_accuracy":13,"location_name":null,"speed":0,"altitude":47,"course":7,"vertical_accuracy":1}}

Now, updates on core <2022.2 and when using the 'Exact' setting look like this (again):

{"type":"update_location","data":{"gps":[1, 2],"gps_accuracy":13,"speed":0,"altitude":47,"course":7,"vertical_accuracy":1}}

And 'Zone name only' updates will only include the location name:

{"type":"update_location","data":{"location_name":"not_home"}}

Only including non-null values works correctly on newer versions (it still clears the GPS data / switches to zone when sending just the location_name, and clears the forced zone when sending GPS data) and restores compatibility with older versions. Tested on:

  • core 2021.12.10 - last version before app zone only support
  • core 2022.2.0 - first version with app zone only support
  • core 2022.10.5 - latest version while testing

Screenshots

n/a

Link to pull request in Documentation repository

n/a

Any other notes

Reported on Discord

 - Including `location_name` always breaks compatibility with previous versions as it will reject updates with unknown keys. Only including non-null values seems to work correctly and makes it work again on older versions.
Copy link
Member

@dshokouhi dshokouhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick fix!

@JBassett JBassett merged commit 3b93bc1 into home-assistant:master Nov 3, 2022
@jpelgrom jpelgrom deleted the fix-location-tracking-pre-2022 branch November 3, 2022 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants