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

This is the current trace. Sorry, the previous one may indeed have been out of date.

https://dpaste.org/DBHJ2

Change stop_before_action in the settings and set it to false

I have it set on true myself because I don’t have the issue that my players won’t stop

I set “stop_before_action: false” but now the script doesn’t stop the music, doesn’t play the message and doesn’t resume. I can only run it once. It seems like it stops somewhere.

https://dpaste.org/sQD9Y

It was waiting for the helper script to finish, can you also send the trace for that?

I am attaching a “helper script” trace.

https://dpaste.org/yoW5f

It looks like the TTS action fails, and therefore both scripts are still waiting.

Does this work if you run it in developer tools > actions

          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

No,Unfortunately, it doesn’t work.

My previous (now removed) post was incorrect, let my check again.

I noticed that the automation was no different from before.

It was, but my correction was incorrect

Does this work in devtools> actions? There was a space added where it didn’t belong

          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

Unfortunately it doesn’t work. Syntax error.

Try again with the corrected YAML above

The speaker now plays the notification.

Okay, here is the automation with the same space removed

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

On a single speaker, resuming works fine. I have two more speakers that create a stereo pair. (A pair created in Google Home). On them, the music stops, the message plays but the music does not resume. Should I create a group for these speakers in the script as below?

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.para_w_kuchni:
            - media_player.kuchnia_lewy
            - media_player.kuchnia_prawy

Do you target the pair itself, or a single channel (so either left or right)? In case you target the pair, it should not be needed to define the group.

I also have a stereo pair in my office, and I never use the single channels.

If it is not a stereo pair, but a speaker group, you should define it in the settings as you did in your example above

The target is in stereo pair. I see an error in the helper script. Do you know what it is related to?

https://dpaste.org/gJyKe

That error is from Spotcast. It can’t find the device id from your entity id. Is the name of the entity and device exactly the same as in the Google Home app?

Yes, the name in google home and HA is the same “Para w kuchni”