mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Improve Linkplay device unavailability detection (#138457)
* Dampen reachability changes Retry a few times before declaring player is unavailable * Fix ruff-format complaint Co-authored-by: Simon Lamon <32477463+silamon@users.noreply.github.com> * Fix ruff-format complaint Co-authored-by: Simon Lamon <32477463+silamon@users.noreply.github.com> * Fix ruff-format complaint Co-authored-by: Simon Lamon <32477463+silamon@users.noreply.github.com> * Fix duplicated change Co-authored-by: Simon Lamon <32477463+silamon@users.noreply.github.com> --------- Co-authored-by: Simon Lamon <32477463+silamon@users.noreply.github.com>
This commit is contained in:
parent
14e66ffef4
commit
23644a60ac
@ -125,6 +125,8 @@ SERVICE_PLAY_PRESET_SCHEMA = cv.make_entity_service_schema(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
RETRY_POLL_MAXIMUM = 3
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
@ -156,6 +158,7 @@ class LinkPlayMediaPlayerEntity(LinkPlayBaseEntity, MediaPlayerEntity):
|
|||||||
|
|
||||||
super().__init__(bridge)
|
super().__init__(bridge)
|
||||||
self._attr_unique_id = bridge.device.uuid
|
self._attr_unique_id = bridge.device.uuid
|
||||||
|
self._retry_count = 0
|
||||||
|
|
||||||
self._attr_source_list = [
|
self._attr_source_list = [
|
||||||
SOURCE_MAP[playing_mode] for playing_mode in bridge.device.playmode_support
|
SOURCE_MAP[playing_mode] for playing_mode in bridge.device.playmode_support
|
||||||
@ -166,9 +169,12 @@ class LinkPlayMediaPlayerEntity(LinkPlayBaseEntity, MediaPlayerEntity):
|
|||||||
"""Update the state of the media player."""
|
"""Update the state of the media player."""
|
||||||
try:
|
try:
|
||||||
await self._bridge.player.update_status()
|
await self._bridge.player.update_status()
|
||||||
|
self._retry_count = 0
|
||||||
self._update_properties()
|
self._update_properties()
|
||||||
except LinkPlayRequestException:
|
except LinkPlayRequestException:
|
||||||
self._attr_available = False
|
self._retry_count += 1
|
||||||
|
if self._retry_count >= RETRY_POLL_MAXIMUM:
|
||||||
|
self._attr_available = False
|
||||||
|
|
||||||
@exception_wrap
|
@exception_wrap
|
||||||
async def async_select_source(self, source: str) -> None:
|
async def async_select_source(self, source: str) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user