Pause movie when light is switched on

Tags: #<Tag:0x00007fc41c6bd220> #<Tag:0x00007fc41c6bd158>

(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!