Skip to content

Fix location fetch: use numeric LocationRefreshMode enum (Google API change)#132

Merged
noiwid merged 1 commit into
noiwid:mainfrom
miditt:fix/location-refresh-mode-numeric-enum
Jul 9, 2026
Merged

Fix location fetch: use numeric LocationRefreshMode enum (Google API change)#132
noiwid merged 1 commit into
noiwid:mainfrom
miditt:fix/location-refresh-mode-numeric-enum

Conversation

@miditt

@miditt miditt commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Problem

Google's kidsmanagement location endpoint no longer accepts the string values "REFRESH" / "DO_NOT_REFRESH" for locationRefreshMode. Requests now fail with:

HTTP 400: Invalid value at 'location_refresh_mode'
(type.googleapis.com/google.kidsmanagement.v1.LocationRefreshMode), "REFRESH"

Because async_get_location returns None on a non-200 response, the device_tracker silently freezes on the last position that succeeded before Google's change — no error surfaced to the user, just a stale location.

Fix

Google now requires the numeric enum values. Switched to 2 (REFRESH) / 1 (DO_NOT_REFRESH), both verified returning HTTP 200 against the live API. Added named class constants with an explanatory comment.

Testing

Reproduced the 400 with the string value and confirmed 200 + a fresh GPS fix with the numeric value, against a live supervised account. Deployed to a running HA instance; device_tracker location resumed updating immediately.

Google's kidsmanagement location endpoint no longer accepts the string
values "REFRESH" / "DO_NOT_REFRESH" for locationRefreshMode and now
returns HTTP 400 ("Invalid value at 'location_refresh_mode'"). This
breaks all location fetches, leaving device_tracker stuck on the last
value that succeeded before the API change.

Switch to the numeric enum values Google now expects (2 = REFRESH,
1 = DO_NOT_REFRESH), verified returning HTTP 200 against the live API.
noiwid pushed a commit that referenced this pull request Jul 9, 2026
Version must not be hand-edited — it is bumped automatically by the
release workflow on GitHub Release publish. The PR branch carried a
manual bump; keep only the api.py location fix.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0141zVauypPjLPy5N2rUCw2J
@noiwid noiwid merged commit f123cb8 into noiwid:main Jul 9, 2026
@noiwid

noiwid commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Thanks a lot for this @miditt - excellent diagnosis and a very clean fix. 🙏

Confirmed on my side: Google's kidsmanagement location endpoint now rejects the string LocationRefreshMode values and only accepts the numeric enum. The failure mode was exactly as you described - async_get_location returns None on the 400, so the device_tracker silently froze on the last known position with nothing surfaced to the user. Nasty one to catch.

Merged into main. I only dropped the manual manifest.json version bump (1.2.11) from the branch, since the version is bumped automatically by the release workflow when I cut a GitHub Release - the API fix itself went in untouched. This will ship in the next release. Thanks again for testing it against the live API and reporting the before/after so clearly! 🚀

noiwid pushed a commit that referenced this pull request Jul 9, 2026
Google's kidsmanagement location endpoint now rejects the string values
"REFRESH"/"DO_NOT_REFRESH" with HTTP 400 and requires the numeric enum
values (2=REFRESH, 1=DO_NOT_REFRESH). Without this the device_tracker
silently froze on the last known position.

Thanks to @miditt for the fix.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
noiwid pushed a commit that referenced this pull request Jul 9, 2026
Version must not be hand-edited — it is bumped automatically by the
release workflow on GitHub Release publish. The PR branch carried a
manual bump; keep only the api.py location fix.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants