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

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

I have followed your instruction, probably in a wrong way, now if I call the script, it does not work anymore, these are the lines which I added in the configuration :

{ “trace”: { “last_step”: “sequence/4”, “run_id”: "01f5969fd31405ce - Pastebin.com

You are missing a semicolon (:) after media_player.casa

BTW, please don’t post pictures code, just post the code, it makes it easier for me to give you a corrected version without having to type it all again.

Ok, I will do it immediatelly:
speaker_groups:
media_player.casa:
- media_player.cucinanest
- media_player.camerastudio
- media_player.salottomini
default_volume_level: 0.75

It does not work anyway, it gives now another error:

{ “trace”: { “last_step”: “sequence/7”, “run_id”: "2bb8bbf34a0311c4 - Pastebin.com

That’s a strange error, that would imply there is an entity in your setup which isn’t off but still doesn’t have a volume_level attribute.
However, I think it is fixed in this version, could you give it a try?

Now the script and the automation do not start anymore…

I’ve update the test version, please download it from the same link above

Now it executes only google home script but not the helper.
Anyway, it does not resume nor single device neither group.

This is the trace:
{ “trace”: { “last_step”: “sequence/21/repeat/sequence/0”, “run_id” - Pastebin.com

Furthermore, on the nest device stuck on the following picture that I never have been seen.

Imgur

If

The template to store the data was failing because somehow the group had the state playing while it was actuanlly not playing anything.
This caused that the app_name in the template was Undefined and because of that the whole list was saved as a string. Can you try 2022.11.9b3 from the link above?

I tried…it does not resume and it does not call the helper. This is the trace :

{ “trace”: { “last_step”: “sequence/21/repeat/sequence/0”, “run_id” - Pastebin.com

Still the same issue, but the player_data now comes from the automation. Did you reload automations as well after updating to the new version?