Script to resume Google Cast devices after they have been interrupted by any action

I’m trying to remove the previous scripts + automation but can’t seem to find the original file locations. HA won’t let me delete from the GUI, and they’re not present in my automations.yaml and scripts.yaml. Any clue where they’re hiding? Running HAOS on baremetal.

If you followed the install instructions they are probably in a folder called packages

Yeah, that was my first instinct. I’ve searched my entire config directory, tried searching strings of yaml from the automation + scripts to see if it hits…nothing’s come up. Really weird.

And what is the state of the scripts and automation?

They’re active, triggered as recently as yesterday. It gives me the option to migrate, but says I’d still need to delete the original.

@prockeo We use SiriusXM almost exlusiviely in our home. I noticed that the media_content_id now shows a value, like a URL. Would this integration now work with SirusxXM?

thanks

also, I don’t have any speaker groups not radio stations. I’m wondering if this is a vald setting. I don’t knomw what to place for the voice_settings?

homeassistant:
  customize:
    script.google_home_resume:
      # enter settings for the script here, all settings are optional, you can remove sections if you don't need them
      # always leave the line with "settings: &settings" in!
      settings: &settings
        default_volume_level: 0.25
        dummy_player: media_player.vlc_telnet
        default_resume_delay:
          seconds: 20
        max_runtime:
          minutes: 10
        # settings for automation
        enable_automation: false
        dashboard_cast: true
        announce_volume_automation: 0.4
      # settings for voice script
      voice_settings: &voice_settings
        check_for_title: "Witte ruis"
        use_resume: true

If that url contains a media stream, it should work.
The voice settings are used if you want to issue voice commands and send a response to the device on which you issued the command.

1 Like

Any luck with Sirius XM? I typically use Sirius XM, Pandora, or local Plex to play music. None of which are working OOTB. I will dig further, just wondering if you’ve had success or not.

I don’t have subscriptions to these services, nor a Plex server. I don’t have the ability to test this.

I expect integrations like Spotcast for Spotify are required to resume Sirius XM and Pandora. For Plex I know there is an integration, but I’m not sure if resume can be achieved using that. But like I said, I don’t have the opportunity to test this myself

Hi,

Can you help me? The script does not resume music played from Spotify.

I have only done basic configuration in the script.

homeassistant:
  customize:
    script.google_home_resume:
      # enter settings for the script here, all settings are optional, you can remove sections if you don't need them
      # always leave the line with "settings: &settings" in!
      settings: &settings
        primary_spotcast: "jszkiela72"
    #     radio_data:
    #       NPO Radio 2:
    #         picture: "http://192.168.2.3:8123/local/pictures/radio/npo_radio_2.png"
    #         title: "Er is maar één NPO Radio 2"
    #       Radio Veronica:
    #         picture: "http://192.168.2.3:8123/local/pictures/radio/radio_veronica.png"
    #         title: "WE. LOVE. MUSIC."
    #       Willy:
    #         picture: "http://192.168.2.3:8123/local/pictures/radio/willy.png"
    #         title: "MUSIC MATTERS"
    #       KINK:
    #         picture: "http://192.168.2.3:8123/local/pictures/radio/kink.jpg"
    #         title: "NO ALTERNATIVE"
    #    speaker_groups:
    #      media_player.dom:
    #        - media_player.kuchnia_lewy
    #        - media_player.kuchnia_prawy
    #        - media_player.glosnik_w_lazience
        #     - media_player.woonkamer_home
        #     - media_player.werkamer_marleen_minini
        #     - media_player.zolder_werkkamer_stereo

The script is run by automation.

