Automation to stop runaway autoplay on YTTV

Hi all. I have developed an automation that I’d like to share. I hope this is the right place/topic for doing so.

It solves a problem with YoutubeTV, namely that they autoplay the next episode in a series once the current one is finished. The will do this ad infinitum, and will even switch to another series if they run out of episodes. This is a problem if you’re someone like me to tends to fall asleep in front of the TV in the evening. It totally messes up the history of watched episodes.

There is no way to disable this behavior despite lots of people asking YTTV for it. So as ridiculous as it sounds, I had to take matters into my own hands with this automation. It simply shuts off playback if the player hasn’t been interacted with for a set amount of time. Here is that YAML:

alias: Turn off Roku Ultra if I fall asleep
description: Turns off Roku if left playing without interaction for a set time
triggers:
  - entity_id: media_player.roku_ultra
    to: playing
    for:
      minutes: "{{ states('input_number.roku_sleep_timer_minutes') | int(75) }}"
    trigger: state
conditions: []
actions:
  - target:
      entity_id: remote.roku_ultra
    data:
      command: home
    action: remote.send_command
mode: single

You can substitute other kinds of streaming players for Roku, of course.

It works with a helper input_number.roku_sleep_timer_minutes, which I set up with min 30 and max 240 minutes and 15 minute increments. That gets set by a mushroom number card that I put on one of my dashboards so if I’m watching a longer program like a football game I can easily change the timeout without editing the automation.

1 Like