Migrate DuneHD to has entity name (#96568)

pull/96721/head
Joost Lekkerkerker 2023-07-16 22:37:12 +02:00 committed by GitHub
parent c34194d8e0
commit 4523105dee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 7 deletions

View File

@ -35,7 +35,7 @@ async def async_setup_entry(
"""Add Dune HD entities from a config_entry."""
unique_id = entry.entry_id
player: str = hass.data[DOMAIN][entry.entry_id]
player: DuneHDPlayer = hass.data[DOMAIN][entry.entry_id]
async_add_entities([DuneHDPlayerEntity(player, DEFAULT_NAME, unique_id)], True)
@ -43,6 +43,9 @@ async def async_setup_entry(
class DuneHDPlayerEntity(MediaPlayerEntity):
"""Implementation of the Dune HD player."""
_attr_has_entity_name = True
_attr_name = None
def __init__(self, player: DuneHDPlayer, name: str, unique_id: str) -> None:
"""Initialize entity to control Dune HD."""
self._player = player
@ -70,11 +73,6 @@ class DuneHDPlayerEntity(MediaPlayerEntity):
state = MediaPlayerState.ON
return state
@property
def name(self) -> str:
"""Return the name of the device."""
return self._name
@property
def available(self) -> bool:
"""Return True if entity is available."""
@ -91,7 +89,7 @@ class DuneHDPlayerEntity(MediaPlayerEntity):
return DeviceInfo(
identifiers={(DOMAIN, self._unique_id)},
manufacturer=ATTR_MANUFACTURER,
name=DEFAULT_NAME,
name=self._name,
)
@property