Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions homeassistant/components/xbox/api.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""API for xbox bound to Home Assistant OAuth."""

from xbox.webapi.authentication.manager import AuthenticationManager
from xbox.webapi.authentication.models import OAuth2TokenResponse
from xbox.webapi.common.signed_session import SignedSession
from pythonxbox.authentication.manager import AuthenticationManager
from pythonxbox.authentication.models import OAuth2TokenResponse
from pythonxbox.common.signed_session import SignedSession

from homeassistant.helpers.config_entry_oauth2_flow import OAuth2Session
from homeassistant.util.dt import utc_from_timestamp
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/xbox/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from enum import StrEnum
from typing import Any

from xbox.webapi.api.provider.people.models import Person
from xbox.webapi.api.provider.titlehub.models import Title
from pythonxbox.api.provider.people.models import Person
from pythonxbox.api.provider.titlehub.models import Title

from homeassistant.components.binary_sensor import (
DOMAIN as BINARY_SENSOR_DOMAIN,
Expand Down
14 changes: 7 additions & 7 deletions homeassistant/components/xbox/browse_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

from typing import NamedTuple

from xbox.webapi.api.client import XboxLiveClient
from xbox.webapi.api.provider.catalog.const import HOME_APP_IDS, SYSTEM_PFN_ID_MAP
from xbox.webapi.api.provider.catalog.models import (
from pythonxbox.api.client import XboxLiveClient
from pythonxbox.api.provider.catalog.const import HOME_APP_IDS, SYSTEM_PFN_ID_MAP
from pythonxbox.api.provider.catalog.models import (
AlternateIdType,
CatalogResponse,
FieldsTemplate,
Image,
)
from xbox.webapi.api.provider.smartglass.models import (
from pythonxbox.api.provider.smartglass.models import (
InstalledPackage,
InstalledPackagesList,
)
Expand Down Expand Up @@ -157,17 +157,17 @@ async def build_item_response(
def item_payload(item: InstalledPackage, images: dict[str, list[Image]]):
"""Create response payload for a single media item."""
thumbnail = None
image = _find_media_image(images.get(item.one_store_product_id, []))
image = _find_media_image(images.get(item.one_store_product_id, [])) # type: ignore[arg-type]
if image is not None:
thumbnail = image.uri
if thumbnail[0] == "/":
thumbnail = f"https:{thumbnail}"

return BrowseMedia(
media_class=TYPE_MAP[item.content_type].cls,
media_content_id=item.one_store_product_id,
media_content_id=item.one_store_product_id, # type: ignore[arg-type]
media_content_type=TYPE_MAP[item.content_type].type,
title=item.name,
title=item.name, # type: ignore[arg-type]
can_play=True,
can_expand=False,
thumbnail=thumbnail,
Expand Down
10 changes: 5 additions & 5 deletions homeassistant/components/xbox/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import logging
from typing import Any

from xbox.webapi.api.client import XboxLiveClient
from xbox.webapi.authentication.manager import AuthenticationManager
from xbox.webapi.authentication.models import OAuth2TokenResponse
from xbox.webapi.common.signed_session import SignedSession
from pythonxbox.api.client import XboxLiveClient
from pythonxbox.authentication.manager import AuthenticationManager
from pythonxbox.authentication.models import OAuth2TokenResponse
from pythonxbox.common.signed_session import SignedSession

from homeassistant.config_entries import ConfigFlowResult
from homeassistant.helpers import config_entry_oauth2_flow
Expand Down Expand Up @@ -54,7 +54,7 @@ async def async_oauth_create_entry(self, data: dict) -> ConfigFlowResult:

client = XboxLiveClient(auth)

me = await client.people.get_friends_own_batch([client.xuid])
me = await client.people.get_friends_by_xuid(client.xuid)

await self.async_set_unique_id(client.xuid)
return self.async_create_entry(title=me.people[0].gamertag, data=data)
19 changes: 10 additions & 9 deletions homeassistant/components/xbox/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,23 @@
import logging

from httpx import HTTPStatusError, RequestError, TimeoutException
from xbox.webapi.api.client import XboxLiveClient
from xbox.webapi.api.provider.catalog.const import SYSTEM_PFN_ID_MAP
from xbox.webapi.api.provider.catalog.models import AlternateIdType, Product
from xbox.webapi.api.provider.people.models import Person
from xbox.webapi.api.provider.smartglass.models import (
from pythonxbox.api.client import XboxLiveClient
from pythonxbox.api.provider.catalog.const import SYSTEM_PFN_ID_MAP
from pythonxbox.api.provider.catalog.models import AlternateIdType, Product
from pythonxbox.api.provider.people.models import Person
from pythonxbox.api.provider.smartglass.models import (
SmartglassConsoleList,
SmartglassConsoleStatus,
)
from xbox.webapi.api.provider.titlehub.models import Title
from xbox.webapi.common.signed_session import SignedSession
from pythonxbox.api.provider.titlehub.models import Title
from pythonxbox.common.signed_session import SignedSession

from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import config_entry_oauth2_flow, device_registry as dr
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from homeassistant.util.ssl import get_default_context

from . import api
from .const import DOMAIN
Expand Down Expand Up @@ -90,7 +91,7 @@ async def _async_setup(self) -> None:
session = config_entry_oauth2_flow.OAuth2Session(
self.hass, self.config_entry, implementation
)
signed_session = await self.hass.async_add_executor_job(SignedSession)
signed_session = SignedSession(ssl_context=get_default_context())
auth = api.AsyncConfigEntryAuth(signed_session, session)
self.client = XboxLiveClient(auth)

Expand Down Expand Up @@ -183,7 +184,7 @@ async def _async_update_data(self) -> XboxData:

# Update user presence
try:
batch = await self.client.people.get_friends_own_batch([self.client.xuid])
batch = await self.client.people.get_friends_by_xuid(self.client.xuid)
friends = await self.client.people.get_friends_own()
except TimeoutException as e:
raise UpdateFailed(
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/xbox/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from dataclasses import dataclass
from typing import Any

from xbox.webapi.api.provider.people.models import Person
from xbox.webapi.api.provider.smartglass.models import ConsoleType, SmartglassConsole
from xbox.webapi.api.provider.titlehub.models import Title
from pythonxbox.api.provider.people.models import Person
from pythonxbox.api.provider.smartglass.models import ConsoleType, SmartglassConsole
from pythonxbox.api.provider.titlehub.models import Title
from yarl import URL

from homeassistant.components.automation import automations_with_entity
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/xbox/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from dataclasses import dataclass
from enum import StrEnum

from xbox.webapi.api.provider.people.models import Person
from xbox.webapi.api.provider.titlehub.models import Title
from pythonxbox.api.provider.people.models import Person
from pythonxbox.api.provider.titlehub.models import Title

from homeassistant.components.image import ImageEntity, ImageEntityDescription
from homeassistant.core import HomeAssistant, callback
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/xbox/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"documentation": "https://www.home-assistant.io/integrations/xbox",
"iot_class": "cloud_polling",
"requirements": ["xbox-webapi==2.1.0"],
"requirements": ["python-xbox==0.1.0"],
"ssdp": [
{
"manufacturer": "Microsoft Corporation",
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/xbox/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from typing import Any

from xbox.webapi.api.provider.catalog.models import Image
from xbox.webapi.api.provider.smartglass.models import (
from pythonxbox.api.provider.catalog.models import Image
from pythonxbox.api.provider.smartglass.models import (
PlaybackState,
PowerState,
VolumeDirection,
Expand Down
18 changes: 9 additions & 9 deletions homeassistant/components/xbox/media_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
from dataclasses import dataclass

from pydantic import ValidationError
from xbox.webapi.api.client import XboxLiveClient
from xbox.webapi.api.provider.catalog.models import FieldsTemplate, Image
from xbox.webapi.api.provider.gameclips.models import GameclipsResponse
from xbox.webapi.api.provider.screenshots.models import ScreenshotResponse
from xbox.webapi.api.provider.smartglass.models import InstalledPackage
from pythonxbox.api.client import XboxLiveClient
from pythonxbox.api.provider.catalog.models import FieldsTemplate, Image
from pythonxbox.api.provider.gameclips.models import GameclipsResponse
from pythonxbox.api.provider.screenshots.models import ScreenshotResponse
from pythonxbox.api.provider.smartglass.models import InstalledPackage

from homeassistant.components.media_player import MediaClass
from homeassistant.components.media_source import (
Expand Down Expand Up @@ -149,9 +149,9 @@ async def _build_media_items(self, title, category):
items = [
XboxMediaItem(
item.user_caption
or dt_util.as_local(
dt_util.parse_datetime(item.date_recorded)
).strftime("%b. %d, %Y %I:%M %p"),
or dt_util.as_local(item.date_recorded).strftime(
"%b. %d, %Y %I:%M %p"
),
item.thumbnails[0].uri,
item.game_clip_uris[0].uri,
MediaClass.VIDEO,
Expand Down Expand Up @@ -201,7 +201,7 @@ async def _build_media_items(self, title, category):
def _build_game_item(item: InstalledPackage, images: dict[str, list[Image]]):
"""Build individual game."""
thumbnail = ""
image = _find_media_image(images.get(item.one_store_product_id, []))
image = _find_media_image(images.get(item.one_store_product_id, [])) # type: ignore[arg-type]
if image is not None:
thumbnail = image.uri
if thumbnail[0] == "/":
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/xbox/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from collections.abc import Iterable
from typing import Any

from xbox.webapi.api.provider.smartglass.models import InputKeyType, PowerState
from pythonxbox.api.provider.smartglass.models import InputKeyType, PowerState

from homeassistant.components.remote import (
ATTR_DELAY_SECS,
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/xbox/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from enum import StrEnum
from typing import Any

from xbox.webapi.api.provider.people.models import Person
from xbox.webapi.api.provider.titlehub.models import Title
from pythonxbox.api.provider.people.models import Person
from pythonxbox.api.provider.titlehub.models import Title

from homeassistant.components.sensor import (
DOMAIN as SENSOR_DOMAIN,
Expand Down
6 changes: 3 additions & 3 deletions requirements_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions requirements_test_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion script/licenses.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ def from_dict(cls, data: PackageMetadata) -> PackageDefinition:
"0.12.3"
), # https://github.com/aio-libs/aiocache/blob/master/LICENSE all rights reserved?
"caldav": AwesomeVersion("1.6.0"), # None -- GPL -- ['GNU General Public License (GPL)', 'Apache Software License'] # https://github.com/python-caldav/caldav
"xbox-webapi": AwesomeVersion("2.1.0"), # None -- GPL -- ['MIT License']
}
# fmt: on

Expand Down
10 changes: 5 additions & 5 deletions tests/components/xbox/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
from unittest.mock import AsyncMock, patch

import pytest
from xbox.webapi.api.provider.catalog.models import CatalogResponse
from xbox.webapi.api.provider.people.models import PeopleResponse
from xbox.webapi.api.provider.smartglass.models import (
from pythonxbox.api.provider.catalog.models import CatalogResponse
from pythonxbox.api.provider.people.models import PeopleResponse
from pythonxbox.api.provider.smartglass.models import (
SmartglassConsoleList,
SmartglassConsoleStatus,
)
from xbox.webapi.api.provider.titlehub.models import TitleHubResponse
from pythonxbox.api.provider.titlehub.models import TitleHubResponse

from homeassistant.components.application_credentials import (
ClientCredential,
Expand Down Expand Up @@ -130,7 +130,7 @@ def mock_xbox_live_client(signed_session) -> Generator[AsyncMock]:
)

client.people = AsyncMock()
client.people.get_friends_own_batch.return_value = PeopleResponse(
client.people.get_friends_by_xuid.return_value = PeopleResponse(
**load_json_object_fixture("people_batch.json", DOMAIN)
)
client.people.get_friends_own.return_value = PeopleResponse(
Expand Down
Loading
Loading