feat(media_player): app_id/app_name prefer the androidtv entity, fall back to the protocol current_app push when absent/unavailable; manifest androidtvremote2 floor aligned to >=0.2.0 (P3-1b,c)
This commit is contained in:
1 parent
d35b61078d
commit
34d09e9f70
3 files changed
+59
-6
No files matched your search
@@ -110,7 +110,7 @@ class NvidiaShieldMediaPlayer(MediaPlayerEntity):
|
||||
def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||
self.hass = hass
|
||||
self._entry = entry
|
||||
self._androidtv_entity = entry.data[CONF_ANDROIDTV_ENTITY]
|
||||
self._androidtv_entity = entry.data.get(CONF_ANDROIDTV_ENTITY, "")
|
||||
self._attr_unique_id = f"{DOMAIN}_{entry.entry_id}_media_player"
|
||||
self._unsub_listeners: list = []
|
||||
|
||||
@@ -489,13 +489,28 @@ class NvidiaShieldMediaPlayer(MediaPlayerEntity):
|
||||
|
||||
@property
|
||||
def app_id(self):
|
||||
atv = self._read(self._androidtv_entity)
|
||||
return atv.attributes.get("app_id") if atv else None
|
||||
"""Android TV entity first; standalone setups fall back to the
|
||||
protocol current-app push (raw package — both stamp the store)."""
|
||||
atv = self._read(self._androidtv_entity) if self._androidtv_entity else None
|
||||
if atv is not None:
|
||||
app_id = atv.attributes.get("app_id")
|
||||
if app_id:
|
||||
return app_id
|
||||
if self._manager is not None:
|
||||
return self._manager.current_app
|
||||
return None
|
||||
|
||||
@property
|
||||
def app_name(self):
|
||||
atv = self._read(self._androidtv_entity)
|
||||
return atv.attributes.get("app_name") if atv else None
|
||||
atv = self._read(self._androidtv_entity) if self._androidtv_entity else None
|
||||
if atv is not None:
|
||||
app_name = atv.attributes.get("app_name")
|
||||
if app_name:
|
||||
return app_name
|
||||
if self._manager is not None:
|
||||
# Name resolution is deferred app-map work; the package is truth.
|
||||
return self._manager.current_app
|
||||
return None
|
||||
|
||||
@property
|
||||
def media_content_type(self):
|
||||
|
||||
Reference in new issue
Block a user