Pause movie when light is switched on

(This will make sense to people with projectors.)

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.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

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
2 Likes

No…
Maybe it’s just me not getting it, but could you explain?

Sure.

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.

I have a lot of usercases…

  • toilet breaks, motion sensor turns on light -> pause media
  • smoking breaks, motion sensor turns on light -> pause media
  • refill wine, motion sensor turns on light -> pause media

I LOVE IT! thanks!!

Very interesting, thanks for sharing. That was the first blueprint I imported, and I like the experience :slight_smile:

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.

My mileage did vary :slight_smile:

Thanks for a simple and useful blueprint!

1 Like

Is there any way to reverse this? When I pause the movie, the lights turn on?

Just use the light as the trigger and the media_player.pause as the action.

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.

Will do when I get home from work. Can’t do this on mobile.

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?

Can this be solved somehow?

I Did mine the other way

when Playing dim lights and Pause brighten lights

- id: f8f6c2cd-8749-456a-ac8f-bff806cf942b
  alias: Watching movie Paused
  trigger:
  - platform: state
    entity_id: media_player.tv_65
    to: paused
  condition:
    condition: and
    conditions:
    - condition: state
      entity_id: sensor.day_night
      state: Night
    - condition: state
      entity_id: light.shelly_lounge
      state: 'on'
  action:
  - data_template:
      entity_id: script.movie_off
    service: script.turn_on
- id: 29d06f19-0ab3-442a-9638-4de513ffb7d7
  alias: Watching move play
  trigger:
  - platform: state
    entity_id: media_player.tv_65
    to: playing
  condition:
    condition: and
    conditions:
    - condition: state
      entity_id: sensor.day_night
      state: Night
    - condition: state
      entity_id: light.shelly_lounge
      state: 'on'
    - condition: state
      entity_id: input_boolean.watching_movie
      state: 'on'
  action:
  - data_template:
      entity_id: script.movie_on
    service: script.turn_on

then the 2 scripts

movie_on:
  sequence:
  - service: light.turn_on
    data:
      entity_id: light.shelly_lounge
      brightness_pct: 40
movie_off:
  sequence:
  - choose:
    - conditions:
      - condition: state
        entity_id: light.shelly_lounge
        state: 'on'
      sequence:
      - service: light.turn_on
        data:
          entity_id: light.shelly_lounge
          brightness_pct: 100
2 Likes

Would something like this work to pause YouTube TV, say if the Nest doorbell was rung??