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

You could try to start a timing
TuneIn stream and see if resume works then.
Anyways the error came from Spotcast, and it’s a Spotcast/Spotify issue on which I can’t really help.

Thank you very much for dedicating your free time to me. Without you I wouldn’t have been able to get this feature working. I can currently confirm that the script works correctly with HA version 2024.8. I will look for a solution to the Spotify/Spotcast problem. As soon as I succeed I will leave information for others.

1 Like

Update: 2024.8.0

:star: IMPROVEMENTS

  • As HA 2034.8 changed service to action adjustements in the script had to be made so these actions would be recognized and performed. The script itself still uses service to make sure it still works on older HA versions
  • The tts.speak action can now be used without the need to additionally provide the target. This is now taken from the action data provided in the tts.speak action
  • A new setting stop_before_action is added. Before the script would stop cast devices which were playing before starting to perform the provided actions. However, since some time this stop action could not be performed for some users. When stop_before_action is set to false (which is the default in case the parameter is not set) the stop action will not be performed. The downside of this is that the volume which should be applied to the TTS announcement will sometimes already be applied to the playing media.

:bug: BUG FIXES

  • removed a check in the helper script which was sometimes blocking resume and keeping both scripts in a waiting state

:books: DOCUMENTATION

  • service has been changed to action in the examples from the documentation.

What’s Changed

Full Changelog: Comparing 2023.8.0...2024.8.0 · TheFes/Google-Home-Resume · GitHub

I just see here above theres an update…
So i think what im going to post, might be cause of the changes is needed.

Anyhow , i will post anyway but my resume automation failed, how can i share the trace?
I will update now :slight_smile:

Put the traces on a website like https://dpaste.org and then place the links here.
Make sure to to post both the trace of the main script and the helper script.

1 Like

Here it is
https://dpaste.org/74Or9

I updated after it, still the same.
I will test some more and post the right traces here.
Sometimes it works, and sometimes the tts sentence is broken halfway without resuming the audio playing before, i dunno why

You’ve sent a trace of the automation provided in the package. From our earlier chat on another platform I know you are calling the script directly. So the automation seems to be interfering here.

Please disable the automation, either in the script settings or in HA itself, and try again. If it still doesn’t work, please provide the traces of the main script and helper script.

I disabled some automations.
I started playing music on one mediaplayer.keuken
Then i tried using development tools to test the script directly.
This worked and the resume worked too:
https://dpaste.org/P0F4u

Then i tried another one (where automation is also disabled) / deurbel and that one did the tts but didnt resume
https://dpaste.org/qpnBt
Heres the helper
https://dpaste.org/7T4Qy

If it works for one, why not the other one then and why not when using automation with it?

I retested some more, sometimes it works (especially the first time after music playing), sometimes it does not work… (second or third time)…

What i also notice is that the other mediaplayers that are part of the group… dont finish there TTS (it gets cut of afther the first words…

When I referred to disabling the automation, I meant the automation provided in the package (the one for which you sent the trace a few days ago), not any of the automations created by you

You mean this one from the package:

Automation for automatic resume after specific service calls

automation:

  • alias: Google Home Automatic Resume

Yes, that one.

The problem in these traces is that you are using HA groups, and not cast groups (groups created in the Google Home app).
The script doesn’t recognize the group you used as a cast device, and therefor it didn’t determine any of the media players to be resumed.

I thought I did build something in for that, but I need to see if it’s still in. The last update I did (before the one of last month) was a year ago. So I don’t have everything fresh in mind :slight_smile:

I understand if its a year ago you cant remember.
I thought the groups are messing up…
Cause
I have groups made in HA under groups
Then i have a group in the script package
And i probably have groups in google home app.
I prefer to make them in one place… (would prefer HA) or in the package…
Ill disable it and try again

ok i disabled it, now the tts did good
https://dpaste.org/Medro

But he didnt resume, but thats normal no?, cause i disabled the automation

Did you target the group again? I just explained that won’t work (especially since you disabled the automation now)

I tried this using development tools

target:
  entity_id: script.google_home_resume
data:
  variables:
    action:
      - alias: Send TTS message
        service: tts.google_cloud_say
        data:
          entity_id: media_player.cast_hubs
          message: Er staat iemand aan de voordeur!
action: script.turn_on

Yes i disabled automation
the cast hubs group is not part of the package , nor is it inside Google home app

The group media_player.huis_groep is part of the package
I only have one group inside google home app: “volledig huis”

the cast hubs group is not part of the package , nor is it inside Google home app

And this is why it doesn’t work, the script doesn’t work with Home Assistant media player groups. I think I can make that work relatively easily, but I need some time to do that.

The group media_player.huis_groep is part of the package

What do you mean with this? media_player.huis_groep is also a Home Assistant media player group, but for this one you provided the members in the speaker_groups: section? Or is this not even a group at all, and you just listed all your Google Home devices there? That speaker_groups section is intended to list the members of the groups created in the Google Home app.

I only have one group inside google home app: “volledig huis”

So that’s media_player.volledig_huis. That’s the one you should list under the speaker_groups section.

I will try to find some time this week to add support for the Home Assistant groups.

Hi

Ok no problem you need time to let the script communicate with HA mediaplayer groups.

So yes, i provided the members in the speaker group section
So we understand eachother, that group i didnt make in HA at all, its just part of that section
So as i indeed understand now, only google home app group should be mentioned there, like “volledig huis”…
Now i understand.
Honestly i dont use the google home app groups at all…
I can delete it there, and have the speaker_groups section empty?

So what im going to do:

  • delete the group inside the google home app
  • delete the group under speaker_groups section and let it blank
  • wait for the fix so the script uses home assistant mediaplayer groups

Is that ok?
One other thing… In my own automations where i point to the script, i also set volume…
However as you can see above, theres a default volume level too in the script… i tried adjusting it there, but it doesnt seem to have effect…
Is this related to the same thing we are discussing here why it fails?
In short: do i need to adjust volume in the script, or in the automation that also uses the script…
Not to misunderstand eachother…
What i meant with “media_player.huis_groep” is this, its part of the script

The default_volume_level is not used for the TTS message, it’s used to restore the media player to after the TTS Is played in case it could not be retrieved.

This is also explained in the documentation, but I guess I could clarify it a bit
https://github.com/TheFes/Google-Home-Resume?tab=readme-ov-file#script-settings