mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Address System Bridge post merge review (#101614)
Address Post Merged PR Review for #97532
This commit is contained in:
parent
b8b28e3ba0
commit
e406b8d1e3
@ -54,6 +54,15 @@ MEDIA_SET_REPEAT_MAP: Final[dict[RepeatMode, int]] = {
|
|||||||
RepeatMode.ALL: 2,
|
RepeatMode.ALL: 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MEDIA_PLAYER_DESCRIPTION: Final[
|
||||||
|
MediaPlayerEntityDescription
|
||||||
|
] = MediaPlayerEntityDescription(
|
||||||
|
key="media",
|
||||||
|
translation_key="media",
|
||||||
|
icon="mdi:volume-high",
|
||||||
|
device_class=MediaPlayerDeviceClass.RECEIVER,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
@ -62,19 +71,14 @@ async def async_setup_entry(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Set up System Bridge media players based on a config entry."""
|
"""Set up System Bridge media players based on a config entry."""
|
||||||
coordinator: SystemBridgeDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
coordinator: SystemBridgeDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
||||||
data: SystemBridgeCoordinatorData = coordinator.data
|
data = coordinator.data
|
||||||
|
|
||||||
if data.media is not None:
|
if data.media is not None:
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
[
|
[
|
||||||
SystemBridgeMediaPlayer(
|
SystemBridgeMediaPlayer(
|
||||||
coordinator,
|
coordinator,
|
||||||
MediaPlayerEntityDescription(
|
MEDIA_PLAYER_DESCRIPTION,
|
||||||
key="media",
|
|
||||||
translation_key="media",
|
|
||||||
icon="mdi:volume-high",
|
|
||||||
device_class=MediaPlayerDeviceClass.RECEIVER,
|
|
||||||
),
|
|
||||||
entry.data[CONF_PORT],
|
entry.data[CONF_PORT],
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
@ -103,7 +107,7 @@ class SystemBridgeMediaPlayer(SystemBridgeEntity, MediaPlayerEntity):
|
|||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
"""Return True if entity is available."""
|
"""Return True if entity is available."""
|
||||||
return self.coordinator.data.media is not None
|
return super().available and self.coordinator.data.media is not None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> MediaPlayerEntityFeature:
|
def supported_features(self) -> MediaPlayerEntityFeature:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user