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

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

Result of first command looks slightly different than yours, while at the home screen:


adb_response: >-
  111Wake Locks: size=2

  DockedStackDivider}:


  - 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
  u0_a38        3970  3503 1348168 105416 0                   0 S
  com.android.systemui

  u0_a42        4217  3503 1304408  80416 0                   0 S
  com.google.android.tv.remote.service

  u0_a56        4243  3503 1394592 165664 0                   0 S
  com.google.android.inputmethod.latin

  u0_a34        4281  3503 1461928 130188 0                   0 S
  com.google.android.gms.persistent

  u0_a34        4448  3503 1626620 141100 0                   0 S
  com.google.android.gms

  u0_a34        4478  3503 1306724  78728 0                   0 S
  com.google.process.gservices

  u0_a31        4492  3503 1764736 120508 0                   0 S
  com.google.android.katniss:interactor

  u0_a37        4566  3503 1369812 143500 0                   0 S
  com.google.android.apps.tv.launcherx:coreservices

  u0_a71        4634  3503 1326244  96796 0                   0 S
  com.spotify.tv.android

  u0_a31        4776  3503 1821492 131648 0                   0 S
  com.google.android.katniss:search

  u0_a35        5038  3503 1318252  83952 0                   0 S
  com.google.android.tungsten.setupwraith

  u0_a41        5525  3503 1439892 114820 0                   0 S
  com.google.android.apps.mediashell

  u0_a46        5874  3503 1383740 134628 0                   0 S
  com.google.android.tts

  u0_a33        6094  3503 1299920  73096 0                   0 S
  com.google.android.tv.axel

  u0_a34        6481  3503 1423336 122244 0                   0 S
  com.google.android.gms.unstable

  u0_a72       16090  3503 1913524 291860 0                   0 S
  com.plexapp.android

  u0_a29       17942  3503 1367224 135252 0                   0 S
  com.google.android.apps.tv.dreamx

  u0_a39       18112  3503 1292288  67764 0                   0 S
  com.android.settings.intelligence

  u0_a37       24501  3503 1675632 246456 0                   0 S
  com.google.android.apps.tv.launcherx

  u0_a63       28503  3503 1832540 242736 0                   0 S
  com.google.android.youtube.tv

  u0_a63       29498  3503 1464556 114680 0                   0 S
  com.google.android.youtube.tv.recommendations

  u0_a4        29571  3503 1294892  78220 0                   0 S
  com.android.providers.tv

Second command matches your test_basetv_sync.py as well as @dg1024 test above:

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

Are we supposed to run those commands idle on the home screen? I’ve been running them during YouTube playback.

I’m happy to run the first command again while playing YouTube if that’s helpful.

This is what I’m getting when running the first command (with 'Window \#1' and A -11) while sitting idle on the homescreen:

adb_response: >-
  111Wake Locks: size=1

  com.google.android.apps.tv.launcherx


  - 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
  u0_a30        1983 16265 1292436  66856 0                   0 S
  com.google.android.partnersetup

  u0_a67        1998 16265 1328548 101812 0                   0 S
  com.rma.netpulsetv

  u0_a78        2014 16265 1591060 100960 0                   0 S
  com.plexapp.android

  u0_a44        2041 16265 1348040 105224 0                   0 S
  com.android.vending:instant_app_installer

  u0_a20       10858 16265 1616400 103832 0                   0 S
  tv.pluto.android

  u0_a3        12693 16265 1315328  83732 0                   0 S
  com.android.providers.tv

  u0_a38       16522 16265 1349984  51744 0                   0 S
  com.android.systemui

  u0_a56       16765 16265 1344856  55548 0                   0 S
  com.google.android.inputmethod.latin

  u0_a42       16783 16265 1303468  43644 0                   0 S
  com.google.android.tv.remote.service

  u0_a34       16836 16265 1466712 111504 0                   0 S
  com.google.android.gms.persistent

  u0_a34       16996 16265 1631748 122040 0                   0 S
  com.google.android.gms

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

  u0_a31       17060 16265 1774508  90948 0                   0 S
  com.google.android.katniss:interactor

  u0_a37       17151 16265 1359820  49876 0                   0 S
  com.google.android.apps.tv.launcherx:coreservices

  u0_a31       17358 16265 1860124 116100 0                   0 S
  com.google.android.katniss:search

  u0_a65       17721 16265 2081420 209120 0                   0 S
  com.netflix.ninja

  u0_a41       18289 16265 1489708  89032 0                   0 S
  com.google.android.apps.mediashell

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

  u0_a33       18896 16265 1300544  38680 0                   0 S
  com.google.android.tv.axel

  u0_a20       21215 16265 1655904 135512 0                   0 S
  tv.pluto.android:input

  u0_a8        23988 16265 1292608  75536 0                   0 S
  com.android.providers.calendar

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

  u0_a80       27749 16265 1317712  54624 0                   0 S
  com.google.android.tv

  u0_a37       29228 16265 1754432 249708 0                   0 S
  com.google.android.apps.tv.launcherx

@dg1024 and @grh6u5zp04kd

Thanks for testing it. Based on the output you posted, the change that I made should work. I submitted a pull request to HA: https://github.com/home-assistant/core/pull/42047

3 Likes

Thanks for your responsiveness throughout this. Looking forward to using it when it’s available!