I’m investigating a foreground-app detection problem with the built-in Android Debug Bridge integration on a Xiaomi Fire TV. While Netflix is playing, Home Assistant reports idle with no app_id or source.
A read-only comparison suggests the Fire TV command used by the installed androidtv library is incompatible with the window-dump output on this model. An ActivityManager-based command already included in the library correctly identifies Netflix and its playback state.
Environment
- Home Assistant Container 2026.8.3, running under CasaOS.
- Built-in Android Debug Bridge integration (
androidtv), not a custom integration. - Installed dependencies:
androidtv0.0.75,adb-shellrequirement 0.4.4. - Device model: AFTBR92D74; device/product: ginzaeu; Android version: 11.
- Integration device type:
auto; built-in Python ADB connection, no external ADB server. - Running-app retrieval enabled; unnamed apps not excluded; no custom state-detection rules.
- Last known working version: unknown. I have not reproduced this on a newer HA release yet.
Expected and actual behavior
During Netflix playback, I expect the entity to identify com.netflix.ninja and report playing.
Instead, HA reports idle, and the app/source attributes are absent. Direct ADB inspection shows Netflix’s activity resumed and an active Netflix media session with playback state 3 and speed 1.0.
HA has also logged an ADB read timeout. However, the command mismatch below is reproducible during a successful ADB connection. Disconnecting the diagnostic PC’s ADB session did not restore HA’s app detection during subsequent observation.
Reproduction and command comparison
With Netflix playing, inspect the media-player entity in Developer Tools → States. Then, from an authorised ADB shell on the TV, compare these read-only commands.
The window fields used by the library’s default Fire TV command:
dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'
On this device, this returned no output, with exit status 1. Running the library’s complete default app/media-session command also returned no output and exit status 1.
ActivityManager does expose the foreground app:
dumpsys activity a . | grep mResumedActivity
The output identifies com.netflix.ninja/.MainActivity.
The following is the library’s existing ActivityManager-based alternative for retrieving the app and media-session state. Run it inside the Android shell so the shell variables are expanded on the TV:
CURRENT_APP=$(dumpsys activity a . | grep mResumedActivity) &&
CURRENT_APP=${CURRENT_APP#*ActivityRecord{* * } &&
CURRENT_APP=${CURRENT_APP#*{* * } &&
CURRENT_APP=${CURRENT_APP%%/*} &&
CURRENT_APP=${CURRENT_APP%\}*} &&
echo "$CURRENT_APP" &&
dumpsys media_session | grep -A 100 'Sessions Stack' |
grep -A 100 "$CURRENT_APP" | grep -m 1 'state=PlaybackState {'
This succeeded with exit status 0. Relevant output, with unrelated fields omitted:
com.netflix.ninja
state=PlaybackState {state=3, ... speed=1.0, ...}
What the installed code shows
In androidtv/basetv/basetv.py, the Fire TV path falls back to CMD_CURRENT_APP_MEDIA_SESSION_STATE. Its initial window-field lookup is followed by &&, so an empty match prevents the subsequent app/media-session query from running.
In androidtv/firetv/base_firetv.py, _update() maps an unidentified current app (None) to idle. Its Netflix rules already map media-session state 3 to playing and 2 to paused.
Feeding the two observed outputs into the installed parser and state logic in a separate Python process produced:
Default query: app=None, session=None -> idle
Alternative query: app=com.netflix.ninja, session=3 -> playing
This suggests that adding Netflix-specific state rules alone would not resolve the missing app detection.
Possible compatibility fix and limitations
A local, undeployed patch selects the existing CMD_CURRENT_APP_GOOGLE_TV and CMD_CURRENT_APP_MEDIA_SESSION_STATE_GOOGLE_TV commands for Fire TV model AFTBR92D74 with Android version 11 only. The constant names refer to Google TV, but their ActivityManager query worked on this Fire TV during the comparison.
Isolated checks passed for that branch, four unaffected device configurations, and explicit command-override precedence. The patch has not been installed in the running HA container, so I am not claiming an end-to-end HA fix. Netflix playing was observed live; paused-state parsing was tested synthetically. Other apps, Home, standby, and reboot behavior still need testing.
For context, this TV has several telemetry/demo/optional Amazon packages disabled and its window animation scale is set to 0.5. The launcher, Settings and screensaver were deliberately preserved. This has not been reproduced on a freshly reset TV; no causal link to those changes has been established.
Has anyone with this model or a similar Fire TV build seen the same missing window fields? Is a model-specific ActivityManager fallback the right approach, and should this be reported to Home Assistant Core or the upstream python-androidtv project?
References: Android Debug Bridge integration, python-androidtv.