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

As the title says, I have the new Chromecast with Google (Android) TV. I have the Android TV integration working correctly on my Nvidia Shield. I set it up on the new Chromecast (enabled debugging and accepted the connection request from HA). However, I am only seeing “Idle” or “Off” for the entity state. It never shows “Playing”, “Paused”, or “Stopped” like on the Shield and I cannot get a name for the currently running app (which works on my shield).

HA is currently 0.116 in Docker on Ubuntu 18.04
The entity attributes for the Chromecast are:
adb_response: null
friendly_name: chromecast
supported_features: 23997

The Nvidia Shield shows a thumbnail and a bunch of additional (expected) attributes but has the same adb_response and supported_features as the chromecast.

Not sure if I am missing something obvious or if someone can verify if it is working or not working for them.

Thanks

One or more of the ADB commands that the androidtv package uses to collect information from the device must not be working correctly for this new product.

You can still turn the device on/off, right? If so, that means that the ADB connection is working correctly.

Yeah, I was able to turn it on via HA and that made it actually load a thumbnail also. I didn’t immediately see a way to turn the device off via the HA UI and didn’t have a chance to mess with that but I imagine if “on” is working then “off” should as well.

I wouldn’t put it past Google to change things to a nonstandard method :-/

And I also found that I couldn’t select source from UI on the new chromecast even I used “apps:” parameter.
androidtv

Well at least I know it’s not (necessarily) a configuration mistake on my part if someone else is having the same issue. I updated the Chromecast with the update that came out yesterday but it doesn’t seem to have made a difference.

That’s because the sources list only shows the running apps. And since it’s not retrieving the properties correctly from the device, there are no running apps to show.

Send this command via the androidtv.adb_command service and post the adb_response here (from the “States” page):

"(dumpsys power | grep 'Display Power' | grep -q 'state=ON' || dumpsys power | grep -q 'mScreenOn=true') && echo -e '1\c' && dumpsys power | grep mWakefulness | grep -q Awake && echo -e '1\c' && (dumpsys audio | grep paused | grep -qv 'Buffer Queue' && echo -e '1\c' || (dumpsys audio | grep started | grep -qv 'Buffer Queue' && echo '2\c' || echo '0\c')) && dumpsys power | grep Locks | grep 'size=' && CURRENT_APP=$(dumpsys window windows | grep mCurrentFocus) && 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 {' || echo) && dumpsys audio | grep '\- STREAM_MUSIC:' -A 12 && ps -A | grep u0_a"

And do the same for this command:

"getprop ro.product.manufacturer && getprop ro.product.model && getprop ro.serialno && getprop ro.build.version.release && ip addr show wlan0 | grep -m 1 ether && ip addr show eth0 | grep -m 1 ether"

Still trying to get the first command to work. It seems to be throwing an API error for some reason. For now, here is the response of the second command:

adb_response: GoogleChromecast08041HFDD0BV0110    link/ether b0:e4:d5:9a:a8:b2 brd ff:ff:ff:ff:ff:ffDevice "eth0" does not exist.

I made an attempt at parsing your first command because I could only get parts of it to work. The grep stuff seems to be throwing it off but I can run more dumpsys commands if that would help. Hopefully this is better than nothing.

Display Power: state=OFF
mWakefulness=Asleep
mWakefulnessChanging=false
no_cached_wake_locks=true
mWakeLockSummary=0x1
mHoldingWakeLockSuspendBlocker=true
Wake Locks: size=1
 PowerManagerService.WakeLocks: ref count=1

  mCurrentFocus=Window{bca1c11 u0 com.google.android.apps.tv.launcherx/com.google.android.apps.tv.launcherx.home.HomeActivity}

  Sessions Stack - have 1 sessions:
      Netflix media session com.netflix.ninja/Netflix media session (userId=0)
        ownerPid=7565, ownerUid=10065, userId=0
        package=com.netflix.ninja
        launchIntent=null
        mediaButtonReceiver=null
        active=false
        flags=3
        rating type=0
        controllers: 0
        state=null
        audioAttrs=AudioAttributes: usage=USAGE_MEDIA content=CONTENT_TYPE_UNKNOWN flags=0x800 tags= bundle=null
        volumeType=1, controlType=2, max=0, current=0
        metadata: null
        queueTitle=null, size=0

  - STREAM_MUSIC:
     Muted: false
     Min: 0
     Max: 25
     streamVolume:25
     Current: 4 (headset): 10, 8 (headphone): 10, 400 (hdmi): 25, 4000000 (usb_headset): 6, 40000000 (default): 20
     Devices: hdmi

