Repository navigation
Fix Xbox achievements total - #182791
Open
scardus wants to merge 6 commits into
Open
Fix Xbox achievements total#182791scardus wants to merge 6 commits into
scardus wants to merge 6 commits into
Conversation
Titlehub always reports totalAchievements as 0 for Xbox One titles once any achievement has been unlocked. 121 was from a previous version of the file before an achievement was unlocked.
Fall back to the achievements API, which reports the real total.
Contributor
|
Hey there @tr4nt0r, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The fallback cache and error paths can retain an incorrect total or disrupt presence updates.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Open (3)
What changed in this PR
Corrects Xbox One achievement totals by querying the achievements API when TitleHub reports zero.
Changes:
- Adds achievement-total fallback retrieval and entity plumbing.
- Adds API fixtures and snapshot coverage.
- Corrects an inaccurate TitleHub fixture.
| File | Description |
|---|---|
homeassistant/components/xbox/coordinator.py |
Fetches and caches fallback totals. |
homeassistant/components/xbox/entity.py |
Exposes totals to attribute callbacks. |
homeassistant/components/xbox/sensor.py |
Uses the fallback total. |
homeassistant/components/xbox/binary_sensor.py |
Updates the callback signature. |
tests/components/xbox/conftest.py |
Mocks the achievements endpoint. |
tests/components/xbox/fixtures/achievements_gameprogress.json |
Adds achievements response data. |
tests/components/xbox/fixtures/titlehub_titleinfo_2533274913657542.json |
Restores the reported zero total. |
tests/components/xbox/snapshots/test_diagnostics.ambr |
Updates expected diagnostics. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
scardus
marked this pull request as draft
September 20, 2026 18:06
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
A same-title update takes the `continue` path, so a lookup that failed was never retried. Fetch the total on unchanged titles too and cache it per xuid, including a zero, so a completed lookup is not repeated.
title_data and achievement_totals were mutable ClassVars, so every config entry read and wrote the same two dicts. Make them instance attributes, set up in __init__ alongside the client.
scardus
marked this pull request as ready for review
September 21, 2026 20:25
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Proposed change
The now_playing sensor has an achievements attribute that looks like "number of achieved \ total achievable".
For Xbox One titles, titlehub reports totalAchievements as 0 as soon as the player has unlocked anything. It only reports the real total in two cases:
You can see an example in your existing test fixtures...
titlehub_titlehistory.json has Blue Dragon, an Xbox 360 title, reporting a correct "3 / 43". The same file has Assassin's Creed Syndicate, an Xbox One title, reporting "22 / 0".
The achievements API will always give the real total, so this change calls it when titlehub reports zero.
In the first commit I've fixed titlehub_titleinfo_2533274913657542.json, which had
totalAchievements: 121. I edited that file by hand during the testing of the previous PR and mistakenly included that version in #182686.The second commit adds the achievement totals fix.
The rest of the commits are following Copilot's review:
I've been running the fix live on my own dashboard, where a Minecraft session that titlehub reports as "11 / 0" now correctly shows "11 / 133".
Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: