The method explained in the original post below no longer works. I expect this is due to optimizations to automations in recent HA versions and/or changes to Netflix’s streaming interface. My current workaround isn’t nearly as fancy and doesn’t skip credits, it just quickly pauses and plays a Netflix show 10 seconds into the episode. 10 seconds seems to be the earliest to keep this consistent. This is enough interaction that “Are you still watching?” will never display.
- alias: Perpetual Netflix
trigger:
platform: state
entity_id: media_player.downstairs_tv
to: playing
from: idle
for:
seconds: 10
condition:
condition: template
value_template: >
{{ state_attr('media_player.downstairs_tv', 'app_name') == 'Netflix'}}
action:
- service: media_player.media_pause
entity_id: media_player.downstairs_tv
- service: media_player.media_play
entity_id: media_player.downstairs_tv
Original Post
Thought I’d share this one as I find it pretty handy.
Recently my son has started watching a couple of educational shows on Netflix. These shows are around 5 minutes long and that causes the show to pause with the “Are you still watching?” screen way too often since it seems that’s based on episode count rather than time.
This automation checks how much time is left in the episode and uses the media_player.media_play
service during the end credits when Netflix’s next episode countdown timer appears, causing the credits to be skipped and the next episode to be played. This interaction also causes the “Are you still watching?” screen to never appear. Since it’s only using the media_play service, you won’t see any interruption if this is triggered before the credits appear.
Just change the 3 media_player.downstairs_tv
with the media player of your choice. The “or” values in set duration
and set position
are there to prevent errors if the media player is unavailable.
The automation is triggered at a few different intervals (15, 30, 45, and 60 seconds remaining) as some show’s end credits are longer than others. You can add more intervals if you find a show this doesn’t work on. Just pause the offending show right before the credits and go to Developer Tools > Templates
. Add this template {{ state_attr('media_player.your_player', 'media_duration') - state_attr('media_player.your_player', 'media_position') }}
. This will show you the remaining seconds. Add a few seconds to the time shown and insert a new durarion - position
calculation to the trigger’s template:
I use this with chromecast devices, I’m not sure if the media_duration, media_position, and app_name attributes are available on all media_players. I’m sure the automation could be optimized, but it’s been working well for me the past week.
- alias: Perpetual Netflix
trigger:
- platform: template
value_template: >-
{% set player = 'media_player.downstairs_tv' %}
{% set duration = state_attr(player, 'media_duration') or 1000 %}
{% set position = state_attr(player, 'media_position') or 0 %}
{{
duration - position < 15 or
duration - position < 30 or
duration - position < 45 or
duration - position < 60
}}
condition:
condition: template
value_template: >-
{{ state_attr('media_player.downstairs_tv', 'app_name') == 'Netflix' }}
action:
- service: media_player.media_play
entity_id: media_player.downstairs_tv