Controlling New Chromecast with Google TV

Must have been a coincidence because, I haven’t seen any since. Thanks for the verification though.

Have you tried calling media_player.select_source with your various sources? I have found that a few “just work” and the rest work “sometimes”. If I use “source: com.netflix.ninja” – it always loads Netflix. But if I use “source: com.amazon.amazonvideo.livingroom”, it almost never loads it.

Any thoughts?

I hope someone can help me with this.
I am trying to send fast ADB commands (as outlined here).
I can send commands successfully when formatted as follows:

#This works flawlessly, albeit slowly.
alias: Send Up command
sequence:
  - service: androidtv.adb_command
    data:
      command: UP
    entity_id: media_player.livingroom_google_tv
mode: single

However, when I try to send the command captured with androidtv.learn_sendevent, I don’t get a response:

# I wish this worked, but it doesn't.
alias: Send Up command
sequence:
  - service: androidtv.adb_command
    data:
      command: 'sendevent /dev/input/event9 4 4 786498 && sendevent /dev/input/event9 1 103 1 && sendevent /dev/input/event9 0 0 0 && sendevent /dev/input/event9 4 4 786498 && sendevent /dev/input/event9 1 103 0 && sendevent /dev/input/event9 0 0 0'
    entity_id: media_player.livingroom_google_tv
mode: single

Has anyone gotten the fast commands to work? I have searched this forum and everywhere on google and I have yet to find a single instance of someone using this. I have both an Nvidia Shield TV and a Chromecast with GoogleTV. Their respectively captured fast commands do not work for either.

I have tried installing the “Android Debug Bridge” Hass addon, thinking that was the issue (As the Chromecast is quite new) but I haven’t seen a difference.

Here is my config:
    # NVIDIA SHIELD Integration through Android TV
  - platform: androidtv
    name: Basement NVIDIA Shield
    host: 192.168.1.IP
    apps:
      com.liskovsoft.videomanager.beta: Youtube
      com.spotify.tv.android: Spotify
      com.plexapp.android: Plex
      com.nvidia.tegrazone3: GeForce
      org.dolphinemu.dolphinemu: Dolphin Emulator
      com.google.android.tvlauncher: Home Menu
    state_detection_rules:
      'com.liskovsoft.videomanager.beta': 
        - 'playing':
            'wake_lock_size': 2
        - 'paused':
            'wake_lock_size': 0
      'com.plexapp.android':
        - 'playing':
            'media_session_state': 3
#            'wake_lock_size': 3
        - 'paused':
            'media_session_state': 2
#            'wake_lock_size': 0
        - 'idle'
      'com.nvidia.tegrazone3':
        - 'playing':
            'wake_lock_size': 2
        - 'paused':
            'wake_lock_size': 0 #Even if playing but out of the screen.

#Tried using the ADB server for the googleTV instead of the python. No difference.
- platform: androidtv
    name: Livingroom Google TV
    host: 192.168.1.IP
    adb_server_ip: 127.0.0.1 # IP for the HA add on 
    adb_server_port: 5037 # port on the ADB server add on`
    apps:
      com.liskovsoft.smarttubetv.beta: Youtube
      com.plexapp.android: Plex
      com.spotify.tv.android: Spotify
    state_detection_rules:
      'com.liskovsoft.smarttubetv.beta': 
        - 'playing':
            'wake_lock_size': 0
        - 'paused':
            'wake_lock_size': 2
      'com.plexapp.android':
        - 'playing':
            'media_session_state': 3
        - 'paused':
            'media_session_state': 2
        - 'idle'

and…

