core icon indicating copy to clipboard operation
core copied to clipboard

Android TV: Currently running app parsing broken

Open TannerBrunscheon opened this issue 2 years ago • 61 comments

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

TannerBrunscheon avatar Apr 09 '22 04:04 TannerBrunscheon

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)

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

JeffLIrion avatar Apr 09 '22 05:04 JeffLIrion

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

rob12git avatar Apr 09 '22 08:04 rob12git

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.

MarkHofmann11 avatar Apr 09 '22 12:04 MarkHofmann11

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 avatar Apr 09 '22 13:04 nethead25

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

nethead25 avatar Apr 09 '22 13:04 nethead25

image can confirm as @MarkHofmann11 mentioned in his message.

Novocaine85 avatar Apr 09 '22 16:04 Novocaine85

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

RolandGoud avatar Apr 10 '22 11:04 RolandGoud

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

supergroover avatar Apr 11 '22 18:04 supergroover

still not working for me neither are sendevents

engeles20 avatar Apr 11 '22 23:04 engeles20

still not working for me neither are sendevents

Same.

nethead25 avatar Apr 12 '22 22:04 nethead25

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.

shooto74 avatar Apr 14 '22 00:04 shooto74

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?

engeles20 avatar Apr 15 '22 07:04 engeles20

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.

nethead25 avatar Apr 15 '22 12:04 nethead25

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.

JeffLIrion avatar Apr 15 '22 13:04 JeffLIrion

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.

supergroover avatar Apr 15 '22 16:04 supergroover

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.

theSC avatar Apr 16 '22 19:04 theSC

Same applies to me as well

gsotiriou avatar Apr 19 '22 20:04 gsotiriou

The InputMethod}: issue is still there on 2022.4.7

fraser-mendeco avatar May 03 '22 16:05 fraser-mendeco

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

ex0nuss avatar May 08 '22 10:05 ex0nuss

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

engeles20 avatar May 12 '22 06:05 engeles20

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.

Shaaden69 avatar May 12 '22 12:05 Shaaden69

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

ex0nuss avatar May 12 '22 13:05 ex0nuss

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

theSC avatar May 12 '22 17:05 theSC

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?

engeles20 avatar May 12 '22 17:05 engeles20

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: @.***>

theSC avatar May 12 '22 17:05 theSC

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

engeles20 avatar May 12 '22 18:05 engeles20

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.

ex0nuss avatar May 12 '22 20:05 ex0nuss

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?

engeles20 avatar May 13 '22 06:05 engeles20