You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Android 14 Google TV: dumpsys … | grep -q writes "Broken pipe" into output → screen_on/awake misparsed, device reported off #373
Home Assistant 2026.10.1, androidtv integration (direct ADB, port 5555, no ADB server), device class auto
Problem
The media player is reported off (sometimes idle) while the TV is on and playing (Disney+ in foreground, media session PLAYING).
Cause CMD_SCREEN_ON_AWAKE_WAKE_LOCK_SIZE pipes dumpsys power into grep -q. grep -q exits on the first match, and on this firmware dumpsys then prints an error that ends up in the ADB shell output:
$ (dumpsys power | grep 'Display Power' | grep -q 'state=ON' || dumpsys power | grep -q 'mScreenOn=true' || dumpsys display | grep -q 'mScreenState=ON') && echo -n 1 || echo -n 0; dumpsys power | grep mWakefulness | grep -q Awake && echo -n 1 || echo -n 0; dumpsys power | grep Locks | grep 'size='
1Failed to write while dumping service power: Broken pipe
1Wake Locks: size=2
_screen_on_awake_wake_lock_size() reads output[1] as the awake flag. Here it is F, so awake=False. The device is then treated as off, and get_properties(lazy=True) skips the remaining properties. The message is timing-dependent, so the state flips between off and idle.
Each command on its own returns the correct values (screen on, mWakefulness=Awake, Wake Locks: size=2, media session state=PLAYING(3)).
Suggested fix
Send dumpsys stderr to /dev/null (e.g. dumpsys power 2>/dev/null | grep -q …) in the screen/awake/wake-lock commands, or avoid grep -q early exit (grep … > /dev/null). Either one keeps the error text out of the parsed output.
Confirming this on a second device: a TCL TV on Android 14 (Google TV launcher), with the Home Assistant androidtv integration (direct ADB, androidtv 0.0.75).
Here Display Power has no state= field and mScreenOn is missing, so CMD_SCREEN_ON falls through to dumpsys display | grep -q. That is the call that breaks the pipe. Output of CMD_SCREEN_ON_AWAKE_WAKE_LOCK_SIZE through Home Assistant's own ADB connection:
'Failed to write while dumping service display: Broken pipe\n10Wake Locks: size=1'
output[0] is F, so screen_on is False and the entity is always off. With 2>/dev/null after each dumpsys:
'10Wake Locks: size=1'
The entity then shows the real state. An Android 11 TV produces identical output with and without the redirect.
I opened a PR that adds the redirect to every dumpsys in constants.py and adds a test to keep it that way: #376
Activity
JordiRubio93 commentedon Oct 25, 2026
Confirming this on a second device: a TCL TV on Android 14 (Google TV launcher), with the Home Assistant
androidtvintegration (direct ADB, androidtv 0.0.75).Here
Display Powerhas nostate=field andmScreenOnis missing, soCMD_SCREEN_ONfalls through todumpsys display | grep -q. That is the call that breaks the pipe. Output ofCMD_SCREEN_ON_AWAKE_WAKE_LOCK_SIZEthrough Home Assistant's own ADB connection:output[0]isF, soscreen_onis False and the entity is alwaysoff. With2>/dev/nullafter eachdumpsys:The entity then shows the real state. An Android 11 TV produces identical output with and without the redirect.
I opened a PR that adds the redirect to every
dumpsysinconstants.pyand adds a test to keep it that way: #376Discard dumpsys stderr so "Broken pipe" does not corrupt parsed output