Here are my learned events:
    # GoogleTV:
    # Down: sendevent /dev/input/event9 4 4 786499 && sendevent /dev/input/event9 1 108 1 && sendevent /dev/input/event9 0 0 0 && sendevent /dev/input/event9 4 4 786499 && sendevent /dev/input/event9 1 108 0 && sendevent /dev/input/event9 0 0 0
    # Up: sendevent /dev/input/event9 4 4 786498 && sendevent /dev/input/event9 1 103 1 && sendevent /dev/input/event9 0 0 0 && sendevent /dev/input/event9 4 4 786498 && sendevent /dev/input/event9 1 103 0 && sendevent /dev/input/event9 0 0 0
    # Left: sendevent /dev/input/event9 4 4 786500 && sendevent /dev/input/event9 1 105 1 && sendevent /dev/input/event9 0 0 0 && sendevent /dev/input/event9 4 4 786500 && sendevent /dev/input/event9 1 105 0 && sendevent /dev/input/event9 0 0 0
    # Right: sendevent /dev/input/event9 4 4 786501 && sendevent /dev/input/event9 1 106 1 && sendevent /dev/input/event9 0 0 0 && sendevent /dev/input/event9 4 4 786501 && sendevent /dev/input/event9 1 106 0 && sendevent /dev/input/event9 0 0 0
    # Select: sendevent /dev/input/event9 4 4 786497 && sendevent /dev/input/event9 1 353 1 && sendevent /dev/input/event9 0 0 0 && sendevent /dev/input/event9 4 4 786497 && sendevent /dev/input/event9 1 353 0 && sendevent /dev/input/event9 0 0 0
    # Back: sendevent /dev/input/event9 4 4 786980 && sendevent /dev/input/event9 1 158 1 && sendevent /dev/input/event9 0 0 0 && sendevent /dev/input/event9 4 4 786980 && sendevent /dev/input/event9 1 158 0 && sendevent /dev/input/event9 0 0 0
    # Circle: sendevent /dev/input/event9 4 4 786979 && sendevent /dev/input/event9 1 172 1 && sendevent /dev/input/event9 0 0 0 && sendevent /dev/input/event9 4 4 786979 && sendevent /dev/input/event9 1 172 0 && sendevent /dev/input/event9 0 0 0
    # SwitchApp: sendevent /dev/input/event9 4 4 786979 && sendevent /dev/input/event9 1 172 1 && sendevent /dev/input/event9 0 0 0 && sendevent /dev/input/event9 4 4 786979 && sendevent /dev/input/event9 1 172 0 && sendevent /dev/input/event9 0 0 0 && sendevent /dev/input/event9 4 4 786979 && sendevent /dev/input/event9 1 172 1 && sendevent /dev/input/event9 0 0 0 && sendevent /dev/input/event9 4 4 786979 && sendevent /dev/input/event9 1 172 0 && sendevent /dev/input/event9 0 0 0
    # Play/Pause: sendevent /dev/input/event8 4 4 589836 && sendevent /dev/input/event8 1 315 1 && sendevent /dev/input/event8 0 0 0 && sendevent /dev/input/event8 4 4 589836 && sendevent /dev/input/event8 1 315 0 && sendevent /dev/input/event8 0 0 0

    #ShieldTV:
    # Up: sendevent /dev/input/event4 4 4 786498 && sendevent /dev/input/event4 1 103 1 && sendevent /dev/input/event4 0 0 0 && sendevent /dev/input/event4 4 4 786498 && sendevent /dev/input/event4 1 103 0 && sendevent /dev/input/event4 0 0 0
    # UP: sendevent /dev/input/event4 4 4 786498 && sendevent /dev/input/event4 1 103 1 && sendevent /dev/input/event4 0 0 0 && sendevent /dev/input/event4 4 4 786498 && sendevent /dev/input/event4 1 103 0 && sendevent /dev/input/event4 0 0 0
    # Down: sendevent /dev/input/event4 4 4 786499 && sendevent /dev/input/event4 1 108 1 && sendevent /dev/input/event4 0 0 0 && sendevent /dev/input/event4 4 4 786499 && sendevent /dev/input/event4 1 108 0 && sendevent /dev/input/event4 0 0 0
    # Left: sendevent /dev/input/event4 4 4 786500 && sendevent /dev/input/event4 1 105 1 && sendevent /dev/input/event4 0 0 0 && sendevent /dev/input/event4 4 4 786500 && sendevent /dev/input/event4 1 105 0 && sendevent /dev/input/event4 0 0 0
    # Right: sendevent /dev/input/event4 4 4 786501 && sendevent /dev/input/event4 1 106 1 && sendevent /dev/input/event4 0 0 0 && sendevent /dev/input/event4 4 4 786501 && sendevent /dev/input/event4 1 106 0 && sendevent /dev/input/event4 0 0 0
    # Select: sendevent /dev/input/event4 4 4 786497 && sendevent /dev/input/event4 1 353 1 && sendevent /dev/input/event4 0 0 0 && sendevent /dev/input/event4 4 4 786497 && sendevent /dev/input/event4 1 353 0 && sendevent /dev/input/event4 0 0 0
    # Back: sendevent /dev/input/event4 4 4 786980 && sendevent /dev/input/event4 1 158 1 && sendevent /dev/input/event4 0 0 0 && sendevent /dev/input/event4 4 4 786980 && sendevent /dev/input/event4 1 158 0 && sendevent /dev/input/event4 0 0 0
    # Home: sendevent /dev/input/event4 4 4 786979 && sendevent /dev/input/event4 1 172 1 && sendevent /dev/input/event4 0 0 0 && sendevent /dev/input/event4 4 4 786979 && sendevent /dev/input/event4 1 172 0 && sendevent /dev/input/event4 0 0 0
  

