Add Bluesound unique id (#80559)

* add unique_id & device_info

* remove broken image

* use a combination of mac and port (for multizone devices)

* use the typed dataclass

Co-authored-by: Mick Vleeshouwer <mick@imick.nl>

* Don't use get

* fix device_info

* remove device_info

Co-authored-by: Mick Vleeshouwer <mick@imick.nl>
pull/80728/head
Fredrik Erlandsson 2022-10-21 12:27:31 +02:00 committed by GitHub
parent 5f27e2fe01
commit 09eff3c242
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 8 deletions

View File

@ -38,6 +38,7 @@ from homeassistant.const import (
from homeassistant.core import HomeAssistant, ServiceCall, callback
from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.device_registry import format_mac
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
@ -210,7 +211,6 @@ class BluesoundPlayer(MediaPlayerEntity):
self._polling_task = None # The actual polling task.
self._name = name
self._id = None
self._icon = None
self._capture_items = []
self._services_items = []
self._preset_items = []
@ -258,8 +258,6 @@ class BluesoundPlayer(MediaPlayerEntity):
self._id = self._sync_status.get("@id", None)
if not self._bluesound_device_name:
self._bluesound_device_name = self._sync_status.get("@name", self.host)
if not self._icon:
self._icon = self._sync_status.get("@icon", self.host)
if (master := self._sync_status.get("master")) is not None:
self._is_master = False
@ -449,6 +447,11 @@ class BluesoundPlayer(MediaPlayerEntity):
_LOGGER.info("Client connection error, marking %s as offline", self._name)
raise
@property
def unique_id(self):
"""Return an unique ID."""
return f"{format_mac(self._sync_status['@mac'])}-{self.port}"
async def async_trigger_sync_on_all(self):
"""Trigger sync status update on all devices."""
_LOGGER.debug("Trigger sync status on all devices")
@ -678,11 +681,6 @@ class BluesoundPlayer(MediaPlayerEntity):
"""Return the device name as returned by the device."""
return self._bluesound_device_name
@property
def icon(self):
"""Return the icon of the device."""
return self._icon
@property
def source_list(self):
"""List of available input sources."""