alias: Test Piper
description: ""
trigger:
  - type: turned_on
    platform: device
    device_id: d990d2bbdf6036200cb7f594f4b03059
    entity_id: 336a7df9ca51a4854efd1a11bd55fb35
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 1
condition: []
action:
  - action: script.google_home_resume
    metadata: {}
    data: {}
  - action: media_player.play_media
    target:
      entity_id: media_player.glosnik_w_lazience
    data:
      media_content_id: >-
        media-source://tts/tts.piper?message=Witaj+Jarek%2C+mo%C5%BCesz+odtwarza%C4%87+dowolny+tekst+na+dowolnym+obs%C5%82ugiwanym+odtwarzaczu+multimedialnym%21&language=pl_PL&voice=pl_PL-gosia-medium
      media_content_type: provider
    metadata:
      title: >-
        Witaj Jarek, możesz odtwarzać dowolny tekst na dowolnym obsługiwanym
        odtwarzaczu multimedialnym!
      thumbnail: https://brands.home-assistant.io/_/tts/logo.png
      media_class: app
      children_media_class: null
      navigateIds:
        - {}
        - media_content_type: app
          media_content_id: media-source://tts
        - media_content_type: provider
          media_content_id: >-
            media-source://tts/tts.piper?message=Witaj+Jarek%2C+mo%C5%BCesz+odtwarza%C4%87+dowolny+tekst+na+dowolnym+obs%C5%82ugiwanym+odtwarzaczu+multimedialnym%21&language=pl_PL&voice=pl_PL-gosia-medium
mode: single

The message is played but the music is not resumed.
I am attaching json with the trace.

https://dpaste.org/QesGk

Just calling the script doesn’t do a thing, the action after which the audio has to be resumed needs to be included in the action to start the script.

Oh, and the script will only check on the outdated service key, it won’t recognize the action key.

This should work, but as soon as you save this in the GUI, it will replace service with action again

alias: Test Piper
description: ""
trigger:
  - type: turned_on
    platform: device
    device_id: d990d2bbdf6036200cb7f594f4b03059
    entity_id: 336a7df9ca51a4854efd1a11bd55fb35
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 1
condition: []
action:
  - action: script.google_home_resume
    data:
      action:
        - service: media_player.play_media
          target:
            entity_id: media_player.glosnik_w_lazience
          data:
            media_content_id: >-
              media-source://tts/tts.piper? message=Witaj+Jarek%2C+mo%C5%BCesz+odtwarza%C4%87+dowolny+tekst+na+dowolnym+obs%C5%82ugiwanym+odtwarzaczu+multimedialnym%21&language=pl_PL&voice=pl_PL-gosia-medium
            media_content_type: provider
          metadata:
            title: >-
              Witaj Jarek, możesz odtwarzać dowolny tekst na dowolnym obsługiwanym
        odtwarzaczu multimedialnym!
            thumbnail: https://brands.home-assistant.io/_/tts/logo.png
            media_class: app
            children_media_class: null
            navigateIds:
              - {}
              - media_content_type: app
                media_content_id: media-source://tts
              - media_content_type: provider
                media_content_id: >-
                  media-source://tts/tts.piper?message=Witaj+Jarek%2C+mo%C5%BCesz+odtwarza%C4%87+dowolny+tekst+na+dowolnym+obs%C5%82ugiwanym+odtwarzaczu+multimedialnym%21&language=pl_PL&voice=pl_PL-gosia-medium
mode: single

I fixed the automation but now I have an error in another place. Can you take a look at it again?

Wykonano: 16 sierpnia 2024 11:21:08
Błąd: CastMediaPlayerEntity.media_stop Failed: Execution of stop timed out after 10.0 s.
Wynik:

params:
  domain: media_player
  service: media_stop
  service_data: {}
  target:
    entity_id:
      - media_player.glosnik_w_lazience
running_script: false

https://dpaste.org/iEz7k

This is a known error which I still need to fix. Let me try to find some time for that this weekend

HI!

I’ve set up a new branch for a 2024.8 version which should resolve this issue.
Optionally you can still let the players stop before the actions are performed by using the stop_before_actions: true
If this is not set the default is false, and in that case the stop action will not be used.

However, this version changes a lot more:

  • ~~service: has been changed to action everywhere to reflect the change in Home Assistant 2024.8. This means you also need to have updated to HA 2024.8 for this version to work. ~~ removed this change to ensure backwards compatibility
  • The script now also supports tts.speak where the media_player target is set under a different key.
  • Removed a check which was sometimes blocking resume

Could you please test the version which you can find here.

Hi,

