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:
@@ -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()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user