Fix friends' achievement stats in Xbox integration (#182686)

This commit is contained in:
Sean Cardus
2026-09-20 15:50:48 +02:00
committed by GitHub
parent a74b99f94a
commit ef97d7c3f8
8 changed files with 416 additions and 38 deletions
+2 -2
View File
@@ -228,8 +228,8 @@ class XboxPresenceCoordinator(XboxBaseCoordinator[XboxData]):
):
continue
try:
title = await self.client.titlehub.get_title_info(
presence_detail.title_id
title = await self.client.titlehub.get_title_info_by_xuid(
person.xuid, presence_detail.title_id
)
except HTTPStatusError as e:
if e.response.status_code == HTTPStatus.NOT_FOUND:
+7
View File
@@ -191,6 +191,13 @@ def mock_xbox_live_client() -> Generator[AsyncMock]:
client.titlehub.get_title_info.return_value = TitleHubResponse(
**load_json_object_fixture("titlehub_titleinfo.json", DOMAIN)
)
def get_title_info_by_xuid(xuid: str, _: str) -> TitleHubResponse:
return TitleHubResponse(
**load_json_object_fixture(f"titlehub_titleinfo_{xuid}.json", DOMAIN)
)
client.titlehub.get_title_info_by_xuid.side_effect = get_title_info_by_xuid
client.titlehub.get_title_history.return_value = TitleHubResponse(
**load_json_object_fixture("titlehub_titlehistory.json", DOMAIN)
)
@@ -133,8 +133,8 @@
"modernGamertagSuffix": "",
"uniqueModernGamertag": "erics273",
"xboxOneRep": "GoodPlayer",
"presenceState": "Offline",
"presenceText": "Last seen 17h ago: Home",
"presenceState": "Online",
"presenceText": "Minecraft",
"presenceDevices": null,
"isFriend": true,
"isFriendRequestReceived": false,
@@ -174,23 +174,23 @@
{
"IsBroadcasting": false,
"Device": "XboxOne",
"PresenceText": "Last seen 17h ago: Home",
"State": "LastSeen",
"TitleId": "750323071",
"PresenceText": "Minecraft",
"State": "Active",
"TitleId": "1739947436",
"TitleType": null,
"IsPrimary": true,
"IsGame": false,
"IsGame": true,
"RichPresenceText": null
}
],
"titlePresence": {
"IsCurrentlyPlaying": false,
"PresenceText": null,
"TitleName": null,
"TitleId": null
"IsCurrentlyPlaying": true,
"PresenceText": "Minecraft",
"TitleName": "Minecraft",
"TitleId": "1739947436"
},
"titleSummaries": null,
"presenceTitleIds": ["750323071"],
"presenceTitleIds": ["1739947436"],
"detail": {
"accountTier": "Silver",
"bio": "",
@@ -0,0 +1,89 @@
{
"xuid": "2533274913657542",
"titles": [
{
"titleId": "1739947436",
"pfn": "Microsoft.MinecraftUWP_8wekyb3d8bbwe",
"bingId": "8ff0c8c4-2b7f-4e2e-9ab9-2cd9ac0d1b4b",
"serviceConfigId": "4fc10100-5f7a-4470-899b-280835760c07",
"windowsPhoneProductId": null,
"name": "Minecraft",
"type": "Game",
"devices": ["XboxOne", "XboxSeries", "Win32", "Android", "iOS"],
"displayImage": "http://store-images.s-microsoft.com/image/apps.50293.13851379342944008.b2fc5ef4-8c3f-4b02-8c42-1e88e52dd0f1.98b3c9d5-1f3d-4d1e-9fdd-c1c1e7d0bd57",
"mediaItemType": "XboxOneGame",
"modernTitleId": "1739947436",
"isBundle": false,
"achievement": {
"currentAchievements": 57,
"totalAchievements": 121,
"currentGamerscore": 1105,
"totalGamerscore": 2500,
"progressPercentage": 44.0,
"sourceVersion": 2
},
"stats": null,
"gamePass": null,
"images": [
{
"url": "http://store-images.s-microsoft.com/image/apps.50293.13851379342944008.b2fc5ef4-8c3f-4b02-8c42-1e88e52dd0f1.98b3c9d5-1f3d-4d1e-9fdd-c1c1e7d0bd57",
"type": "BoxArt",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.11144.13851379342944008.b2fc5ef4-8c3f-4b02-8c42-1e88e52dd0f1.6a2c9c4f-1a34-4a3f-9a2e-0f3a5a07a6bd",
"type": "Logo",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.27886.13851379342944008.b2fc5ef4-8c3f-4b02-8c42-1e88e52dd0f1.5a9d2a8e-64f2-4f9a-9a2b-9d2a7f18e3c1",
"type": "TitledHeroArt",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.63217.13851379342944008.b2fc5ef4-8c3f-4b02-8c42-1e88e52dd0f1.3d8e6b5c-7c1a-42f9-84d6-0f9f4a1c2b77",
"type": "Poster",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.19442.13851379342944008.b2fc5ef4-8c3f-4b02-8c42-1e88e52dd0f1.c47a1d09-52b7-4d0e-9a7f-2e5b1a6d8f34",
"type": "Screenshot",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.38014.13851379342944008.b2fc5ef4-8c3f-4b02-8c42-1e88e52dd0f1.0b6e9f21-4a3c-4b8d-bc57-7a1e9d3f6c20",
"type": "Screenshot",
"caption": ""
}
],
"titleHistory": null,
"titleRecord": null,
"detail": {
"attributes": [],
"availabilities": [
{
"Actions": ["Details", "Purchase", "Browse"],
"AvailabilityId": "9NBLGGH537B3",
"Platforms": ["Xbox"],
"SkuId": "0010",
"ProductId": "9NBLGGH537B3"
}
],
"capabilities": [],
"description": "Explore infinite worlds and build everything from the simplest of homes to the grandest of castles. Play in creative mode with unlimited resources or mine deep into the world in survival mode, crafting weapons and armor to fend off dangerous mobs.",
"developerName": "Mojang Studios",
"genres": ["Action & adventure", "Family & kids"],
"minAge": 7,
"publisherName": "Xbox Game Studios",
"releaseDate": "2017-09-19T07:00:00Z",
"shortDescription": "Explore infinite worlds and build everything from the simplest of homes to the grandest of castles.",
"vuiDisplayName": "Minecraft",
"xboxLiveGoldRequired": false
},
"friendsWhoPlayed": null,
"alternateTitleIds": [],
"contentBoards": null,
"xboxLiveTier": "Full"
}
]
}
@@ -0,0 +1,186 @@
{
"xuid": "271958441785640",
"titles": [
{
"titleId": "1297287135",
"pfn": null,
"bingId": "66acd000-77fe-1000-9115-d8024d5307df",
"serviceConfigId": "7f2e0100-2f8c-4b64-b2be-675b266ec2cd",
"windowsPhoneProductId": null,
"name": "Blue Dragon",
"type": "Game",
"devices": ["Xbox360", "XboxOne", "XboxSeries"],
"displayImage": "http://store-images.s-microsoft.com/image/apps.45451.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.3abf2cc3-00cc-417d-a93d-97110cdfb261",
"mediaItemType": "Xbox360Game",
"modernTitleId": "644793037",
"isBundle": false,
"achievement": {
"currentAchievements": 2,
"totalAchievements": 43,
"currentGamerscore": 10,
"totalGamerscore": 1000,
"progressPercentage": 1.0,
"sourceVersion": 1
},
"stats": null,
"gamePass": null,
"images": [
{
"url": "http://store-images.s-microsoft.com/image/apps.35725.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.c4bf34f8-ad40-4af3-914e-a85e75a76bed",
"type": "Screenshot",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.64736.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.6491fb2f-52e7-4129-bcbd-d23a67117ae0",
"type": "BrandedKeyArt",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.55545.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.4c2daefb-fbf6-4b90-b392-bf8ecc39a92e",
"type": "TitledHeroArt",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.22570.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.bf29284d-808a-4e4a-beaa-6621c9898d0e",
"type": "Poster",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.55545.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.4c2daefb-fbf6-4b90-b392-bf8ecc39a92e",
"type": "SuperHeroArt",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.45451.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.3abf2cc3-00cc-417d-a93d-97110cdfb261",
"type": "BoxArt",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.35072.13670972585585116.70570f0d-17aa-4f97-b692-5412fa183673.25a97451-9369-4f6b-b66b-3427913235eb",
"type": "Logo",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.45451.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.3abf2cc3-00cc-417d-a93d-97110cdfb261",
"type": "FeaturePromotionalSquareArt",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.38628.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.c2a205af-5146-405b-b2b7-56845351f1f3",
"type": "Screenshot",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.22150.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.b147895c-e947-424d-a731-faefc8c9906a",
"type": "Screenshot",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.37559.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.479d2dc1-db2d-4ffa-8c54-a2bebb093ec6",
"type": "Screenshot",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.32737.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.6a16ae3e-2918-46e9-90d9-232c79cb9d9d",
"type": "Screenshot",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.57046.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.0c0dd072-aa27-4e83-9010-474dfbb42277",
"type": "Screenshot",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.19315.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.6293a7b7-07ca-4df0-9eea-6018285a0a8d",
"type": "Screenshot",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.23374.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.66498a73-52f5-4247-a1e2-d3c84b9b315d",
"type": "Screenshot",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.64646.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.83182b76-4294-496d-90a7-f4e31e7aa80a",
"type": "Screenshot",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.24470.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.72d2abc3-aa69-4aeb-960b-6f6d25f498e4",
"type": "Screenshot",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.15604.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.27cee011-660b-49a4-bd33-38db6fff5226",
"type": "Screenshot",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.39987.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.be285efe-78f8-4984-9d28-9159881bacd4",
"type": "Screenshot",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.38206.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.2409803d-7378-4a69-a10b-1574ac42b98b",
"type": "Screenshot",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.14938.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.ef6ee72c-4beb-45ec-bd10-6235bd6a7c7f",
"type": "Screenshot",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.12835.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.6165ee24-df01-44f5-80fe-7411f9366d1c",
"type": "Screenshot",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.40786.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.b7607a0d-0101-4864-9bf8-ad889f820489",
"type": "Screenshot",
"caption": ""
},
{
"url": "http://store-images.s-microsoft.com/image/apps.55686.65457035095819016.56f55216-1bb9-40aa-8796-068cf3075fc1.ecbb0e91-36a9-4f76-ab1e-5a5de009840e",
"type": "Screenshot",
"caption": ""
}
],
"titleHistory": null,
"titleRecord": null,
"detail": {
"attributes": [],
"availabilities": [
{
"Actions": [
"Details",
"Fulfill",
"Purchase",
"Browse",
"Curate",
"Redeem"
],
"AvailabilityId": "9TWPXS4C28K1",
"Platforms": ["Xbox"],
"SkuId": "0001",
"ProductId": "C2HGK9J5367F"
}
],
"capabilities": [],
"description": "Hironobu Sakaguchi, the Father of the Final Fantasy series, and Artoon present the world of Blue Dragon on Xbox 360. Featuring the character design of Akira Toriyama, the Father of \"Dragon Ball Z\", and music by Nobuo Uematsu, the composer for Final Fantasy, Blue Dragon is an epic role-playing game (RPG) centered on five youngsters who possess miraculous strength and magical power to control shadow creatures that mirror the actions of their masters.",
"developerName": "Mistwalker / Artoon",
"genres": ["Role Playing"],
"minAge": 13,
"publisherName": "Microsoft",
"releaseDate": "2016-12-14T09:00:00Z",
"shortDescription": "Hironobu Sakaguchi, the Father of the Final Fantasy series, and Artoon present the world of Blue Dragon on Xbox 360. Featuring the character design of Akira Toriyama, the Father of \"Dragon Ball Z\", and music by Nobuo Uematsu, the composer for Final Fantasy, Blue Dragon is an epic role-playing game (RPG) centered on five youngsters who possess miraculous strength and magical power to control shadow creatures that mirror the actions of their masters.",
"vuiDisplayName": "Blue Dragon",
"xboxLiveGoldRequired": false
},
"friendsWhoPlayed": null,
"alternateTitleIds": [],
"contentBoards": null,
"xboxLiveTier": "Full"
}
]
}
@@ -51,7 +51,7 @@
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
'state': 'on',
})
# ---
# name: test_binary_sensors[binary_sensor.erics273_in_game-entry]
@@ -101,7 +101,7 @@
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
'state': 'on',
})
# ---
# name: test_binary_sensors[binary_sensor.gsr_ae-entry]
@@ -9623,20 +9623,20 @@
'device_sub_type': None,
'gameplay_type': None,
'is_broadcasting': False,
'is_game': False,
'is_game': True,
'is_primary': True,
'presence_text': 'Last seen 17h ago: Home',
'presence_text': 'Minecraft',
'rich_presence_text': None,
'state': 'LastSeen',
'title_id': '750323071',
'state': 'Active',
'title_id': '1739947436',
'title_type': None,
}),
]),
'presence_devices': None,
'presence_state': 'Offline',
'presence_text': 'Last seen 17h ago: Home',
'presence_state': 'Online',
'presence_text': 'Minecraft',
'presence_title_ids': list([
'750323071',
'1739947436',
]),
'real_name': '',
'recent_player': dict({
@@ -9661,10 +9661,10 @@
}),
'titleHistory': None,
'title_presence': dict({
'is_currently_playing': False,
'presence_text': None,
'title_id': None,
'title_name': None,
'is_currently_playing': True,
'presence_text': 'Minecraft',
'title_id': '1739947436',
'title_name': 'Minecraft',
}),
'title_summaries': None,
'tournament_summary': None,
@@ -9841,6 +9841,101 @@
'windows_phone_product_id': None,
'xbox_live_tier': 'Full',
}),
dict({
'achievement': dict({
'current_achievements': 57,
'current_gamerscore': 1105,
'progress_percentage': 44.0,
'source_version': 2,
'total_achievements': 121,
'total_gamerscore': 2500,
}),
'alternate_title_ids': list([
]),
'bing_id': '8ff0c8c4-2b7f-4e2e-9ab9-2cd9ac0d1b4b',
'content_boards': None,
'detail': dict({
'attributes': list([
]),
'availabilities': list([
dict({
'actions': list([
'Details',
'Purchase',
'Browse',
]),
'availability_id': '9NBLGGH537B3',
'platforms': list([
'Xbox',
]),
'sku_id': '0010',
}),
]),
'capabilities': list([
]),
'description': 'Explore infinite worlds and build everything from the simplest of homes to the grandest of castles. Play in creative mode with unlimited resources or mine deep into the world in survival mode, crafting weapons and armor to fend off dangerous mobs.',
'developer_name': 'Mojang Studios',
'genres': list([
'Action & adventure',
'Family & kids',
]),
'min_age': 7,
'publisher_name': 'Xbox Game Studios',
'release_date': '2017-09-19T07:00:00+00:00',
'short_description': 'Explore infinite worlds and build everything from the simplest of homes to the grandest of castles.',
'vui_display_name': 'Minecraft',
'xbox_live_gold_required': False,
}),
'devices': list([
'XboxOne',
'XboxSeries',
'Win32',
'Android',
'iOS',
]),
'display_image': 'http://store-images.s-microsoft.com/image/apps.50293.13851379342944008.b2fc5ef4-8c3f-4b02-8c42-1e88e52dd0f1.98b3c9d5-1f3d-4d1e-9fdd-c1c1e7d0bd57',
'friends_who_played': None,
'game_pass': None,
'images': list([
dict({
'type': 'BoxArt',
'url': 'http://store-images.s-microsoft.com/image/apps.50293.13851379342944008.b2fc5ef4-8c3f-4b02-8c42-1e88e52dd0f1.98b3c9d5-1f3d-4d1e-9fdd-c1c1e7d0bd57',
}),
dict({
'type': 'Logo',
'url': 'http://store-images.s-microsoft.com/image/apps.11144.13851379342944008.b2fc5ef4-8c3f-4b02-8c42-1e88e52dd0f1.6a2c9c4f-1a34-4a3f-9a2e-0f3a5a07a6bd',
}),
dict({
'type': 'TitledHeroArt',
'url': 'http://store-images.s-microsoft.com/image/apps.27886.13851379342944008.b2fc5ef4-8c3f-4b02-8c42-1e88e52dd0f1.5a9d2a8e-64f2-4f9a-9a2b-9d2a7f18e3c1',
}),
dict({
'type': 'Poster',
'url': 'http://store-images.s-microsoft.com/image/apps.63217.13851379342944008.b2fc5ef4-8c3f-4b02-8c42-1e88e52dd0f1.3d8e6b5c-7c1a-42f9-84d6-0f9f4a1c2b77',
}),
dict({
'type': 'Screenshot',
'url': 'http://store-images.s-microsoft.com/image/apps.19442.13851379342944008.b2fc5ef4-8c3f-4b02-8c42-1e88e52dd0f1.c47a1d09-52b7-4d0e-9a7f-2e5b1a6d8f34',
}),
dict({
'type': 'Screenshot',
'url': 'http://store-images.s-microsoft.com/image/apps.38014.13851379342944008.b2fc5ef4-8c3f-4b02-8c42-1e88e52dd0f1.0b6e9f21-4a3c-4b8d-bc57-7a1e9d3f6c20',
}),
]),
'is_bundle': False,
'is_streamable': None,
'media_item_type': 'XboxOneGame',
'modern_title_id': '1739947436',
'name': 'Minecraft',
'pfn': 'Microsoft.MinecraftUWP_8wekyb3d8bbwe',
'service_config_id': '4fc10100-5f7a-4470-899b-280835760c07',
'stats': None,
'title_history': None,
'title_id': '1739947436',
'type': 'Game',
'windows_phone_product_id': None,
'xbox_live_tier': 'Full',
}),
]),
})
# ---
@@ -357,24 +357,25 @@
# name: test_sensors[sensor.erics273_now_playing-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'achievements': None,
'developer': None,
'achievements': '57 / 121',
'developer': 'Mojang Studios',
<EntityStateAttribute.ENTITY_PICTURE: 'entity_picture'>: 'https://store-images.s-microsoft.com/image/apps.11144.13851379342944008.b2fc5ef4-8c3f-4b02-8c42-1e88e52dd0f1.6a2c9c4f-1a34-4a3f-9a2e-0f3a5a07a6bd',
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'erics273 Now playing',
'gamerscore': None,
'genres': None,
'min_age': None,
'platform': None,
'progress': None,
'publisher': None,
'release_date': None,
'short_description': None,
'gamerscore': '1105 / 2500',
'genres': 'Action & adventure, Family & kids',
'min_age': 7,
'platform': 'Xbox One',
'progress': '44 %',
'publisher': 'Xbox Game Studios',
'release_date': datetime.date(2017, 9, 19),
'short_description': 'Explore infinite worlds and build everything from the simplest of homes to the grandest of castles.',
}),
'context': <ANY>,
'entity_id': 'sensor.erics273_now_playing',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
'state': 'Minecraft',
})
# ---
# name: test_sensors[sensor.erics273_party_join_restrictions-entry]
@@ -484,7 +485,7 @@
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'Last seen 17h ago: Home',
'state': 'Minecraft',
})
# ---
# name: test_sensors[sensor.gsr_ae_followers-entry]