home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.34k stars 29.88k forks source link

Android TV: Currently running app parsing broken #69723

Closed TannerBrunscheon closed 1 year ago

TannerBrunscheon commented 2 years ago

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

probot-home-assistant[bot] commented 2 years ago

androidtv documentation androidtv source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years ago

Hey there @jefflirion, @ollo69, mind taking a look at this issue as it has been labeled with an integration (androidtv) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

JeffLIrion commented 2 years ago

This is why we need customizable commands: https://github.com/home-assistant/core/pull/65397.

rob12git commented 2 years ago

I have the same problem with a Lenovo_P11 Android 11 tablet. As written here in the last post, the query of the running app is not correct.

https://community.home-assistant.io/t/new-chromecast-w-android-tv-integration-only-showing-as-off-or-idle/234424/53

MarkHofmann11 commented 2 years ago

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.

nethead25 commented 2 years ago

I am also having a similar issue with two Android 10 TV devices ( Sony Bravia TV and Onn Streaming Box). Both devices are connecting fine via native python ADB or a separate adb server, showing screenshots and turning on/off fine. However, the state is shown as 'idle' for all content and the running app does not get returned. Tested for Netflix to eliminate possibility of a weird app.

nethead25 commented 2 years ago

Additionally, media player source selection is also not working for me.

Novocaine85 commented 2 years ago

image can confirm as @MarkHofmann11 mentioned in his message.

RolandGoud commented 2 years ago

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.

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}:

supergroover commented 2 years ago

After core update 2022.4.2 it seams to work now.

source_list:
  - Android TV Launcher
  - Spotify
  - Smart YouTube
  - Google Cast
  - Ziggo GO TV
  - Netflix
volume_level: 1
is_volume_muted: false
app_id: com.ziggo.tv
app_name: Ziggo GO TV
source: Ziggo GO TV
adb_response: null
hdmi_input: null
entity_picture: >-
  /api/media_player_proxy/media_player.android_tv_1?token=82d88572d9d3ebd2db6ab8d6b8047fdaecf5d6b7e70804ec2bdb0bba27cfcb37&cache=1649700467.868998
friendly_name: Android TV shield woonkamer
supported_features: 23997
engeles20 commented 2 years ago

still not working for me neither are sendevents

nethead25 commented 2 years ago

still not working for me neither are sendevents

Same.

shooto74 commented 2 years ago

I am running the latest Home Assistant Core 2022.4.3. Sony A80J OLED TV it is running Android 10 - State shows as idle no matter what app is currently running. Showing screenshots and turning on/off fine within HA - I cannot access a source list from the HA Dashboard. I also tried the custom component fix HA-androidtv11 this did not solve the issue. Hopefully, a fix for Android 10 devices will become available soon.

engeles20 commented 2 years ago

i think the issue is more to do with the shield hardware than the integration as it works just fine on a firestick 4k

has anyone downgraded the shield firmware and seen if it fixes it?

nethead25 commented 2 years ago

Seems like there might be two issues going on here. Not sure if they should be split out or if they are similar enough to be tracked together.

1) A Shield issue where InputMethod}: is being returned in the currently running fields (being discussed by @engeles20 , @TannerBrunscheon, @supergroover, @RolandGoud) 2) An Android 10 issue where the state shows as "idle" and the currently running app is not displayed. This has been observed on two Sony TVs, a Lenovo tablet, and an Onn 4K streaming box (being discussed by myself, @shooto74, @rob12git)

Either way seems like a pretty significant cross-section of android TV devices are not working as intended insofar as it comes to the state of the device and what is playing on it.

i think the issue is more to do with the shield hardware than the integration as it works just fine on a firestick 4k

I also can confirm FireTV is fine on my side.

JeffLIrion commented 2 years ago

The only sustainable way to support all the various Android TV devices and OS versions is to enable users to customize ADB commands: https://github.com/home-assistant/core/pull/65397

This would empower users to resolve these issues on their own, all from the comfort of the Home Assistant UI. No SSH'ing, modifying files, custom components, or HA restarts needed. And of course, these users will then kindly contribute their solutions to the upstream androidtv library so that other users will benefit.

So please, review & approve the customizable commands pull request, and call attention to it so that someone with merge rights merges it.

supergroover commented 2 years ago

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.

theSC commented 2 years ago

NVidia Shield user here: I still have the "InputMethod}" issue as well as the random playing/idle changes. On 2022.4.4. It 100% breaks any automations based on the player state.

gsotiriou commented 2 years ago

Same applies to me as well

fraser-mendeco commented 2 years ago

The InputMethod}: issue is still there on 2022.4.7

ex0nuss commented 2 years ago

The InputMethod}: issue is still there on Home Assistant Core 2022.5.2

engeles20 commented 2 years ago

So i found out on the nvidia shield if you factory reset the InputMethod}: issue goes away

not sure how to fix it without reset but i can confirm it worked

Shaaden69 commented 2 years ago

Same behaviour here with one of my 2 Nvidia Shields. No issue with the other one. Both are on AndroidTV 11 and up-to-date. I'm using the same apps on both.

ex0nuss commented 2 years ago

If a factory reset is necessary: Is there a way to backup all the shield apps, app settings and os settings?

theSC commented 2 years ago

What about the random switching from playing to idle? That's the part that breaks my automations.... Lights turning off and on while I watch a movie isn't fun lol

engeles20 commented 2 years ago

