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 <noreply@anthropic.com>
This commit is contained in:
2026-02-07 12:26:44 +03:00
parent 8cbe33eb72
commit 02bdcc5d4b

View File

@@ -199,6 +199,10 @@ class MediaPlayerCoordinator(DataUpdateCoordinator[dict[str, Any]]):
# Re-enable polling as fallback # Re-enable polling as fallback
self.update_interval = timedelta(seconds=self._poll_interval) self.update_interval = timedelta(seconds=self._poll_interval)
_LOGGER.warning("WebSocket disconnected, falling back to polling") _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 # Schedule reconnect attempt
self._schedule_reconnect() self._schedule_reconnect()