Googlecast/Chromecast Play Youtube TV App/Channel

I’ve tried every combination of service calls for Chrome/Gcast to play the Youtube TV app with a specific channel. HA shows the content ID when I’m playing a channel, but is there a way to start an app/channel with a service call?

What did you try?

Should be something like media_player.play_media
with payload:

{
  "entity_id": "media_player.YOUR_CHROMECAST_NAME",
  "media_content_id": "MEDIA_URL",
  "media_content_type": "CONTENT_TYPE"
}

For CONTENT_TYPE it could be one of: VIDEO, EPISODE, CHANNEL or PLAYLIST

What happens if you pass the youtube channel URL?

Playing a channel or playing a specific video ?

You can use the media_extractor component to cast youtube videos

You need to following line in your config.yaml for component setup

media_extractor:

Sample script

media_extractor_test:
  alias: Media Extractor Test
  sequence:
    - service: media_extractor.play_media
      entity_id: media_player.lounge
      data:
        media_content_id: "https://www.youtube.com/watch?v=Pj0w0xo2ChY&list=PL71F771F239EF17F7"
        media_content_type: video/youtube
1 Like

I’m referring to the Youtube TV platform, not Youtube. Here’s the service:

media_position_updated_at: 2018-01-30T14:15:55.156006+00:00
media_content_id: OxaTMpYqrKU
friendly_name: Cast Loft
is_volume_muted: false
supported_features: 21437
app_id: 32EAB1DF
app_name: YouTube TV
volume_level: 1
media_duration: 14389
media_position: 11820.399

@eswiderski did you ever figure this out? I’m interested in doing this as well, but the media_extractor.play_media example doesn’t work.

Nope, but would love it.

apparently the service call does not support playlists when called from an automation. Calling the playlist from the front-end dev console allows for playing back youtube playlists though … weird.

I did this It but i can see the video without audio, if I change the media_content_type to YouTube I ear audio without video so how I can do to get both at the seem time?

@eswiderski this is way afterwards, but I’m still looking to figure out how to do this. Did you have any luck? I’m assuming that Google’s restrictive API policy is probably insurmountable, but just wanted to check since this is basically the only thread I can find that references this…

Hey, after a lot of mucking about I was able to get this working on my android TV using ADB commands.

In order to use this service, you must enable the android TV integration and set up an android TV media player. https://www.home-assistant.io/integrations/androidtv/

service: androidtv.adb_command
data:
  entity_id: media_player.android_tv
  command: >-
    am start -a android.intent.action.VIEW -d
    "https://www.youtube.com/watch?v=w4btM4maxKU&list=PL8TioFHubWFucN8uHuSR0cptOzTqYLjC8"
    com.google.android.youtube.tv

This will play a YouTube playlist link, individual videos, perhaps other types of YouTube content links. I was able to find the ‘recent videos’ playlist link on a desktop web browser when browsing my son’s favourite YouTube channel.

this sadly doesnt work for me

  - service: androidtv.adb_command
    target:
      entity_id: media_player.fire_tv_living_room
    data:
      source: "com.netflix.ninja"

This command opens Netflix, but yours doesnt work

also change yours to

    - service: androidtv.adb_command
      target:
        entity_id: media_player.firetvstick_1
      data:
        command: >-
          am start -a android.intent.action.VIEW -d
          "https://www.youtube.com/watch?v=L_LUpnjgPso"
          com.google.android.youtube.tv

still doesnt work
EDIT: using a firetvstick

SOLUTION:

    - service: androidtv.adb_command
      target:
        entity_id: media_player.firetvstick_1
      data:
        entity_id: media_player.firetvstick_1
        command: "am start -a android.intent.action.VIEW -d https://www.youtube.com/watch?v=L_LUpnjgPso com.amazon.firetv.youtube/dev.cobalt.app.MainActivity"

they changed the source to com.amazon.firetv.youtube/dev.cobalt.app.MainActivity

I got this working on the Nvidia Shield TV with this:

service: androidtv.adb_command
metadata: {}
data:
  command: >-
    adb shell am start -a android.intent.action.VIEW -d
    "https://www.youtube.com/watch?v=6hCqRb8Dtvo&list=RDEMb1vAi4rwXXeDlr7NZ68C_w"
target:
  device_id: ************

It’s playing a YouTube music playlist, however I was wondering if anyone knew how to have this play on shuffle when casting.