Unfortunately I still can’t resume music from Spotify.

Am I right in thinking that since you’ve adjusted the script to HA 2024.8 for automation to trigger it should now look like this?

alias: Test Piper 3
description: ""
trigger:
  - type: turned_on
    platform: device
    device_id: d990d2bbdf6036200cb7f594f4b03059
    entity_id: 336a7df9ca51a4854efd1a11bd55fb35
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 1
condition: []
action:
  - action: script.google_home_resume
    metadata: {}
    data: {}
  - action: media_player.play_media
    target:
      entity_id: media_player.glosnik_w_lazience
    data:
      media_content_id: >-
        media-source://tts/tts.piper?message=Witaj+Jarek%2C+mo%C5%BCesz+odtwarza%C4%87+dowolny+tekst+na+dowolnym+obs%C5%82ugiwanym+odtwarzaczu+multimedialnym%21&language=pl_PL&voice=pl_PL-gosia-medium
      media_content_type: provider
    metadata:
      title: >-
        Witaj Jarek, możesz odtwarzać dowolny tekst na dowolnym obsługiwanym
        odtwarzaczu multimedialnym!
      thumbnail: https://brands.home-assistant.io/_/tts/logo.png
      media_class: app
      children_media_class: null
      navigateIds:
        - {}
        - media_content_type: app
          media_content_id: media-source://tts
        - media_content_type: provider
          media_content_id: >-
            media-source://tts/tts.piper?message=Witaj+Jarek%2C+mo%C5%BCesz+odtwarza%C4%87+dowolny+tekst+na+dowolnym+obs%C5%82ugiwanym+odtwarzaczu+multimedialnym%21&language=pl_PL&voice=pl_PL-gosia-medium
mode: single

I still see an error in the script trace.

https://dpaste.org/LDx9u

What am I doing wrong?

You still have the action you want to perform outside the script action.

Have a look at the example I gave above, the action to send the TTS message is part of the script action
It’s placed under data: > action:

Here it is again (but now with action instead of service as that should work as well now

alias: Test Piper
description: ""
trigger:
  - type: turned_on
    platform: device
    device_id: d990d2bbdf6036200cb7f594f4b03059
    entity_id: 336a7df9ca51a4854efd1a11bd55fb35
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 1
condition: []
action:
  - action: script.google_home_resume
    data:
      action:
        # the TTS action is placed here, inside the script action
        # not as a separate action after the script action
        - action: media_player.play_media
          target:
            entity_id: media_player.glosnik_w_lazience
          data:
            media_content_id: >-
              media-source://tts/tts.piper? message=Witaj+Jarek%2C+mo%C5%BCesz+odtwarza%C4%87+dowolny+tekst+na+dowolnym+obs%C5%82ugiwanym+odtwarzaczu+multimedialnym%21&language=pl_PL&voice=pl_PL-gosia-medium
            media_content_type: provider
          metadata:
            title: >-
              Witaj Jarek, możesz odtwarzać dowolny tekst na  dowolnym obsługiwanym
              odtwarzaczu multimedialnym!
            thumbnail: https://brands.home-assistant.io/_/tts/logo.png
            media_class: app
            children_media_class: null
            navigateIds:
              - {}
              - media_content_type: app
                media_content_id: media-source://tts
              - media_content_type: provider
                media_content_id: >-
                  media-source://tts/tts.piper?message=Witaj+Jarek%2C+mo%C5%BCesz+odtwarza%C4%87+dowolny+tekst+na+dowolnym+obs%C5%82ugiwanym+odtwarzaczu+multimedialnym%21&language=pl_PL&voice=pl_PL-gosia-medium
mode: single

Still doesn’t work. The script triggered by this automation stops the Spotify playback but doesn’t play the message or resume playback. (The speaker remains off.)

https://dpaste.org/C8tXd

You didn’t use what I provided above in that run, as the I can see the action was not passed through to the script

Actually, it’s the same trace as you provided before

I am changing practically nothing in your automation. Are you sure there is no error in it? I am attaching an image of how it looks in my HA. Do you see any error?

Please run that and provide the trace :slight_smile: