Closed TannerBrunscheon closed 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 #1
in 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.
androidtv
package to replace Window #1
in constants.py
with mInputMethodTarget
and the right app info is now populated in the attributes. That patch looks like this:
diff --git a/androidtv/constants.py b/androidtv/constants.py
index be4b0af..325270e 100644
--- a/androidtv/constants.py
+++ b/androidtv/constants.py
@@ -96,7 +96,7 @@ CMD_DEFINE_CURRENT_APP_VARIABLE = (
)
#: Assign focused application identifier to ``CURRENT_APP`` variable for an Android 11 device
CMD_DEFINE_CURRENT_APP_VARIABLE11 = (
current_app_media_session_state
shell 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 the androidtv
package.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 #1
was 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.
So it varies by Android tv version? Maybe it can be hard-coded by version then.
It already is, but it's not maintainable to support all the variations.
Well we can only try to cover as much as we can. You've managed to make it work for the latest version so that's great. Future versions will be managed as they come out.
I hope this fix and the other fix/feature for listing all installed apps as sources makes it into core eventually. (https://github.com/home-assistant/core/issues/45611) Long story short, PR was rejected 2 years ago when config flow was missing but should be easier now that config flow exists, right?
I have the same problem with a Philips Oled706 recently update to Android 11. app_id: InputMethod}: app_name: InputMethod}: source: InputMethod}: I have Home Assistant 2022.9.2 Is there nothing to solve this problem yet? Thanks!
I have the same problem with a Philips Oled706 recently update to Android 11.
app_id: InputMethod}:
app_name: InputMethod}:
source: InputMethod}:
I have Home Assistant 2022.9.2
Is there nothing to solve this problem yet? Thanks!
Aside from the workaround that I described? It's been working fine for me.
I have the same problem with a Philips Oled706 recently update to Android 11. app_id: InputMethod}: app_name: InputMethod}: source: InputMethod}: I have Home Assistant 2022.9.2 Is there nothing to solve this problem yet? Thanks!
Aside from the workaround that I described? It's been working fine for me.
I have tried your solution, but it doesn't solve the problem. However, the following command did it. I found this command here: https://community.home-assistant.io/t/new-chromecast-w-android-tv-integration-only-showing-as-off-or-idle/234424/66
CURRENT_APP=$(dumpsys activity a . | grep -E 'mResumedActivity' | cut -d ' ' -f 8) && CURRENT_APP=${CURRENT_APP%%/*} && echo $CURRENT_APP
I have the same problem with a Philips Oled706 recently update to Android 11. app_id: InputMethod}: app_name: InputMethod}: source: InputMethod}: I have Home Assistant 2022.9.2 Is there nothing to solve this problem yet? Thanks!
Aside from the workaround that I described? It's been working fine for me.
I have tried your solution, but it doesn't solve the problem. However, the following command did it. I found this command here: https://community.home-assistant.io/t/new-chromecast-w-android-tv-integration-only-showing-as-off-or-idle/234424/66
CURRENT_APP=$(dumpsys activity a . | grep -E 'mResumedActivity' | cut -d ' ' -f 8) && CURRENT_APP=${CURRENT_APP%%/*} && echo $CURRENT_APP
Where did you exactly change this please?
I have the same problem with a Philips Oled706 recently update to Android 11. app_id: InputMethod}: app_name: InputMethod}: source: InputMethod}: I have Home Assistant 2022.9.2 Is there nothing to solve this problem yet? Thanks!
Aside from the workaround that I described? It's been working fine for me.
I have tried your solution, but it doesn't solve the problem. However, the following command did it. I found this command here: https://community.home-assistant.io/t/new-chromecast-w-android-tv-integration-only-showing-as-off-or-idle/234424/66 CURRENT_APP=$(dumpsys activity a . | grep -E 'mResumedActivity' | cut -d ' ' -f 8) && CURRENT_APP=${CURRENT_APP%%/*} && echo $CURRENT_APP
Where did you exactly change this please?
I ´ve installed AndroidTV Custom from this repo: I ´ve configured the Android TV Custom integration and then i put the command on current_app_media_session_state field. After that I can correctly see app_id, app_name and source in my home assistant
The command also allowed me to see the running apps - thanks for sharing Igloher .
My TV is the following - Sony A80J OLED - Android 9. This is the first time I have successfully seen the running apps within HA after many months trying all sorts of possible solutions.
I used the Android TV Custom Integration rather than the "Android TV" integration.
Here are the steps I followed within HA,
Settings devices and services Android Custom Integration chose my media device "Sony OLED" configure configure ADB shell custom commands followed by current_app_media_session_state - click submit In the blank box in the centre of the window, I pasted the command shared by Igloher
CURRENT_APP=$(dumpsys activity a . | grep -E 'mResumedActivity' | cut -d ' ' -f 8) && CURRENT_APP=${CURRENT_APP%%/*} && echo $CURRENT_APP
Submit Submit, again Message appeared that options were saved successfully, click on finish
After this I ran Kodi, Disney++, Netflix to test and under developer tools / states it showed the currently running app & also via the media player in my HA dashboard.
The only issue which still does not work correctly for me is the state of the running app - either it is idle / paused when an app is opened and something is playing. This is the main feature I wish to work, like probably many others, to have lights dim/off when a film is playing at night & come back on when the film is paused/stopped.
If anyone has an idea of an addition to the command to display this information, please share, thanks.
Ok, I did it different, but it also works perfectly fine now for my Philips 65OLED806 on Android 11:
With File editor in HASS I've opened the following file: /config/custom_components/androidtv/androidtv11hack/constants.py
I've replaced line 99
"CURRENT_APP=$(dumpsys window windows | grep 'Window #1') && " + CMD_PARSE_CURRENT_APP11
with
"CURRENT_APP=$(dumpsys window windows | grep 'mInputMethodTarget') && " + CMD_PARSE_CURRENT_APP11
Restart HASS and voila!
Tnx for the feedback!
Another workaround is to install Tasker on the TV. Several ways to get the APK where it needs to be. Connect a BT keyboard (or you'll hate yourself) and set up Tasker to run a task when the running app changes. Do a HTTP request to the RESTful API with the app name.
Using Tasker to talk to the IPA gives much more options anyway and much more reliable than this integration. I can for example wake my gaming PC with Steam Link when my controller connects to the TV. Get information about what's playing, battery level of the remote, and so on.
I too don’t have the Android TV Notifications app installed. Not sure what else it could be. I have the typical apps installed. Has anyone found the other apps that break it?
I bought my Shield TV Pro today, set it up with Home Assistant and have the same issue. I installed no applications so probably one of default apps causing it. Home Assistant is running the newest version
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}:
It says AssistPreviewPanel}; for me now, not sure what changed though.
and after it closes InputMethod}:
stays on forever until you reboot
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
Example YAML snippet
Anything in the logs that might be useful for us?
No response
Additional information
No response