YouTube on TV: see and control what the YouTube app on your TV is playing

Hi all,

I’ve built a custom integration that shows what the YouTube app on your TV is playing, and lets you control it from Home Assistant.

GitHub: GitHub - jorgediez/ha-youtube-on-tv: Home Assistant integration showing what the YouTube app on your TV is playing. · GitHub

Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

Why

TV integrations usually only report that “YouTube” is the active app, not what’s on screen. This one connects to the TV the same way the YouTube phone app does when you cast (YouTube’s Lounge protocol, via pyytlounge). The TV pushes updates instantly: no polling, no Google account, no API key.

What you get

  • Media player with title, channel, thumbnail, duration, position and play/pause state
  • Play, pause, seek, next/previous, and media_player.play_media with any video id or YouTube URL, which opens YouTube on the TV if it’s closed
  • Turn the player on/off to open and close YouTube on the TV
  • Ad playing sensor and a Skip ad button that becomes available as soon as the ad can be skipped
  • Autoplay and Subtitles switches, a Playback speed select, plus Video quality, Subtitles and Up next sensors
  • Auto-discovery of TVs (DIAL/SSDP) with no pairing code; a TV code works as a fallback

Auto-skipping ads is one small automation:

automation:
  - alias: Skip YouTube ads
    triggers:
      - trigger: state
        entity_id: button.youtube_on_samsung_neo_qled_skip_ad
        from: unavailable
    actions:
      - action: button.press
        target:
          entity_id: button.youtube_on_samsung_neo_qled_skip_ad

Testers wanted

It’s developed and tested on a Samsung Tizen TV (Neo QLED QN900F). LG webOS, Android/Google TV, Chromecast with Google TV, Fire TV and Roku use the same protocol and should work, but none are confirmed yet. If you have one, a quick report here or in Issues would help a lot: did discovery find the TV, and do the states look right?

Install

HACS → ⋮ → Custom repositories → add the repo as type Integration, download, restart. Requires Home Assistant 2026.3 or newer.

Thanks to FabioGNR for pyytlounge, and to iSponsorBlockTV, whose DIAL discovery work made code-free pairing possible.

Not affiliated with Google or YouTube. It relies on an undocumented protocol that YouTube may change at any time.

Feedback and ideas welcome!

4 Likes

Beta Testing as it is installed and configured on one of my Shield TV devices. What do I do with it?

Thanks, that’s great! Shield TV is one of the platforms I haven’t been able to confirm yet, so this really helps.
Can you run the following:

  1. Discovery: Did the Shield show up automatically under Settings → Devices & services, or did you have to pair it with the TV code?
  2. Playback from the TV: Start a video with the Shield remote. Does the media player show the title, channel and thumbnail, and does it follow play/pause and seeking?
  3. Control from HA: Try pause, play, seek and next from the media player card.
  4. Ads (if you get one): Does Ad playing turn on, and does Skip ad become available and work?

Then reply here with what worked and what didn’t. If something misbehaves, please let me know and attach the integration’s diagnostics if possible (the ⋮ menu on the integration entry → Download diagnostics).
Many thanks!

1.) I had to pair it with the 12-digit code. It would not pair with the IP Address. Kind of prefer it that way in case the device’s IP ever changes.
2.) Yes, it shows all of that.
3.) Need to try that.
4.) I have YouTube Premium so no ads.

Awesome, thanks for testing. And great to know that it works on a Shield TV.

Let me know if you experience any issue, thanks!

Very nice! I’ll create an automation that automatically skips ads when possible!!

1 Like

This is great stuff! I installed and successfully connected it (with code; discovery didn’t work) to the YouTube app running on an Onn 4k Android TV box. Controls all seem to be working as expected, including Skip ad; I’ll be testing out an automation for that next.

I’m also using a Samsung Tizen TV. Everything seems to work except that the “Skip Ad” option doesn’t become available when ads are playing.

Edit: Reinstalled it, and now the Skip Ads option is working. Also - the ad-playing entity is super useful for muting/unmuting sound while adverts play

Thanks a lot @Nik_Fiend for the thorough testing, and for the idea about muting/unmuting, that’s a great addition. Your feedback also made me go back to the skip ad logic, and I’ve reworked it so it should be more reliable across different devices.

