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

Whoops, yes that one!

@chicknlil25 Thanks.
Did you already place the yaml from the package in the package folder? In that case I think the scripts you see in your config are actually the new scripts

If you open the script in Settings > Automations & Scenes > Scripts, what does it show as configuration for the version number?

Iā€™ll have a look at the instructions, you might be right there.

2022.11.9 is a new version I havenā€™t placed on GitHub yet, so you are on the latest version which is publicly available. So thatā€™s good.

Could you go to Developer Tools > States and filter in the table on script.google_home
If the entity_ids of the script now end with a number, you should click on the (i) icon, go to settings and remove the number

The automation is part of the package, and was introduced in version 2.7.0 (in August).
Now you are using the package, you automatically also have the automation added.

It wonā€™t interfere with your existing script calls though. Calling the script yourself and adding the actions in the script data is the most failsafe approach, the automation doesnā€™t work in all cases

Are you sending it to a Google Home speaker group? If so, the delay can be caused by the synchronization of the playback on the individua members of the group

BTW, if you use Google Cloud TTS you can use ssml to start your message with a break of a second or 2.

All options are shown in the example from the link in the docs, but it should look something like this:

service: tts.google_cloud_say
target:
  entity_id: media_player.your_device
data:
  message: >
    <speak>
      <break time="2s"/>
      The actual <say-as interpret-as="characters">TTS</say-as> message
    </speak>

Just to be sure, did you set text_type: ssml in the settings for the TTS integration?

okay, if you set the voice setting, it overrides the language and gender setting, so no need to set those
see: Google Cloud Platform - Home Assistant

The example is a bit overdone to show what settings you could use.

Yeah, like I already added to my previous reply, it is more to show all the individual options, how they would be set.
Mine just looks like this:

  - platform: google_cloud
    key_file: /config/.google_api/google_tts.json
    voice: "nl-NL-Wavenet-C"
    profiles:
      - medium-bluetooth-speaker-class-device
    text_type: ssml

whoops, and thanks! Iā€™ve corrected it! (both here and in my config, I actually just added it today, I was experimenting with the ssml myself)

me too, ssml is very interesting feature of GCT

After updating to the last version, the yaml code you gave me, it does not work anymore. Do I need to change something?

These are my traces :
google home resume helper - Pastebin.com
google home resume - Pastebin.com

This is the same spotcast error as you were having 3 days ago.
See line 13 in the trace of the helper script:
"error": "Failed to get device id from Spotify",

So this is caused by Spotcast

Nothing changed in the way the script should be started

If spot cast gives this error, it could not be resumed by the yaml code you gave me last time to execute in the service menu, is it correct?

This device id for which we are speaking for, is it contained in the following json?
json - Pastebin.com

No, the device id is just some random collection of numbers and letters which Spotify assigns to a playback device. You canā€™t see it in Home Assistant, spotcast uses the Spotify API to retrieve it based on the name of the device in HA.

I expect this issue here is the cause: Cast device not launching properly, but works if timeout is ignored Ā· Issue #365 Ā· fondberg/spotcast Ā· GitHub

Iā€™ve made the same changes as described in that post, and spotcast seems to be working again now, however it is a bit slow (it takes like 10 seconds to start).

The issue seems to be something in the Spotify player on the Google Cast device.

You are great!!! It seems to workā€¦I will make further tests and see if it will work on all devices.

I have another question, how to cast a message that will be reproduced to all devices at the same time?

Well, multiple options

  1. Add multiply entities to the TTS service call instead of just one
  2. Create a media_player group in Home assistant and send the the TTS to that group
  3. Create a speaker group in the Google Home app, and send the TTS to the media_player entity of that group
  4. Add multiple service calls in the action part of the script

The advantage of a Google Home speaker group is that the audio in synchronized, so they all play the same thing at the same time. With the other options the audio will most probably not be played at the same time (e.g. half a second difference).
However because of the synchronization it could be that the first part of the TTS message is not played by the speaker. In the posts above yours there is a solution for that discussed, but to use that, your TTS service has to support ssml

If I choose the option 3 and I create a group in google home,

do I need to do any changes in the script file?

If I have device 1,2,3 on which separately they are playing: youtube on 1, spotify on 2 and tunein on 3, if I call the tts message on the group, the script will resume all their previous states?

if you set the speaker_groups variable in the settings, it will