Use shorthand attributes in Openhome (#99629)

This commit is contained in:
Joost Lekkerkerker 2023-09-05 14:57:26 +02:00 committed by GitHub
parent 582eeea082
commit d5ad01ffbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 21 deletions

View File

@ -102,26 +102,23 @@ def catch_request_errors() -> (
class OpenhomeDevice(MediaPlayerEntity): class OpenhomeDevice(MediaPlayerEntity):
"""Representation of an Openhome device.""" """Representation of an Openhome device."""
_attr_supported_features = SUPPORT_OPENHOME
_attr_state = MediaPlayerState.PLAYING
_attr_available = True
def __init__(self, hass, device): def __init__(self, hass, device):
"""Initialise the Openhome device.""" """Initialise the Openhome device."""
self.hass = hass self.hass = hass
self._device = device self._device = device
self._attr_unique_id = device.uuid() self._attr_unique_id = device.uuid()
self._attr_supported_features = SUPPORT_OPENHOME
self._source_index = {} self._source_index = {}
self._attr_state = MediaPlayerState.PLAYING self._attr_device_info = DeviceInfo(
self._attr_available = True
@property
def device_info(self):
"""Return a device description for device registry."""
return DeviceInfo(
identifiers={ identifiers={
(DOMAIN, self._device.uuid()), (DOMAIN, device.uuid()),
}, },
manufacturer=self._device.manufacturer(), manufacturer=device.manufacturer(),
model=self._device.model_name(), model=device.model_name(),
name=self._device.friendly_name(), name=device.friendly_name(),
) )
async def async_update(self) -> None: async def async_update(self) -> None:

View File

@ -54,17 +54,13 @@ class OpenhomeUpdateEntity(UpdateEntity):
"""Initialize a Linn DS update entity.""" """Initialize a Linn DS update entity."""
self._device = device self._device = device
self._attr_unique_id = f"{device.uuid()}-update" self._attr_unique_id = f"{device.uuid()}-update"
self._attr_device_info = DeviceInfo(
@property
def device_info(self):
"""Return a device description for device registry."""
return DeviceInfo(
identifiers={ identifiers={
(DOMAIN, self._device.uuid()), (DOMAIN, device.uuid()),
}, },
manufacturer=self._device.manufacturer(), manufacturer=device.manufacturer(),
model=self._device.model_name(), model=device.model_name(),
name=self._device.friendly_name(), name=device.friendly_name(),
) )
async def async_update(self) -> None: async def async_update(self) -> None: