core: Android TV: Currently running app parsing broken
The problem
The new androidtv integration update has made my Nvidia Shield always report back the app playing as “InputMethod}:”. It also misses state detection rules.
What version of Home Assistant Core has the issue?
core-2022.4.1
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
androidtv
Link to integration documentation on our website
https://www.home-assistant.io/integrations/androidtv/
Diagnostics information
{
"home_assistant": {
"installation_type": "Home Assistant OS",
"version": "2022.4.1",
"dev": false,
"hassio": true,
"virtualenv": false,
"python_version": "3.9.9",
"docker": true,
"arch": "x86_64",
"timezone": "America/Chicago",
"os_name": "Linux",
"os_version": "5.10.108",
"supervisor": "2022.03.5",
"host_os": "Home Assistant OS 7.6",
"docker_version": "20.10.9",
"chassis": "vm",
"run_as_root": true
},
"custom_components": {
"holidays": {
"version": "1.7.2",
"requirements": [
"python-dateutil>=2.8.2",
"holidays>=0.13"
]
},
"pirateweather": {
"version": "0.1.0",
"requirements": [
"python-forecastio==1.4.0"
]
},
"google_home": {
"version": "1.9.10",
"requirements": [
"glocaltokens==0.6.3",
"google-api-python-client==2.38.0"
]
},
"spotcast": {
"version": "v3.6.27",
"requirements": [
"spotify_token==1.0.0"
]
},
"localtuya": {
"version": "3.2.1",
"requirements": []
},
"nodered": {
"version": "1.0.7",
"requirements": []
},
"hacs": {
"version": "1.24.3",
"requirements": [
"aiogithubapi>=21.11.0"
]
},
"adaptive_lighting": {
"version": "1.0.14",
"requirements": []
}
},
"integration_manifest": {
"domain": "androidtv",
"name": "Android TV",
"documentation": "https://www.home-assistant.io/integrations/androidtv",
"requirements": [
"adb-shell[async]==0.4.2",
"androidtv[async]==0.0.66",
"pure-python-adb[async]==0.3.0.dev0"
],
"codeowners": [
"@JeffLIrion",
"@ollo69"
],
"config_flow": true,
"iot_class": "local_polling",
"loggers": [
"adb_shell",
"androidtv",
"pure_python_adb"
],
"is_built_in": true
},
"data": {
"entry": {
"entry_id": "42b4d4fa6c2de81599a71d3558da6ed1",
"version": 1,
"domain": "androidtv",
"title": "192.168.50.124",
"data": {
"host": "192.168.50.124",
"device_class": "auto",
"port": 5555
},
"options": {
"get_sources": true,
"exclude_unnamed_apps": false,
"screencap": true,
"apps": {
"com.liskovsoft.smarttubetv.beta": "Youtube",
"me.efesser.flauncher": "Home"
},
"state_detection_rules": {
"me.efesser.flauncher": [
"idle"
]
}
},
"pref_disable_new_entities": false,
"pref_disable_polling": false,
"source": "user",
"unique_id": "**REDACTED**",
"disabled_by": null
},
"device_properties": {
"device_class": "androidtv",
"manufacturer": "NVIDIA",
"model": "SHIELD Android TV",
"serialno": "**REDACTED**",
"sw_version": "11",
"ethmac": "**REDACTED**",
"wifimac": "**REDACTED**"
},
"device": {
"area_id": "living_room",
"config_entries": [
"42b4d4fa6c2de81599a71d3558da6ed1"
],
"configuration_url": null,
"connections": "**REDACTED**",
"disabled_by": null,
"entry_type": null,
"id": "f128690e3afe01dd999ef9f8ce5a0fd9",
"identifiers": "**REDACTED**",
"manufacturer": "NVIDIA",
"model": "SHIELD Android TV (Android TV)",
"name_by_user": null,
"name": "Android TV 192.168.50.124",
"suggested_area": null,
"sw_version": "11",
"hw_version": null,
"via_device_id": null,
"is_new": false,
"entities": {
"media_player.android_tv_192_168_50_124": {
"unique_id": "**REDACTED**",
"platform": "androidtv",
"area_id": null,
"capabilities": {},
"config_entry_id": "42b4d4fa6c2de81599a71d3558da6ed1",
"device_class": null,
"device_id": "f128690e3afe01dd999ef9f8ce5a0fd9",
"domain": "media_player",
"disabled_by": null,
"entity_category": null,
"hidden_by": null,
"icon": null,
"id": "b07811a73e22341f3809f32cea8c4491",
"name": null,
"options": {},
"original_device_class": null,
"original_icon": null,
"original_name": "Android TV 192.168.50.124",
"supported_features": 23997,
"unit_of_measurement": null,
"state": {
"state": "playing",
"attributes": {
"source_list": [
"com.foxsports.android",
"com.google.android.gms.persistent",
"com.android.systemui",
"Spotify",
"com.google.android.tv.remote.service",
"com.nvidia.blakepairing",
"com.dolby.android.audio.service",
"com.nvidia.shieldtech.accessoryui",
"com.nvidia.shield.remote.server",
"com.nvidia.osc",
"com.nvidia.app.messaging",
"com.android.providers.media.module",
"Youtube",
"com.google.process.gservices",
"com.nvidia.tegrazone3",
"Play Store",
"com.google.process.gapps",
"com.android.vending:background",
"com.nvidia.tegrazone3:telemetry",
"com.nvidia.tegrazone3:PersonalGridService",
"com.android.providers.tv",
"com.google.android.tvrecommendations",
"Home",
"com.nvidia.shield.ask",
"com.google.android.ext.services",
"com.irishin.buttonsremapper",
"com.google.android.leanback.ime",
"com.google.android.katniss:interactor",
"com.google.android.gms",
"Google Cast",
"com.google.android.katniss:search"
],
"volume_level": 1.0,
"is_volume_muted": false,
"app_id": "InputMethod}:",
"app_name": "InputMethod}:",
"source": "InputMethod}:",
"adb_response": null,
"hdmi_input": null,
"entity_picture": "/api/media_player_proxy/media_player.android_tv_192_168_50_124?token=8e0267e2b1651c1df436956a24ec29934f860217db5943e3889edd58ac60a866&cache=1649479274.991632",
"friendly_name": "Android TV 192.168.50.124",
"supported_features": 23997
},
"last_changed": "2022-04-09T04:37:05.363656+00:00",
"last_updated": "2022-04-09T04:41:14.991708+00:00"
}
}
}
}
}
}
Example YAML snippet
This was set up using Add Integration
Anything in the logs that might be useful for us?
No response
Additional information
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 9
- Comments: 63 (5 by maintainers)
Commits related to this issue
- Fix for current application in android 11 Parsing of current app is broken incase google assitant gets triggered and closed again. Suddenly we have Windows #1 as `mOwnerUid=10050 showForAllUsers=fals... — committed to grimpy/python-androidtv by grimpy 2 years ago
- Fix for current application in android 11 Parsing of current app is broken incase google assitant gets triggered and closed again. Suddenly we have Windows #1 as `mOwnerUid=10050 showForAllUsers=fals... — committed to grimpy/python-androidtv by grimpy 2 years ago
- Fix for current application in android 11 (#321) Parsing of current app is broken incase google assitant gets triggered and closed again. Suddenly we have Windows #1 as `mOwnerUid=10050 showForAllUse... — committed to JeffLIrion/python-androidtv by grimpy 2 years ago
- Bump androidtv dependency of androitv component Bump dependency to version 0.0.69 Fixes: #69723 Signed-off-by: Jo De Boeck <deboeck.jo@gmail.com> — committed to grimpy/core by grimpy 2 years ago
- Bump androidtv dependency to 0.0.69 (#80407) Bump dependency to version 0.0.69 Fixes: #69723 Signed-off-by: Jo De Boeck <deboeck.jo@gmail.com> Signed-off-by: Jo De Boeck <deboeck.jo@gmail.com> — committed to home-assistant/core by grimpy 2 years ago
I agree that the only way to really address the parade of incompatible changes coming from AndroidTV is to make the commands more easily customizable. I dug into this a bit today when it started happening for me and it looks like one of the issues is that the current app is being extracted from
Window #1in the adb output, and the window numbers don’t seem to be a reliable way to reference the current running app. I solved it for me in a couple of different ways, with only one required and both with the same result.androidtvpackage to replaceWindow #1inconstants.pywithmInputMethodTargetand the right app info is now populated in the attributes. That patch looks like this:current_app_media_session_stateshell command to the following. It’s exactly the same change as above, but specifying the command in the HA UI, rather than messing around with theandroidtvpackage.CURRENT_APP=$(dumpsys window windows | grep 'mInputMethodTarget') && 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 {'There may very well be a reason that
Window #1was chosen to search for in the adb output, and I have no idea if the change that I made will continue to be reliable. Just throwing it out there if someone else wants to try it.The inspiration came from here, where you can see how often this changes and why it’s so hard to keep it working.
I’m using an nVidia Shield running AndroidTV 11 and v9.1.0 of the Shield software.
This used to work in 2022.2.x, but something broke in 2022.4. I have the same issue now with my Nvidia Shields reporting “InputMethod}:” no matter what I am app is running or what I am watching. My previous config was in YAML and had to re-set these up in the integrations GUI.
The InputMethod}: issue is still there on 2022.4.7
The InputMethod}: issue is still there on Home Assistant Core 2022.5.2
Just wondering if there is anyone looking at fixes for this issue at all. I miss my automations lol
I built an workaround for my Nvidia Shield using MacroDroid and the HA API. It’s even faster than the Android TV implemention! Maybe because it pushes a status change to HA instead of pulling it. I can share my code on the weekend if you’d like.
i have discovered that Google Assistant is the cause, if you reboot the shield everything works, and after you open assistant it goes to
AssistPreviewPanel}:and after it closes
InputMethod}:stays on forever until you rebootI do not have the android tv notifications app on my shield and I still have this issue
I don’t think that’s the only trigger for the problem. I never set up the notifications integration in the first place but still regularly get the InputMethod thing. It’s not constantly, but often enough for it to be noticable.
Ik have a shield tv pro 2019 and the InputMethod}: is suddenly solved after the 2022.4.2 update. The next problem is the playing, idle and pause state. It seems to work fine but after a few minutes of playing a movie the status sometimes jumps to idle for a few seconds. After this, the status changes back to playing. That’s great fun because I have an automation that dims those lights while playing a movie.
Where did you exactly change this please?
I had misread your post and accidentally deleted the updates of Android tv core instead of Android TV notifications which I don’t even have😁. the problem of inputmethod is now gone for me too😀
I can confirm that removing Notifications for Android TV/Fire TV app from the Nvidia Shield fixed the input method error.
After core update 2022.4.2 it seams to work now.
I have two shields… one wasnt added yet because the integration was broken for Android 11 before. I adde it now to see if this was fixed, at first it worked like it should. But after a while (or a reboot) it showed the same issues as it had with the one that ws already active…
Nvidia Shield Pro V2017 app_id: InputMethod}: app_name: InputMethod}: source: InputMethod}:
or
Nvidia Shield Pro V2019 app_id: AssistPreviewPanel}: app_name: AssistPreviewPanel}: source: AssistPreviewPanel}:
This is why we need customizable commands: https://github.com/home-assistant/core/pull/65397.