Both changes are now out in v1.0.1, and you’re credited in the README for the help.

Also thanks @kahilzinger and @j_quadrifrons for testing on your devices. You’re now credited too, and it’s really useful to know which hardware it’s working on.

3 Likes

Quick update after a couple of days: the day after I set this up it stopped working for some reason; I wasn’t in the mood to troubleshoot it at the time, and by the time I looked at it, it was back up and running on its own. No issues since then. I tend to put long youtube playlists on in the background while I’m working, so the skip ad automation is a lifesaver, especially now in Political Ad Season.

Thanks for the feedback! The integration retries lost sessions with a gradual delay, so it makes sense that it was working again when you checked. Please let me know if it happens again though, and I’ll take a closer look.

Also, glad to hear you’re enjoying the skip ad automation!

1 Like

Hi,

I installed on my Hisense youtube tv. It was working great, Skipped ads and other controls worked.

Problem occurs when trying to play youtube shorts. I keeps giving and error saying it can’t play the short when a mobile device is connected. Give me the option to disconnect it, but that just fails back and repeats. Tried killing youtube on tv and restarting but same error again. Finally disconnected TV from inside HA and it started working agin.

Thanks

Thanks for reporting this!

This happens because the YouTube TV app blocks Shorts whenever a remote device is connected (which is how this integration controls the TV). Since Home Assistant automatically reconnects right away, the TV’s disconnect option and app restarts don’t work. Currently, the only workaround is breaking the connection entirely.

To fix this experience, I will release a new version that lets you disconnect the session without having to completely remove the integration. I will also update the documentation to make this limitation clear for everyone.

Thanks for your patience!

Thanks for the prompt reply.

Just a suggestion would be nice to be able to specify a delay time before reconnecting and also to have an action (button) to be able to disconnect and reconnect without on demand.

Thanks again
Mike

By any chance does this mean the skip ad setting can make it so I no longer have to pay for YouTube premium?

In theory it would be able to skip around 5s after an ad starts, but as far as I know it can’t skip unskippable ads (sometimes 5-30s long)

The only way to get YouTube without ads otherwise is to use a mobile client like Unwatched and a TV client like YouTube Adfree

v1.0.2 is out, with the Shorts fix I promised and a few things that came out of testing since.

Shorts can be watched again @mlmoore403 — as suspected, the TV refuses Shorts while any device is connected to it as a remote, which is why its own disconnect button didn’t help: the integration reconnected straight away. There’s now a Remote session switch: turn it off to watch Shorts, on again afterwards, and the choice survives a restart.

Your two suggestions are covered as automations rather than extra settings, so you can pick your own timing: a dashboard button that toggles the session, and an automation that reconnects after a set time. Both are in taking a Shorts break.

The Ad playing sensor could blink at the end of an ad @Nik_Fiend — it flipped off and on again for about a second, enough to make a mute automation unmute and re-mute. The TV sends one last “advertisement” state just after the ad ends, carrying the video’s duration; ads are now taken from the ad events instead, which bracket an ad cleanly. If you’re using the mute automation, this is worth updating for.

What Skip ad can and can’t do @kahilzinger @inventor7777 — now written down after your exchange: it presses skip when YouTube offers it, so unskippable ads still play in full, and muting is what covers those.

Outages leave a trace now @j_quadrifrons — after the drop you saw that fixed itself, a session that stays down for more than five minutes logs a warning with the reason, and logs its return. If it happens again there’ll be something to look at, and debug logging now shows every event a TV sends, so a report doesn’t need a special build.

Smaller things: a rejected or expired TV code says so instead of “failed to connect”, and the README is now a short overview with the detail in docs — entities, automations, behaviour, troubleshooting and development.

Also worth knowing: Android TV devices (Shield, Onn, Mi Box) don’t publish their YouTube app over the local protocol at all, so they can only be added with a TV code. That’s documented now, along with the features that need the TV’s address.

Update through HACS. Reports from other TVs are still very welcome — especially LG webOS, Fire TV and Roku, which nobody has tried yet.

4 Likes