1
mirror of https://github.com/home-assistant/core synced 2024-09-06 10:29:55 +02:00

Migrate Squeezebox to has entity name (#98948)

This commit is contained in:
Joost Lekkerkerker 2023-08-24 19:58:54 +02:00 committed by GitHub
parent be78169065
commit 480db1f1e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,7 +35,7 @@ from homeassistant.helpers import (
entity_platform,
)
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.device_registry import format_mac
from homeassistant.helpers.device_registry import DeviceInfo, format_mac
from homeassistant.helpers.dispatcher import (
async_dispatcher_connect,
async_dispatcher_send,
@ -236,6 +236,8 @@ class SqueezeBoxEntity(MediaPlayerEntity):
| MediaPlayerEntityFeature.GROUPING
| MediaPlayerEntityFeature.MEDIA_ENQUEUE
)
_attr_has_entity_name = True
_attr_name = None
def __init__(self, player):
"""Initialize the SqueezeBox device."""
@ -244,6 +246,10 @@ class SqueezeBoxEntity(MediaPlayerEntity):
self._query_result = {}
self._available = True
self._remove_dispatcher = None
self._attr_unique_id = format_mac(self._player.player_id)
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, self._attr_unique_id)}, name=self._player.name
)
@property
def extra_state_attributes(self):
@ -256,16 +262,6 @@ class SqueezeBoxEntity(MediaPlayerEntity):
return squeezebox_attr
@property
def name(self):
"""Return the name of the device."""
return self._player.name
@property
def unique_id(self):
"""Return a unique ID."""
return format_mac(self._player.player_id)
@property
def available(self):
"""Return True if device connected to LMS server."""