From 00ecc108d107012d2884a031f9a09abf01e8a2eb Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Tue, 29 Aug 2023 13:08:24 +0200 Subject: [PATCH] Use shorthand attributes for DuneHD (#99237) --- .../components/dunehd/media_player.py | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/homeassistant/components/dunehd/media_player.py b/homeassistant/components/dunehd/media_player.py index c76a4b72e9a..4f6bf6fb677 100644 --- a/homeassistant/components/dunehd/media_player.py +++ b/homeassistant/components/dunehd/media_player.py @@ -49,10 +49,14 @@ class DuneHDPlayerEntity(MediaPlayerEntity): def __init__(self, player: DuneHDPlayer, name: str, unique_id: str) -> None: """Initialize entity to control Dune HD.""" self._player = player - self._name = name self._media_title: str | None = None 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: """Update internal status of the entity.""" @@ -78,20 +82,6 @@ class DuneHDPlayerEntity(MediaPlayerEntity): """Return True if entity is available.""" 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 def volume_level(self) -> float: """Return the volume level of the media player (0..1)."""