Hope someone has some insight into this, it is quite frustrating.

I’ve been struggling with this same thing. Have you figured anything out yet?

Unfortunately not yet. I can sidestep the issue by sending commands through my SamsungTV integration, and those seem fast enough, but I’d prefer to have the google integration work.

On discord someone mentioned that those commands only work when the remote is actively connected to the chromecast. Otherwise when the remote falls asleep, those commands apparently stop working. I was not able to replicate this, though. No matter if my remote had just been used or not, the Adb commands don’t work. So no progress there.

Yeah. I don’t think the remote being inactive is the problem. I’m getting nowhere with this though. Hopefully some clever person will be kind enough to let us know when they figure it out.

1 Like

That’s because sendevent command doesn’t work on CCwGTV. You’ll get “Permission denied” error when trying to do that.

Please try this script I created: https://github.com/redphx/hassio-cookbook/tree/main/scripts/androidtv_press_buttons

2 Likes

Will usb debugging work with usb hub or any other usb device connected? On mibox s it is impossible. When turning on usb debugging usb power is cut off so it is not possible to use for example usb ethernet adapter at the same time. I would like to know before I buy it as I want to add ethernet connection (hub).

Thanks @redphx, I will have to try that out! If you wouldnt mind, I’d love an explanation for how your script works.

As for your question @Wojtas, I assume you want to connect a USB hub to the “Chromecast with Google TV” and youre wondering if you’d be able to still use USB debugging? I imagine yes, because currently I have no USB connected to the device, and yet despite that, I am getting all the network debugging features. So I imagine adding a USB device/hub will not change that.

1 Like

Basically it combines multiple buttons into one command instead of sending command buttons one by one.

Had the same problem. I tried with adb server and adb-python but both didn’t stop freezing.
I think disabling the screencap at androidtv integration fixes the problem.

Hi all, thanks for sharing this information. I see that Tivimate app also shows a status of “paused”. I suspect a possible issue with the app itself but I’m not sure. Have any of you had any luck with this?

I had an issue similar to this and setting the custom state detection helped:

1 Like

Is this possible with the built-in Python implementation since the ADB add-on was depreciated?

1 Like

I have my google tv working thanks to you, but i didn’t have to install ADB. (Also couldn’t find it anywhere.) Now the androidtv does always say idle, and i can’t see any of the attributes you have. Does it still work for you? I’m trying to find the app id’s. Any help is appreciated. Thanks

@sgobat and @NiMa008

I didn’t realise that the ADB add on was depreciated. I must have missed that. For my Chromecast with Google TV (CCwGTV) it is still working just fine using the deprecated add on. I don’t have reason (and time) to check out the Python implementation to see if it works so perhaps anyone else who comes across this thread can report back on whether it works.

I’m considering to new Chromecast with Google TV but hard remote controls (also because my AVR is in a rack in another room). Before embarking on it a couple of questions seeing that some of you have succeeded here.

Reading this thread I understand all I’d need is to install the Android TV Integration to make this device available.

What about the navigation? Does this essentially mimic the remote?

What do you guys use for the UI? Standard media player?

Lastly how is the performance, i.e. integration?

Same issue here, using the androidtv integration I don’t see he attributes for sources, volume, etc. of my devices. I can see my android tv devices (nVidia Shields) but they’re just idle.

You will need to provide more information @Piepke82

Here is my TLDR after reviewing the thread

  1. I just added:
media_player:
  - platform: androidtv
    name: CwGTV
    host: 192.168.10.59
  1. Restart HA

  2. On CwGTV I went to:

Settings (highlight profile in top right and it's under that) 
> System > About > build number (click 7 times); then
  1. then
Settings > System > Developer Options > USB Debugging (enable)
  1. Important you will receive a notification asking you to confirm authorisation for a device trying to connect - that should be HA.
    If you don’t then HA will not be able to receive information and in my case, it did not create my entity till I accepted the auth.

I can’t control my volume as my CwGTV volume is controlled via IR to my sound bar.

Thanks to all for the information to get this working. Can’t believe it still changes to “Netflix” with “unknown” status …

2 Likes

I’m not sure if I fully understand the problem, but I have my new CCwGTV for a couple of weeks now.
I added it to HA through the regular Google cast integration and seem to have all the state-attributes I had before with my CCU. No difference in managing device through HA just had to substitute the entity name everywhere.