From 02bdcc5d4bda9b8647434621303a5e77acf38fcf Mon Sep 17 00:00:00 2001 From: "alexei.dolgolyov" Date: Sat, 7 Feb 2026 12:26:44 +0300 Subject: [PATCH] Fix entity not becoming unavailable on server shutdown Trigger async_request_refresh() on WebSocket disconnect to restart the polling loop. Without this, the coordinator's polling stays stopped and last_update_success is never set to False. Co-Authored-By: Claude Opus 4.6 --- custom_components/remote_media_player/media_player.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/custom_components/remote_media_player/media_player.py b/custom_components/remote_media_player/media_player.py index fed627a..f8722f2 100644 --- a/custom_components/remote_media_player/media_player.py +++ b/custom_components/remote_media_player/media_player.py @@ -199,6 +199,10 @@ class MediaPlayerCoordinator(DataUpdateCoordinator[dict[str, Any]]): # Re-enable polling as fallback self.update_interval = timedelta(seconds=self._poll_interval) _LOGGER.warning("WebSocket disconnected, falling back to polling") + # Trigger an immediate refresh to restart the polling loop. + # Without this, the polling loop stays stopped (it was disabled when + # WebSocket was active) and the entity never becomes unavailable. + self.hass.async_create_task(self.async_request_refresh()) # Schedule reconnect attempt self._schedule_reconnect()