What about the random switching from playing to idle? That's the part that breaks my automations.... Lights turning off and on while I watch a movie isn't fun lol

I'll test it right now,what app in particular?

theSC commented 2 years ago

All of them for me

On Thu., May 12, 2022, 10:36 engeles20, @.***> wrote:

What about the random switching from playing to idle? That's the part that breaks my automations.... Lights turning off and on while I watch a movie isn't fun lol

I'll test it right now,what app in particular?

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/69723#issuecomment-1125255604, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE5OBIUKPWISM4PAZ6PGO4LVJU6QXANCNFSM5S6KCCVQ . You are receiving this because you commented.Message ID: @.***>

engeles20 commented 2 years ago

All of them for me On Thu., May 12, 2022, 10:36 engeles20, @.> wrote: What about the random switching from playing to idle? That's the part that breaks my automations.... Lights turning off and on while I watch a movie isn't fun lol I'll test it right now,what app in particular? — Reply to this email directly, view it on GitHub <#69723 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE5OBIUKPWISM4PAZ6PGO4LVJU6QXANCNFSM5S6KCCVQ . You are receiving this because you commented.Message ID: @.>

yes, it goes to standby still for about 2 seconds then goes back to playing

ex0nuss commented 2 years ago

What about the random switching from playing to idle? That's the part that breaks my automations.... Lights turning off and on while I watch a movie isn't fun 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.

engeles20 commented 2 years ago

So after i installed and setup notifications for android/firetv on my nvidia shield, the inputmethod thing came back. Once i realized it i decided to uninstall the app from the shield, and also delete the integration on HA. After a restart the inputmethod error went away again

can someone confirm this behavior?

MelvinBungles commented 2 years ago

I can confirm that removing Notifications for Android TV/Fire TV app from the Nvidia Shield fixed the input method error.

engeles20 commented 2 years ago

Awesome, now we know the root of the problem

mmuffins commented 2 years ago

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.

inputmethod

supergroover commented 2 years ago

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😀

gsotiriou commented 2 years ago

I can confirm removing Android TV notification seems to fix the issue. The question is , why it caused the issue and is there a work around that? I was kinda relying on Android Notifications for another part of my automations.

engeles20 commented 2 years ago

To clarify to users coming across the input method error

Removing this app from the nvidia shield fixes the issue

https://play.google.com/store/apps/details?id=de.cyberdream.androidtv.notifications.google

murkumurdok commented 2 years ago

I do not have the android tv notifications app on my shield and I still have this issue

gsotiriou commented 2 years ago

I do not have the android tv notifications app on my shield and I still have this issue

Then you have "some other application" installed on your AndroidTV that uses that systemic permission SYSTEM_ALERT_WINDOW. You need to "imagine" what app this may be and remove it.

Evidence: I removed Android TV Notifications which apparently must be working by "drawing" a system alert window as a permanent overlay above everything in order to display notifications. Apparently this overlay is picked up by AndroidTV as "InputMethod:]" and displayed as such.

More evidence: In my search for an alternative notification solution I quickly tested the opensource called "PIPup" (here).

PIPup works as a server accepting POST requests from any client (either HomeAssistant or POSTman). At first I tried to display a simple notification using POSTman. It wasn't working. Searching through PIPup's issues I found that in order for it to work I had to provide it with SYSTEM_ALERT_WINDOW permission.

As soon as I did that and sent again my POST request via POSTman , I noticed that the notification was appearing. But, for the duration of it my TV's state was becoming "InputMethod:]". That led me to realise that also PIPup temporarily "draws" the same overlay in order to display the short notification. As soon as the notification goes away the state of my TV comes back to normal.

I think I can live with that for now.

bencmeyer commented 2 years ago

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?

dc911x commented 2 years ago

I also didn't have the Android TV Notification app installed and was still having "InputMethod:}" issue. So I started deleting all apps that I didn't use in the hope it was one of those.

I deleted the following apps:

I have the feeling I missed one because I did it last night and didn't document it right away... But maybe someone can cross-reference those and also try it?

PS: Issue was only fixed after rebooting the SHIELD so I have no idea what app was actually causing it. I didn't reboot after each app removal.

dc911x commented 2 years ago

We're a few days later and it's back... I don't think we've installed a new app. Back to the drawing board...

afbeelding

theSC commented 2 years ago

Just wondering if there is anyone looking at fixes for this issue at all. I miss my automations lol

dc911x commented 2 years ago

We're a few days later and it's back... after a reboot of the Nvidia SHIELD it showing the source again.

afbeelding

Hope this info helps someone who knows where to look at.

MarkHofmann11 commented 2 years ago

Yes, I noticed the same thing. A reboot of the Shield seems to temporarily fix the issue - but it will re-appear. Not sure what the trigger is, but it is definitely still an issue even running the very latest HA.

tYn0 commented 2 years ago

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

ex0nuss commented 2 years ago

Yes, I noticed the same thing. A reboot of the Shield seems to temporarily fix the issue - but it will re-appear. Not sure what the trigger is, but it is definitely still an issue even running the very latest HA.

+1 for me

mvv588 commented 2 years ago

It says AssistPreviewPanel}; for me now, not sure what changed though.

Xitro01 commented 2 years ago

Same issue here on my Nvidia Shield.

efaden commented 2 years ago

Same issue on my shield.... Even after a reset.

TommisGR commented 2 years ago

Recently bought an AndroidTV Box running android 10 and been having same issues as above

state remains at idle cannot change to another source. only Volume and power seem to work