Not sure what you are looking for specifically but HA doesn’t like me trying to pipe things into grep very much. I can give you the full dumps for stuff or if you let me know what you are looking for I can give you just that.

Thanks

The first command is what the androidtv package uses to get a bunch of state properties from the Android TV device. Something about it isn’t working correctly for Google’s new device, so I’d like to see what the raw output is in order to see which part isn’t working as expected.

It looks like your device is off, so the output of the command, as seen in the adb_response, should be an empty string. Try it when your device is in use.

Sorry it took so long. Here is the adb response while playing a YouTube video:

adb_response: '111Wake Locks: size=3'

And here it is while playing Netflix:

adb_response: '111Wake Locks: size=4'

I then went back and played YouTube and got the original result in case that matters. YouTube again:

adb_response: '111Wake Locks: size=3'

Can you try replacing mCurrentFocus with 'Window #1' in my first command and post the result.

This was suggested here: Native support for Android TV / Android devices

I think you might be removing some newlines from the output of the second command (the one that gets the device properties). It should look something like:

Amazon
AFTT
SERIALNO
5.1.1
    link/ether ab:cd:ef:gh:ij:kl brd ff:ff:ff:ff:ff:ff
Device "eth0" does not exist.

Although it may have \n instead of actual newlines. If there’s a way to distinguish these Google devices from other Android TV devices, then a different command can be used to perform the update.

Source

I’ll go ahead and replace mCurrentFocus in your first command and post back here. I didn’t think I was missing anything from the second command’s response (I think the response was all one line) but I can double check. It’ll be a bit before I can get in front of it…hoping 9hrs or less.

Also, with that second command, the Chromecast was off so I’ll try it both on and off and see if I get different/better results.

Thanks for all the help.

Not sure what happened last time. Here is the second command with proper output:

adb_response: |-
  Google
  Chromecast
  SERIALNUMBER
  10
      link/ether MAC_ADDRESS brd ff:ff:ff:ff:ff:ff
  Device "eth0" does not exist.

And here is the modified first command as I entered it (while playing YouTube):

