Use shorthand attributes for DuneHD (#99237)

This commit is contained in:
Joost Lekkerkerker 2023-08-29 13:08:24 +02:00 committed by GitHub
parent 750cfeb76a
commit 00ecc108d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -49,10 +49,14 @@ class DuneHDPlayerEntity(MediaPlayerEntity):
def __init__(self, player: DuneHDPlayer, name: str, unique_id: str) -> None: def __init__(self, player: DuneHDPlayer, name: str, unique_id: str) -> None:
"""Initialize entity to control Dune HD.""" """Initialize entity to control Dune HD."""
self._player = player self._player = player
self._name = name
self._media_title: str | None = None self._media_title: str | None = None
self._state: dict[str, Any] = {} self._state: dict[str, Any] = {}
self._unique_id = unique_id self._attr_unique_id = unique_id
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, unique_id)},
manufacturer=ATTR_MANUFACTURER,
name=name,
)
def update(self) -> None: def update(self) -> None:
"""Update internal status of the entity.""" """Update internal status of the entity."""
@ -78,20 +82,6 @@ class DuneHDPlayerEntity(MediaPlayerEntity):
"""Return True if entity is available.""" """Return True if entity is available."""
return len(self._state) > 0 return len(self._state) > 0
@property
def unique_id(self) -> str:
"""Return a unique_id for this entity."""
return self._unique_id
@property
def device_info(self) -> DeviceInfo:
"""Return the device info."""
return DeviceInfo(
identifiers={(DOMAIN, self._unique_id)},
manufacturer=ATTR_MANUFACTURER,
name=self._name,
)
@property @property
def volume_level(self) -> float: def volume_level(self) -> float:
"""Return the volume level of the media player (0..1).""" """Return the volume level of the media player (0..1)."""