Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Increase Xbox update interval to 15 seconds and refactor title data handling#158780

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
joostlek merged 2 commits intohome-assistant:devfromtr4nt0r:xbox_rate_limit
Dec 12, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletionshomeassistant/components/xbox/coordinator.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -81,10 +81,11 @@ def __init__(
_LOGGER,
config_entry=config_entry,
name=DOMAIN,
update_interval=timedelta(seconds=10),
update_interval=timedelta(seconds=15),
)
self.data = XboxData()
self.current_friends: set[str] = set()
self.title_data: dict[str, Title] = {}

async def _async_setup(self) -> None:
"""Set up coordinator."""
Expand DownExpand Up@@ -217,7 +218,6 @@ async def _async_update_data(self) -> XboxData:
)

# retrieve title details
title_data: dict[str, Title] = {}
for person in presence_data.values():
if presence_detail := next(
(
Expand All@@ -227,6 +227,12 @@ async def _async_update_data(self) -> XboxData:
),
None,
):
if (
person.xuid in self.title_data
and presence_detail.title_id
== self.title_data[person.xuid].title_id
):
continue
try:
title = await self.client.titlehub.get_title_info(
presence_detail.title_id
Expand All@@ -250,7 +256,9 @@ async def _async_update_data(self) -> XboxData:
translation_domain=DOMAIN,
translation_key="request_exception",
) from e
title_data[person.xuid] = title.titles[0]
self.title_data[person.xuid] = title.titles[0]
else:
self.title_data.pop(person.xuid, None)
person.last_seen_date_time_utc = self.last_seen_timestamp(person)
if (
self.current_friends - (new_friends := set(presence_data))
Expand All@@ -259,7 +267,7 @@ async def _async_update_data(self) -> XboxData:
self.remove_stale_devices(new_friends)
self.current_friends = new_friends

return XboxData(new_console_data, presence_data, title_data)
return XboxData(new_console_data, presence_data,self.title_data)

def last_seen_timestamp(self, person: Person) -> datetime | None:
"""Returns the most recent of two timestamps."""
Expand Down
4 changes: 2 additions & 2 deletionstests/components/xbox/test_image.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -115,12 +115,12 @@ async def test_load_image_from_url(
"rgWHJigthrlsHCxEOMG9UGNdojCYasYt6MJHBjmxmtuAHJeo.sOkUiPmg4JHXvOS82c3UOrvdJTDaCKwCwHPJ0t0Plha8oHFC1i_o-&format=png"
).respond(status_code=HTTPStatus.OK,content_type="image/png",content=b"Test2")

freezer.tick(timedelta(seconds=10))
freezer.tick(timedelta(seconds=15))
async_fire_time_changed(hass)
awaithass.async_block_till_done()

assert (state:=hass.states.get("image.gsr_ae_gamerpic"))
assertstate.state=="2025-06-16T00:00:10+00:00"
assertstate.state=="2025-06-16T00:00:15+00:00"

access_token=state.attributes["access_token"]
assert (
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp