mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 00:37:13 +00:00
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>
This commit is contained in:
parent
5f27e2fe01
commit
09eff3c242
@ -38,6 +38,7 @@ from homeassistant.const import (
|
|||||||
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
import homeassistant.helpers.config_validation as cv
|
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.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.event import async_track_time_interval
|
from homeassistant.helpers.event import async_track_time_interval
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
@ -210,7 +211,6 @@ class BluesoundPlayer(MediaPlayerEntity):
|
|||||||
self._polling_task = None # The actual polling task.
|
self._polling_task = None # The actual polling task.
|
||||||
self._name = name
|
self._name = name
|
||||||
self._id = None
|
self._id = None
|
||||||
self._icon = None
|
|
||||||
self._capture_items = []
|
self._capture_items = []
|
||||||
self._services_items = []
|
self._services_items = []
|
||||||
self._preset_items = []
|
self._preset_items = []
|
||||||
@ -258,8 +258,6 @@ class BluesoundPlayer(MediaPlayerEntity):
|
|||||||
self._id = self._sync_status.get("@id", None)
|
self._id = self._sync_status.get("@id", None)
|
||||||
if not self._bluesound_device_name:
|
if not self._bluesound_device_name:
|
||||||
self._bluesound_device_name = self._sync_status.get("@name", self.host)
|
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:
|
if (master := self._sync_status.get("master")) is not None:
|
||||||
self._is_master = False
|
self._is_master = False
|
||||||
@ -449,6 +447,11 @@ class BluesoundPlayer(MediaPlayerEntity):
|
|||||||
_LOGGER.info("Client connection error, marking %s as offline", self._name)
|
_LOGGER.info("Client connection error, marking %s as offline", self._name)
|
||||||
raise
|
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):
|
async def async_trigger_sync_on_all(self):
|
||||||
"""Trigger sync status update on all devices."""
|
"""Trigger sync status update on all devices."""
|
||||||
_LOGGER.debug("Trigger sync status 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 the device name as returned by the device."""
|
||||||
return self._bluesound_device_name
|
return self._bluesound_device_name
|
||||||
|
|
||||||
@property
|
|
||||||
def icon(self):
|
|
||||||
"""Return the icon of the device."""
|
|
||||||
return self._icon
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source_list(self):
|
def source_list(self):
|
||||||
"""List of available input sources."""
|
"""List of available input sources."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user