fix(media_player): ADB-health-aware _attr_available; fetch_media_info dispatches through _track_task (F2, F4)
This commit is contained in:
1 parent
9c409b3805
commit
75fff11d04
1 file changed
+14
-1
@@ -94,6 +94,7 @@ class NvidiaShieldMediaPlayer(MediaPlayerEntity):
|
|||||||
_attr_has_entity_name = True
|
_attr_has_entity_name = True
|
||||||
_attr_name = None
|
_attr_name = None
|
||||||
_attr_should_poll = False
|
_attr_should_poll = False
|
||||||
|
# Overridden as a property below: ADB-health aware
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None:
|
def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
@@ -121,6 +122,18 @@ class NvidiaShieldMediaPlayer(MediaPlayerEntity):
|
|||||||
# here directly.
|
# here directly.
|
||||||
self._entity_tasks: set = set()
|
self._entity_tasks: set = set()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def available(self) -> bool:
|
||||||
|
"""The bridge entities stay functional without ADB (passive manager).
|
||||||
|
|
||||||
|
Unavailable only while an active ADB manager is down — its data is
|
||||||
|
unreliable until the watchdog reconnects (t5-F2).
|
||||||
|
"""
|
||||||
|
manager = getattr(self._entry, "runtime_data", None)
|
||||||
|
if not isinstance(manager, ShieldConnectionManager):
|
||||||
|
return True
|
||||||
|
return manager.connected or manager.awake is not None or not manager.available
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _jellyfin_entity(self) -> str | None:
|
def _jellyfin_entity(self) -> str | None:
|
||||||
return self._entry.options.get(CONF_JELLYFIN_ENTITY) or None
|
return self._entry.options.get(CONF_JELLYFIN_ENTITY) or None
|
||||||
@@ -312,7 +325,7 @@ class NvidiaShieldMediaPlayer(MediaPlayerEntity):
|
|||||||
# Fetch media stream info when playing
|
# Fetch media stream info when playing
|
||||||
if new_jf in (STATE_PLAYING, STATE_PAUSED):
|
if new_jf in (STATE_PLAYING, STATE_PAUSED):
|
||||||
entity_picture = new_state_obj.attributes.get("entity_picture", "")
|
entity_picture = new_state_obj.attributes.get("entity_picture", "")
|
||||||
self.hass.async_create_task(
|
self._track_task(
|
||||||
self._fetch_media_info(entity_picture)
|
self._fetch_media_info(entity_picture)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in new issue
Block a user