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

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?

I have just restarted home assistant device, to be sure that everything will restart… nothing, it does not resume and the helper script is not called.

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

I made also some additional tests. If I call the service also for one device, it still the same problem, so the problem is not only for the group.
If I call the service with tunein active, it works both for single device and group. So the problem is again with spotify.
I have also tried the google nest hub device with some yutube videos…here the same situation, it resumes.
Anyway, there are some remarks… during the announcement, I hear the “beeb” from the 3 devices not synchronized…the second thing is that the volume raises before the announcement, so tunein or the youtube video for one second play with a louder volume before playing the tts message…the other thing that I noticed, is that now the volume does not return to its previous setting…so in my case it remains louder, because I set the announcement volume to be higher, while in the past there weren’t this problem.

Can you try 2022.11.9 from the same link above. I’ve also made some changes to the automation.

For the volume restore thing I will need traces, for both the main script and the helper script. Do note that the helper script might be started several times (once for each device).

BTW, are you saying that Spotify was playing on the group in all these cases?
If that is indeed the case, it won’t resume, there is simply no information available in Home Assistant that Spotify is actually playing.
Only the Speaker Group shows as playing, but without any information what it is playing. All the members show as idle.

How are you starting Spotify on this group?

No, I have done another kind of test. I started spotify on google home mini while youtube on google nest hub. Afterwards I called a group announcement. To check after if it will resume to all the devices. it is enough that on one device is present Spotify, it will automatically not resume also the other devices. Now I will check the new version

I put the new version. This is the situation.

If only camerastudio is playing with tunein, if calling the tts for both only camerastudio and group, it works.
Only camerastudio - Pastebin.com
{ “trace”: { “last_step”: “sequence/1/then/11”, “run_id”: "9d27022a - Pastebin.com

If it is playing tunein on camerastudio and spotify on salottomini, and I start a call tts only to camerastudio, not only it does not resume camerastudio, but it does not restore the volume, so next time I start anykind of activity on camerastudio, it is with louder volume. Spotify will continue playing on salottomini.
camerastudio+salottomini - Pastebin.com
camerastudio+salottomini - Pastebin.com

If it is playing tunein on camerastudio and spotify on salottomini, and I start a group call tts, it does not resume anything, on the other side, the volume is restored on both devices.
camerastudio+salottomini group - Pastebin.com
camerastudio+salottomini group helper - Pastebin.com

I do not what it is going on, but definitely spotify is creating the problems.

For now I had a look a these traces.
From the player_data from the main script, and the helper script I can see that on speaker was indeed playing a web stream, and it was resumed nicely by the helper script. I don’t see any issues in that helper script.
From the player data in the main script, I can see that according to Home Assistant the camerastudio player was playing on TuneIn, that is the one which is resumed

              {
                "data_source": "resume_script",
                "entity_id": "media_player.camerastudio",
                "state": "playing",
                "type": "no screen",
                "members": [],
                "app_name": "TuneIn Free",
                "volume_level": 0.3,
                "media_content_id": "https://kisskiss.fluidstream.eu/KissKiss.aac?FLID=3",
                "media_position": 15.51,
                "media_artist": "Radio Kiss Kiss",
                "media_title": "Io Tu e KissKiss",
                "media_content_type": "music",
                "entity_picture": "https://cdn-profiles.tunein.com/s61955/images/logoq.jpg?t=1"
              }

The solattomini player was not playing at all according to Home Assistant:

              {
                "data_source": "resume_script",
                "entity_id": "media_player.salottomini",
                "state": "off",
                "type": "no screen",
                "members": []
              }

So either you are mixing traces here, or there is something strange going on…

On all of these traces, only the camerastudio player was playing on TuneIn.

I might have missed the answer on my earlier question, but how are you starting Spotify on these devices? Is that through a voice command, or starting it with the app? Or something else?

Wait, a had a second look at the traces, they are all exactly the same trace you uploaded 3 times.
The start timestamp is exactly the same. So this is only one of the 3 use cases, probably the first one which was the successful resume when camerastudio was playing on TuneIn

Make sure you upload the right trace for the right test scenario.
I’m off to bed now

Hi, is there a way to trigger the google assistant to listen (like saying hey google) after the resume? I noticed before the script randomly triggered the google assistant after the resume.

Sometimes using a voice command, sometimes directly from the HA integration.