Automation Question - Resume cast audio

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

@MarkHofmann11did you ever get this resolved?

Unfortunately, not. Part of the issue is I have a door open and door closed automation. If you open/close a window/door quickly, even if I was able to save the music playing prior to the open, the close would save the door open audio as being the last thing playing vs music. Just can’t figure out a perfect solution for this. First, I would need to ensure my door/window open/close automations were the same automation (not two different ones). Then maybe saving the audio prior to triggering would work. Just seems like there should be a much easier way to do this.

It would be so much easier if there was a “service snapshot” and “service restore” option similar to what you can do with the sonos speakers.

Did you ever make any progress on this? I am doing my own research now. I was wondering if my cast implementation would help your concern of the automations being done in the same automation. Basically I created a nodered flow to receive homeassistant/speak mqtt messages to initiate casts to speakers independent of the original automations.

Unfortunately not. I have never been able to “save/store” the previous status of what was playing on the Google mini/hub speakers to play “Front Door Open”, and then have it return to playing the same thing. Cast just stops whatever is playing and doesn’t resume.

The work-around would be to have dedicated google minis for different things. Not optimum, but I have no other solution at the present time.