Automation Question - Resume cast audio

Tags: #<Tag:0x00007f739e9fdf58>

Been struggling trying to figure out a way to resume cast audio in the event it is interrupted by one of my “open door/open window” audio alerts.

For example, I have a script to play Internet Radio to one of my Google Minis via Home Assistant. I have automations that cast “Front Door is Open” to selected minis. The issue is, if I’m playing Internet Radio on one of them - it doesn’t resume.

Does anyone have an example of how to best handle this if there is a way?


- Mark

You should be able to look at the media_content_id and stuff like that under attributes in Developer Tools. Try looking on the forums for other questions (search keyword: resume music).
PS: your - rendered as a bullet point, try using backticks around it, like this:
- Kendell

Probably should have mentioned I made *.mp3 audio files from the Google TTS output files for my automation to avoid it from needing the Internet/cloud and could play them local.

What would be ideal is somehow to “save state” of the google mini prior to running the door/window MP3 playing, so it could return to what it was playing previously.

Here is an example of one of my automations. At the end, it has a condition to return to playing a 12 hour whitenoise if it is nighttime.

 - id: Doors_and_Windows_Opened
  alias: 'Doors and Windows Opened'
  initial_state: 'on'
    platform: state
      - binary_sensor.front_door
      - binary_sensor.garage_entry_door
      - binary_sensor.kitchen_sliding_door
      - binary_sensor.foyer_window
      - binary_sensor.basement_sliding_door
    from: 'off'
    to: 'on'
  mode: restart
#    - service: script.radio_paused_for_message
    - service: switch.turn_on
        - switch.beep_beep
        - switch.beep_beep_2
    - service: media_player.play_media
        - media_player.marks_office_hub
        - media_player.foyer_mini
        - media_player.master_bedroom_mini
        - media_player.family_room_mini
        - media_player.basement_mini
        media_content_id: >
        media_content_type: 'music'
#    - service: script.resume_radio_paused_for_message
    - condition: time
      after: '22:00:00'
      before: '06:30:00'
    - delay:
        seconds: 11
    - service: media_player.play_media
          - media_player.master_bedroom_mini
        media_content_id: ''
        media_content_type: 'music'

Basic outline:

  • Make a couple of input_texts
  • Do something like this before you change it
    - service: input_text.set_value
        entity_id: input_text.media_id
        value: '{{state_attr(''media_player.mything'', ''media_content_id'')}}'
  • Later call media_player.play_media

Or you could use the scene create / restore actions to save your player’s state, anounce the message then restore the state.

See the example here:

Great suggestions! Going to start tinkering, thanks!

Here is an example of my Google Office Hub playing Pandora. Currently, if the door opens and it plays the “Front Door is Open” mp3, it will stop Pandora and not resume.

Could capturing the media_content_id here allow it to resume? The other thing I just thought of, it is could get hosed up because it will say “Front Door Open”, then another MP3 for “Front Door Closed” shortly after (normally). It could potentially capture the previous automation’s info and still break the resuming of Pandora.

media_player.marks_office_hub	playing	volume_level: 0.26999998092651367
is_volume_muted: false
media_content_type: music
media_duration: 515
media_position: 29
media_position_updated_at: 2020-08-02T20:18:54.721885+00:00
media_title: The Grudge
media_artist: TOOL
media_album_name: Lateralus
media_album_artist: TOOL
app_id: 211CD751
app_name: Pandora
entity_picture_local: /api/media_player_proxy/media_player.marks_office_hub?token=0675489837cecfd42628574c53ee8d8ff9f62f17016ed40f8fdb50083c5bd85e&cache=34de9a4c7329f963
friendly_name: Mark's Office Hub
supported_features: 21437