From 5b2c65310439d1b118a520c59a24971bfd1d85fa Mon Sep 17 00:00:00 2001 From: "alexei.dolgolyov" Date: Tue, 3 Feb 2026 05:20:02 +0300 Subject: [PATCH] Revert "Reduce unnecessary state refreshes to prevent UI dialog closure" This reverts commit 8419b0de8cf98ea2a9e8eba836d230b41776154d. --- custom_components/emby_player/coordinator.py | 16 ++++++++-------- custom_components/emby_player/media_player.py | 3 +-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/custom_components/emby_player/coordinator.py b/custom_components/emby_player/coordinator.py index 1d825e5..6b190ad 100644 --- a/custom_components/emby_player/coordinator.py +++ b/custom_components/emby_player/coordinator.py @@ -161,16 +161,16 @@ class EmbyCoordinator(DataUpdateCoordinator[dict[str, EmbySession]]): sessions = self._parse_sessions(data) self.async_set_updated_data(sessions) - elif message_type in (WS_MESSAGE_PLAYBACK_START, WS_MESSAGE_PLAYBACK_STOP): - # Playback started or stopped - refresh to get full state + elif message_type in ( + WS_MESSAGE_PLAYBACK_START, + WS_MESSAGE_PLAYBACK_STOP, + WS_MESSAGE_PLAYBACK_PROGRESS, + ): + # Individual session update - trigger a refresh to get full state + # We could optimize this by updating only the affected session, + # but a full refresh ensures consistency self.hass.async_create_task(self.async_request_refresh()) - elif message_type == WS_MESSAGE_PLAYBACK_PROGRESS: - # Progress updates are frequent - don't trigger full refresh - # to avoid UI flicker. Regular polling will update position. - # We could extract position from the message here if needed. - pass - async def _async_update_data(self) -> dict[str, EmbySession]: """Fetch sessions from Emby API (polling fallback).""" try: diff --git a/custom_components/emby_player/media_player.py b/custom_components/emby_player/media_player.py index 13f1fae..8907e5b 100644 --- a/custom_components/emby_player/media_player.py +++ b/custom_components/emby_player/media_player.py @@ -404,8 +404,7 @@ class EmbyMediaPlayer(CoordinatorEntity[EmbyCoordinator], MediaPlayerEntity): self._session_id, item_ids=[media_id], ) - # Don't refresh immediately - WebSocket will send PlaybackStart event, - # or polling will update state. Immediate refresh can close UI dialogs. + await self.coordinator.async_request_refresh() async def async_browse_media( self,