mirror of
https://github.com/home-assistant/core.git
synced 2025-07-11 23:37:18 +00:00
Migrate DuneHD to has entity name (#96568)
This commit is contained in:
parent
c34194d8e0
commit
4523105dee
@ -35,7 +35,7 @@ async def async_setup_entry(
|
|||||||
"""Add Dune HD entities from a config_entry."""
|
"""Add Dune HD entities from a config_entry."""
|
||||||
unique_id = entry.entry_id
|
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)
|
async_add_entities([DuneHDPlayerEntity(player, DEFAULT_NAME, unique_id)], True)
|
||||||
|
|
||||||
@ -43,6 +43,9 @@ async def async_setup_entry(
|
|||||||
class DuneHDPlayerEntity(MediaPlayerEntity):
|
class DuneHDPlayerEntity(MediaPlayerEntity):
|
||||||
"""Implementation of the Dune HD player."""
|
"""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:
|
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
|
||||||
@ -70,11 +73,6 @@ class DuneHDPlayerEntity(MediaPlayerEntity):
|
|||||||
state = MediaPlayerState.ON
|
state = MediaPlayerState.ON
|
||||||
return state
|
return state
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self) -> str:
|
|
||||||
"""Return the name of the device."""
|
|
||||||
return self._name
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
"""Return True if entity is available."""
|
"""Return True if entity is available."""
|
||||||
@ -91,7 +89,7 @@ class DuneHDPlayerEntity(MediaPlayerEntity):
|
|||||||
return DeviceInfo(
|
return DeviceInfo(
|
||||||
identifiers={(DOMAIN, self._unique_id)},
|
identifiers={(DOMAIN, self._unique_id)},
|
||||||
manufacturer=ATTR_MANUFACTURER,
|
manufacturer=ATTR_MANUFACTURER,
|
||||||
name=DEFAULT_NAME,
|
name=self._name,
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user