From 85e96f3c607ab7e8247a057c9c0f4f29744a38f3 Mon Sep 17 00:00:00 2001 From: James Mackay Date: Mon, 12 Oct 2026 06:53:13 +0100 Subject: [PATCH] docs(sensor): name where the Current App name chain comes from (t55) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Current App sensor already resolved through the shared `resolve_app_name` chain, so the package-id live symptom was never a missing tier — it was the label path being silenced (fix in the previous commit). Its docstrings now say so explicitly: `_package` is the app on screen (protocol push → ADB mResumedActivity → recents as a last resort) and `native_value` resolves exactly that package's map entry or cached device label, which is why the label fetch must be driven off it. The behaviour is unchanged; the comment is what was missing. --- custom_components/nvidia_shield/sensor.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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(