This is a blueprint for an automation that pauses movie playback when a certain light is turned on. If you switch the light back off within a defined timeout, it resumes playback.
It tries to detect when only music is playing (as opposed to a movie), but I only tested with YouTube Music on a Chromecast so YMMV.
blueprint:
name: Pause movie when light on
description: Pauses movie playback when a certain light is turned on.
domain: automation
input:
media_player:
name: Media player
description: This media device will be paused.
selector:
entity:
domain: media_player
light:
name: Light
description: Turning this light on will pause playback.
selector:
entity:
domain: light
timeout:
name: Resume playback timeout
description: If the light is turned back off within this time, playback will resume.
default: 5
selector:
number:
min: 0
max: 999
unit_of_measurement: minutes
mode: box
mode: single
trigger:
- platform: state
entity_id: !input light
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: !input media_player
state: playing
- condition: not
conditions:
- condition: state
entity_id: !input media_player
state: music
attribute: media_content_type
action:
- service: media_player.media_pause
entity_id: !input media_player
- wait_for_trigger:
- platform: state
entity_id: !input light
from: 'on'
to: 'off'
continue_on_timeout: false
timeout:
minutes: !input timeout
- service: media_player.media_play
entity_id: !input media_player
Use case #1: I’m watching a movie. Someone comes into the room and turns the light on. The movie pauses as I can’t really watch it anyway with the light on.
Use case #2: I’m watching a movie. I want to get up and get a drink. I turn the light on and the movie pauses automatically. Two actions for the price of one.
Very interesting, thanks for sharing. That was the first blueprint I imported, and I like the experience
For anyone playing with this: I’ve tested with a chromecast media player and I had just an youtube video playing. The automation would not trigger; I had to remove the filter condition for state not music, for whatever reason that was being triggered by the video I was playing. Since I don’t play music on this chromecast (I have chromecast audio devices for that), I will not need this filter.
I need help please. I made an automation to manipulate lights when Chromecast with google TV is either playing or paused and it’s working well but I can’t seem to get it to NOT trigger when fast-forwarding or reversing.
anybody have any idea how to do that? I tried media position under conditions but that didn’t work
Post a new question with all the details.
The entity, the current automation, what it does, what it should do, then we can answer.
But posting in another thread like this with barely any details is not ideal.
Error evaluating condition in ‘Pause movie when light on’: In ‘condition’ (item 2 of 2): In ‘not’: In ‘state’: In ‘state’ condition: attribute ‘media_content_type’ (of entity media_player.ultra) does not exist
What could this mean in the log?
Guess it has something to do with the media I play does not have attribute ‘media_content_type’ and this is needed for it not to pause music?