Skip to content

Fix friends' achievement stats in Xbox integration - #182686

Merged
joostlek merged 2 commits into
home-assistant:devfrom
scardus:xbox-title-info-by-xuid
Sep 20, 2026
Merged

joostlek merged 2 commits into
home-assistant:devfrom
scardus:xbox-title-info-by-xuid

Conversation

@scardus

@scardus scardus commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Proposed change

The Xbox integration fetches title info for every person it tracks, but the call always used the signed-in account's xuid. The achievements, gamerscore and progress shown for a friend were the signed-in user's own figures for that game.

python-xbox 0.3.0 added get_title_info_by_xuid. With this change, the coordinator now passes each person's xuid, so a friend's card shows their own figures. The signed-in account is unaffected.

A new test fixture puts a friend in a game.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Copilot AI balanced review requested due to automatic review settings September 19, 2026 13:38
@home-assistant home-assistant Bot added bugfix cla-signed has-tests integration: xbox small-pr PRs with less than 30 lines. Top 200 Integration is ranked within the top 200 by usage Quality Scale: platinum labels Sep 19, 2026
@home-assistant

Copy link
Copy Markdown
Contributor

Hey there @tr4nt0r, mind taking a look at this pull request as it has been labeled with an integration (xbox) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of xbox can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant mark-draft Mark the pull request as draft.
  • @home-assistant ready-for-review Remove the draft status from the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign xbox Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant update-branch Update the pull request branch with the base branch.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) on the pull request.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The focused implementation matches the dependency API and includes regression coverage for the corrected XUID.

Review effort: Balanced
Findings: None

What changed in this PR

Updates Xbox presence data to fetch title statistics for each tracked person’s XUID.

Changes:

  • Uses get_title_info_by_xuid for person-specific achievements.
  • Adds a playing-friend fixture and regression test.
  • Extends the mocked Title Hub API.
File Description
homeassistant/​components/​xbox/​coordinator.py Requests title details using each person’s XUID.
tests/​components/​xbox/​conftest.py Mocks the new API method.
tests/​components/​xbox/​test_init.py Verifies the friend XUID is passed.
tests/​components/​xbox/​fixtures/​people_friends_own_playing.json Provides friend presence test data.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@tr4nt0r tr4nt0r left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good catch by the way! I never noticed that it was showing the own achievement info 😂
I have just some small remarks about the tests.

Comment thread tests/components/xbox/conftest.py
Comment thread tests/components/xbox/conftest.py Outdated
Comment thread tests/components/xbox/test_init.py Outdated
Copilot AI review requested due to automatic review settings September 20, 2026 06:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation passes the correct XUID and the updated fixtures and snapshots cover both account and friend title data.

Review effort: Balanced
Findings: None

@scardus

scardus commented Sep 20, 2026

Copy link
Copy Markdown
Contributor Author

Applied both test suggestions.

erics273 is now online and playing Minecraft, and the mock returns title info per xuid from titlehub_titleinfo_<xuid>.json.

The two title fixtures give the owner and erics273
different achievement counts and gamerscore to catch this bug.

I left the get_title_info mock in place for now... see my other comment.

@tr4nt0r tr4nt0r left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, LGTM! 👍🏼

@joostlek joostlek added this to the 2026.9.4 milestone Sep 20, 2026
@joostlek
joostlek merged commit ef97d7c into home-assistant:dev Sep 20, 2026
35 checks passed
@scardus
scardus deleted the xbox-title-info-by-xuid branch September 20, 2026 15:42
@scardus scardus mentioned this pull request Sep 20, 2026
10 of 21 tasks
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants