Automation Question - Resume cast audio

Tags: #<Tag:0x00007f7397dd32d8>

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?

Thanks!

- 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'
  trigger:
    platform: state
    entity_id: 
      - 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
  action:
#    - service: script.radio_paused_for_message
    - service: switch.turn_on
      entity_id:
        - switch.beep_beep
        - switch.beep_beep_2
    - service: media_player.play_media
      entity_id:
        - media_player.marks_office_hub
        - media_player.foyer_mini
        - media_player.master_bedroom_mini
        - media_player.family_room_mini
        - media_player.basement_mini
      data_template:
        media_content_id: >
            http://192.168.0.14:8123/local/{{trigger.entity_id}}_is_open.mp3
        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
      data:
        entity_id:
          - media_player.master_bedroom_mini
      data_template:
        media_content_id: 'http://192.168.0.14:8123/local/White_Noise_10hrs.mp3'
        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
      data_template:
        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: https://www.home-assistant.io/integrations/scene/#creating-scenes-on-the-fly

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_id: http://audio-sv5-t1-2-v4v6.pandora.com/access/4225969463000742574.mp4?version=5&lid=177595983&token=ekKLDAkCa8iEEKcPqsAkzmCqyydFAjwIcBxHTv6uYBx0J2XwVIsRnsF%2FtMmeXrmZMDm7%2FduaP%2Bx8uN0zrT%2FI511KddPYlEFBLF%2FBriTzMwYjUcG3bHfXmxvK23TGoTTdq5Lgp2A7UlTBCJS5bhPMyb%2BuneBYQen9X%2Fqef%2FvrwcuNzQa%2BLGLVStqjz6FJIfFdiPiUe%2FXwD%2F8IHzgNgWw2dDiu2CvlRB2RqgNgDsjUMz6aZpBnmzSocY39MVfQOBh6ZZ96DOedlhVmkypGBze9ahnvSUgB%2FUumFKIB4u6mFa5GhnKGC7Q86FmntdiPdp8Me1OVjbdhICPVn5pDr8iPgA%3D%3D
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
entity_picture: http://cont-4.p-cdn.us/images/public/int/4/6/7/4/886447824764_500W_500H.jpg
supported_features: 21437