(dumpsys power | grep 'Display Power' | grep -q 'state=ON' || dumpsys power | grep -q 'mScreenOn=true') && echo -e '1\c' && dumpsys power | grep mWakefulness | grep -q Awake && echo -e '1\c' && (dumpsys audio | grep paused | grep -qv 'Buffer Queue' && echo -e '1\c' || (dumpsys audio | grep started | grep -qv 'Buffer Queue' && echo '2\c' || echo '0\c')) && dumpsys power | grep Locks | grep 'size=' && CURRENT_APP=$(dumpsys window windows | grep 'Window #1') && 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 {' || echo) && dumpsys audio | grep '\- STREAM_MUSIC:' -A 12 && ps -A | grep u0_a

and the response (which looks like I did something wrong):

adb_response: '/system/bin/sh: no closing quote'

Assuming you made the modification correctly and you’re using the androidtv.adb_command service to send the command, try putting double quotes around it.

I had tried that with no luck. I think I figured out how to get the correct output. I had to escape the # so it was 'Window \#1'. For whatever reason, when HA was using the command (Developer Tools > Services tab > Service Data) it was chopping it off at the #. Maybe it was seeing everything after that as a comment? Idk.
This is hopefully what you are looking for (playing YouTube):

adb_response: >-
  111Wake Locks: size=4

  com.google.android.youtube.tv
        state=PlaybackState {state=3, position=610102, buffered position=0, speed=1.0, updated=234649304, actions=379, custom actions=[], active item id=-1, error=null}
  - STREAM_MUSIC:
     Muted: false
     Min: 0
     Max: 25
     streamVolume:25
     Current: 4 (headset): 10, 8 (headphone): 10, 400 (hdmi): 25, 4000000 (usb_headset): 6, 40000000 (default): 20
     Devices: hdmi
  - STREAM_ALARM:
     Muted: false
     Min: 1
     Max: 7
     streamVolume:6
     Current: 4 (headset): 3, 8 (headphone): 3, 400 (hdmi): 7, 4000000 (usb_headset): 2, 40000000 (default): 6
  u0_a38       16522 16265 1348552  89960 0                   0 S
  com.android.systemui

  u0_a56       16765 16265 1343904  94124 0                   0 S
  com.google.android.inputmethod.latin

  u0_a42       16783 16265 1302956  67868 0                   0 S
  com.google.android.tv.remote.service

  u0_a34       16836 16265 1463908 140584 0                   0 S
  com.google.android.gms.persistent

  u0_a34       16996 16265 1606840 156528 0                   0 S
  com.google.android.gms

  u0_a34       17025 16265 1308624  70540 0                   0 S
  com.google.process.gservices

  u0_a80       17047 16265 1306576  73044 0                   0 S
  com.google.android.tv

  u0_a31       17060 16265 1764928 112324 0                   0 S
  com.google.android.katniss:interactor

  u0_a37       17151 16265 1335044  89580 0                   0 S
  com.google.android.apps.tv.launcherx:coreservices

  u0_a31       17358 16265 1825940 135776 0                   0 S
  com.google.android.katniss:search

  u0_a35       17649 16265 1312908  77648 0                   0 S
  com.google.android.tungsten.setupwraith

  u0_a65       17721 16265 1939492 161236 0                   0 S
  com.netflix.ninja

  u0_a41       18289 16265 1462220 151080 0                   0 S
  com.google.android.apps.mediashell

  u0_a46       18601 16265 1385216 139948 0                   0 S
  com.google.android.tts

  u0_a33       18896 16265 1299904  66116 0                   0 S
  com.google.android.tv.axel

  u0_a63       22420 16265 1824040 215012 0                   0 S
  com.google.android.youtube.tv

  u0_a78       24557 16265 1587728 100648 0                   0 S
  com.plexapp.android

  u0_a41       25161 16265 1456356 138372 0                   0 S
  com.google.android.apps.mediashell:privileged_process0

  u0_a6        28482 16265 1294856  73352 0                   0 S
  android.process.media

  u0_a67       28513 16265 1329604 101240 0                   0 S
  com.rma.netpulsetv

  u0_a20       28526 16265 1622032 103692 0                   0 S
  tv.pluto.android

  u0_a44       28633 16265 1408720 125572 0                   0 S
  com.android.vending

  u0_a20       28666 16265 1615808 117512 0                   0 S
  tv.pluto.android:input

  u0_a34       28778 16265 1293748  74880 0                   0 S
  com.google.process.gapps

  u0_a44       28871 16265 1344820  98500 0                   0 S
  com.android.vending:download_service

  u0_a3        28908 16265 1308992  80596 0                   0 S
  com.android.providers.tv

  u0_a37       29092 16265 1662476 228096 0                   0 S
  com.google.android.apps.tv.launcherx
friendly_name: Bedroom Chromecast

I have literally the same setup and issues as OP. I’m willing to assist with testing so we can get these new Chromecasts working as well as the Shield does.

@dg1024 @grh6u5zp04kd

This pull request should fix it: https://github.com/JeffLIrion/python-androidtv/pull/203

Can you run the two commands I posted above while your device is on and make sure the results are the same format as what’s in these tests. Note: change mCurrentFocus to 'Window \#1' and change -A 12 to -A 11 in the commands.

Look at the additions in these two files:

  • test_basetv_sync.py
  • test_androidtv_sync.py

Yeah, best I can tell everything looks good. This may be obvious but for the sake of being thorough, HA doesn’t allow the first command to call the service unless the end quotes are removed. The second command works with or without the containing quotes.

Also, in case it matters, the device info response lists Google on the second line for me, not the first:

adb_response: |-
  Google
  Chromecast
  SERIALNUMBER
  10
      link/ether MAC_ADDRESS brd ff:ff:ff:ff:ff:ff
  Device "eth0" does not exist.

Thanks