New Chromecast w/ Android TV Integration only showing as Off or Idle

I am having this same issue, using the core component. So I will also switch to the custom one for now.

Update: with the custom component it’s not great either. When I start Kodi on the Shield, it shows “playing” even without content playing on the Kodi. Youtube seems to work correctly, but another streaming app “NLZiet” still keeps the Shield on “idle” while content is playing.

The status issue of AndroidTV not showing current status, seems to have been resolved with a recent core update. You can view the pull request here.

1 Like

Unfortunately not. I have a Lenovo P11 tablet with Android 11 the androditv mediaplayer (Homeassistant 2022.4.0) still switches between idle and playing.
It also does not recognise the app running in the foreground. ((homeassistant companion app)
The query is not correct. You can see this in the curly brackets at the end of the (wrong) app_id, app_name and source string.

Btw. the dumpsys query shows the correct app_id of the active app (companion app or when stopped the app_id of the launcher):

J606F:/ $ dumpsys activity a . | grep -E 'mResumedActivity' | cut -d ' ' -f 8
io.homeassistant.companion.android/.webview.WebViewActivity
J606F:/ $ dumpsys activity a . | grep -E 'mResumedActivity' | cut -d ' ' -f 8
com.tblenovo.launcher/com.android.searchlauncher.SearchLauncher

The second mediaplayer is an old Lenovo tablet with Android 8 and everything works.

:wave:

I have a Chromecast with Google TV integrated with the android TV integration. The status is reported fine, almost all the controls works, and the source works well.

I have two problems, the volume control doesn’t work at all, and I don’t get the album art in any of the apps.

Any clue about if I am doing something wrong?

1 Like

I am having the same issue, TCL TV with Google TV (Android 11) the android TV integration gets some info but barely anything useful. I can turn the TV on and off, but not much else.

Via the Google Cast integration, I got a device which is able to get all inputs and control the volume but it only works when some apps (maybe only YouTube) are open.

Here’s the results when playing simple TV channels

And here’s when playing youtube

I’ve tried running some of the ADB commands in this thread but they do not return much information.

Special attention to the 'InputMethod}:' that is show on app_name, app_id and source. It looks like this is part of the issue.

1 Like

Update, today it shows app_name: 'AssistPreviewPanel}:' not InputMethod}: anymore

1 Like

I’m seeing the exact same scenario’s as @kauelima when using the official integration. The Hacked Integration works better, but it stumbles with certain apps. For instance, when I watch the Sling TV app on my Nvidia Shield, it will only display the entity picture from the Goggle Cast integration and not the Android TV? Yet, it works fine when I use the Tablo TV app. Netflix however, doesn’t display the entity picture on either app?!

No consistency between the two?! lol

1 Like

Hey Mark what hacked one you say, the one posted above by @undulattice? I’ll have to try that one

Yep. that’s the one. It works better than the official integration but still isn’t perfect. I haven’t updated to 2022.05 to see if the May release is any better.

@mboarman @diodorus I’ve been trying to install this but I haven’t had any luck. I created the “androidtv” folder within the custom_componets folder as stated in the repo but that’s where I got a little confused. Do I copy everything from the main “HA-androidtv11” folder of the repo or everything from the “androidtv11hack” subfolder that is within the main folder.? After I get that straightened out what are my next steps.? Thanks in advance.

If you have a “androidtv” folder created under custom_components, then just grab the entire folder structure of the repo and drop it in there.

Reboot
Add Integration - AndroidTV through the config panel
Add your TV’s through the AndroidTV integration. (each on requires a new integration be setup)

Even with the hacked version I’m still getting app_id: 'InputMethod}:' :frowning:

It can at least turn on and off the device I think, but states are also messed up as volume slider and basically everything else

Hmmmm…are you sure its using the hacked integration? What android device are you using it with?

i factory reset my shield and it fixed the app_id: ‘InputMethod}:’

hassle to set everything up again, but worth it

I’ll try again, but it is a TCL TV with google tv (TCL C725), not exactly the new chromecast. I’ll try again but heres the steps i took

Deleted the standard android tv device.
Copied the repo contents to a folder called “androidtv” inside of custom components
Reset home assistant
Add the android tv integration (it was exactly the same, i’m assuming it’s all in background)

Update: User error is really a thing. I’ve tried moving the folder using vscode but it only created folders not files. So I redid it using the samba integration and all files are there.

Now I see that it went in because the name of the integration changed from “Android TV” to “androidtv”.

BUT, I still have it showing something that is not what it should. Now it’s showing “AssistPreviewPanel}:” on the state. It does query the tv volume but I cannot change it still :frowning: everything else is the same.

Using the ADB query someone posted above I get the current app returned with success:

CURRENT_APP=$(dumpsys activity a . | grep -E 'mResumedActivity' | cut -d ' ' -f 8) && CURRENT_APP=${CURRENT_APP%%/*} && echo $CURRENT_APP
1 Like

Hello, I tried both the hacked integration and the official integration on latest core but the integration stays idle.
For the hacked integration I renamed the folder to androidtv and placed in custom components folder.
Assuming I did everything correct, or is there something I’m missing?
My device is Tivo 4k

Getting inputmethod in media, any solutions yet ?

Has anyone successfully downgraded to Android 9? I want to use the Android ‘sendevent’ command as opposed to the default ‘input’ which requires A9 as A10 has introduced a security policy to block this command

The above is documented.ob the official HA integration page

I use a template sensor for this.

template:
  - sensor:
    - name: "chromecast_adb_office_on_screen"
      state: >
        {% set astate = state_attr('media_player.chromecast_adb_office', 'adb_response') %}
        {% if "{'screen_on':" in astate -%}
        {% set onscreen = astate | regex_findall_index("{'screen_on': (\w+)") %}
        {% if onscreen == "True" -%}
          {{ onscreen }}
        {%- endif %}
        {% if onscreen == "False" -%}
          {{ onscreen }}
        {%- endif %}
        {%- endif %}  

And on every state change of the player i fire up this service:

  - service: androidtv.adb_command
    data:
      command: GET_PROPERTIES
    target:
      entity_id: media_player.chromecast_adb_office

It is not the best method, but better than nothing.

Check this link out: [Testers needed!] Custom state detection rules for Android TV / Fire TV - #28 by Pronown
Should work like Fire TV since it is same integration and Fire TV is Android based.

Known ids:
Plex = com.plexapp.android
Netflix = com.netflix.ninja
Hulu = com.hulu.plus

Others can be found by visiting the play store via browser (preferably pc so it doesn’t auto open the app) and copying the com.blank.blank from the url.

I was able to get most states through all three sources using

- playing:
    media_session_state: 3
- paused:
    media_session_state: 2
- idle
- standby

Anyone know how to make the adb connection stop falling off randomly?

1 Like