diff --git a/custom_components/nvidia_shield/sensor.py b/custom_components/nvidia_shield/sensor.py index f91dabf..d6c55e7 100644 --- a/custom_components/nvidia_shield/sensor.py +++ b/custom_components/nvidia_shield/sensor.py @@ -93,10 +93,13 @@ class NvidiaShieldCurrentAppSensor(NvidiaShieldSensorBase): self.async_write_ha_state() def _package(self) -> str | None: - """The raw foreground package from the manager's store (t41). + """The raw package of the app that is on screen (t41, t55). StateStore priority chain (P3-3c): protocol current_app push → ADB - mResumedActivity → ADB recents. + mResumedActivity (both via ``manager.foreground_app``) → the most + recent visible ADB recent task. The recents tier is a last resort for + a moment when neither live signal has reported yet; it keeps the + sensor from going None while ADB is still warming up. """ manager = self._manager() if manager is None: @@ -117,6 +120,13 @@ class NvidiaShieldCurrentAppSensor(NvidiaShieldSensorBase): ``resolve_app_name``: apps map → cached manifest label → the package text itself. A bare or unknown package shows its package text rather than None, like the media player's app_name. + + This is why ``_package`` must be the CURRENT app and the label fetch + must be driven off it (t55): the device-manifest label is resolved on + demand for exactly the package passed here, so a live run showing a + package id means the label tier never answered — see + ``ShieldConnectionManager.app_label`` for the caching rule that makes + a miss retry instead of being stamped as an eternal "no label". """ manager = self._manager() return resolve_app_name(