Skip to content
Snippets Groups Projects
Unverified Commit 638bd743 authored by epenet's avatar epenet Committed by GitHub
Browse files

Use DeviceInfo in xbox (#58640)

parent 42a2aed8
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@ from __future__ import annotations
from yarl import URL
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from . import PresenceData, XboxUpdateCoordinator
......@@ -66,12 +67,12 @@ class XboxBaseSensorEntity(CoordinatorEntity):
return self.attribute == "online"
@property
def device_info(self):
def device_info(self) -> DeviceInfo:
"""Return a device description for device registry."""
return {
"identifiers": {(DOMAIN, "xbox_live")},
"name": "Xbox Live",
"manufacturer": "Microsoft",
"model": "Xbox Live",
"entry_type": "service",
}
return DeviceInfo(
entry_type="service",
identifiers={(DOMAIN, "xbox_live")},
manufacturer="Microsoft",
model="Xbox Live",
name="Xbox Live",
)
......@@ -29,6 +29,7 @@ from homeassistant.components.media_player.const import (
SUPPORT_VOLUME_STEP,
)
from homeassistant.const import STATE_OFF, STATE_ON, STATE_PAUSED, STATE_PLAYING
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from . import ConsoleData, XboxUpdateCoordinator
......@@ -213,21 +214,20 @@ class XboxMediaPlayer(CoordinatorEntity, MediaPlayerEntity):
await self.client.smartglass.launch_app(self._console.id, media_id)
@property
def device_info(self):
def device_info(self) -> DeviceInfo:
"""Return a device description for device registry."""
# Turns "XboxOneX" into "Xbox One X" for display
matches = re.finditer(
".+?(?:(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|$)",
self._console.console_type,
)
model = " ".join([m.group(0) for m in matches])
return {
"identifiers": {(DOMAIN, self._console.id)},
"name": self._console.name,
"manufacturer": "Microsoft",
"model": model,
}
return DeviceInfo(
identifiers={(DOMAIN, self._console.id)},
manufacturer="Microsoft",
model=" ".join([m.group(0) for m in matches]),
name=self._console.name,
)
def _find_media_image(images: list[Image]) -> Image | None:
......
......@@ -20,6 +20,7 @@ from homeassistant.components.remote import (
DEFAULT_DELAY_SECS,
RemoteEntity,
)
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from . import ConsoleData, XboxUpdateCoordinator
......@@ -98,18 +99,17 @@ class XboxRemote(CoordinatorEntity, RemoteEntity):
await asyncio.sleep(delay)
@property
def device_info(self):
def device_info(self) -> DeviceInfo:
"""Return a device description for device registry."""
# Turns "XboxOneX" into "Xbox One X" for display
matches = re.finditer(
".+?(?:(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|$)",
self._console.console_type,
)
model = " ".join([m.group(0) for m in matches])
return {
"identifiers": {(DOMAIN, self._console.id)},
"name": self._console.name,
"manufacturer": "Microsoft",
"model": model,
}
return DeviceInfo(
identifiers={(DOMAIN, self._console.id)},
manufacturer="Microsoft",
model=" ".join([m.group(0) for m in matches]),
name=self._console.name,
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment