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

Hi there, first of all thanks for the awesome script but sadly it stopped working for me and i get the same error as @rudy12767 , so “Google Home Resume: Error executing script. Error rendering template for variables at pos 7: ValueError: dictionary update sequence element #0 has length 1; 2 is required”

Here is the trace of the automation: { "trace": { "last_step": "action/8", "run_id": "ce8d9f72ac6c84ab7e - Pastebin.com
And here of the script: { "trace": { "last_step": "sequence/6", "run_id": "bc8c527e62591936 - Pastebin.com

Thanks in advance and I wish you a nice weekend.!

Just one, all I have.

If you have just one Spotify account integrated, it doesn’t matter what you put there, it will automatically use the primary (and only) Spotcast account

Hmm. Then I’ve done something wrong. Because when I’ve got Spotify playing and an automation runs to announce an event, it doesn’t resume spotify when it’s done announcing. What would I need to provide you to help me troubleshoot this?

It’s described here

Okay, I opened an issue. It wouldn’t let me upload the JSON for whatever reason, so I put it on that pastebin type site and linked it. Thank you, I very much appreciate your time! Sending you Ko-fi now!

@BalanceBreaker @rudy12767
I think I found what caused the issue. I fixed it already in the script, but forgot to do that in the automation.

Version 2.8.8 - 6 November 2022

:bug: Bug fixes

  • Fix for media_content_type in template in automation

Ah, I see it, that’s an easy one to fix. Just add group: to your configuration.yaml (as also stated in the General requirements.

I finally got the script working. Don’t ask me how, but since I used the Text-to-Speech (TTS): Say an TTS message with google_translate istead of the cloud_say service in my automations it works.
Big thank you @TheFes!

I think I have a bug or a feature request.
Gotta paint a picture real quick. I have two speaker groups, group A ( speaker 1,2) group B (speaker 1,2,3,4) Each number represents a speaker. They have been added to the script.

I have music(Spotify) playing on group A (just two speakers). Now a tts message goes off on group B with four speakers that includes the two speakers from group A . The message plays and music is resumed.

The issue, simply stated, is that the two speakers that are not playing music (but are playing the tts message) don’t restore their previous volume.
With the announce_volume variable set to .7 the speakers 3 and 4 have a volume increase after the message plays if at .5 before the message they jump to .69. If announce_volume is set to .4 i get a volume decrease from .5 to .34.

My B if I am just missing something and incorrectly using the script/automation. Appreciate your work a ton thank you!!

script dpaste/fqNr3 (Python)
helper dpaste/kDO37 (Python)

Interesting, I’ll have a look at the traces

Version 2.8.9 - 13 November 2022

:bug: Bug fixes

  • Fix for not all players being restored to previous state

Should be fixed now

1 Like

Hello,
I followed the described procedure; I have installed both the script and the automation…I made changes in the config files so they can match my configuration. But unfortunately, it doesn’t work.
I am relatively new to home assistant, so I am not excluding to have made some mistakes in the config.
Anyway, I am using node red to create flows in which google devices play vocal messages when a condition is met. After that, it does not resume its previous state.
My first question is, if this script and automation works with node red integration.
The second thing is how I can eventually trace the problem, so I can understand if there is a config problem or whatever else?

If the automation triggered by your Node Red flow? You can see when it last triggered in Settings > Automations.

If so, could you please provide a trace of the Google Home Resume script as described in the first post of this topic?

This is the situation:
If I go in the setting->automations I can find “00 - Google Home Automatic Resume”, so it was triggered.
Following what it is written in the first post, I went in script and both “00 - Google Home Resume” and the helper version, never triggered. If I made a trace, it is written “no trace found”.
On the contrary If I made trace in the automation setting, I found the error “UndefinedError: cast_entities’ is undefined”.

https://www.dpaste.org/gz8cK

I have a google nest device, plus a couple of google home devices, but they aren’t connected as a group.
In your default configuration I see :
speaker_groups:
media_player.huis_groep:
- media_player.keuken_hub
- media_player.slaapkamer_hub
- media_player.pepijn_mini
- media_player.woonkamer_mini
- media_player.zolder_mini_marleen
- media_player.zolder_mini_martijn
- media_player.floris_mini
media_player.boven_groep:
- media_player.pepijn_mini
- media_player.slaapkamer_hub
- media_player.zolder_mini_marleen
- media_player.zolder_mini_martijn
- media_player.floris_mini
media_player.beneden_groep:
- media_player.keuken_hub
- media_player.woonkamer_mini
media_player.zolder_groep:
- media_player.zolder_mini_marleen
- media_player.zolder_mini_martijn
Do I need to delete them all and left only “speaker_groups:”?

If it’s in that list, it doesn’t mean it’s triggered, it just means the automation is created.
It should mention a date and time when it was last triggered, like it does here for me:

What does it say there?

If it was triggered, can you provide a trace of the automation as well?

You can delete it all, including the speaker_groups: key

1 Like