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

Update

Version 2022.11.0 / 2022.11.1 - 21 November 2022

:red_circle: BREAKING

  • Combined the script and automation in a package, see the setup section on how to update. Remove the old scripts and automation first, and do a reload from Developer Tools > YAML before copying the new version to your system.
  • You will need to update the Google Home Voice and Google Home Event scripts as well if you update to this version.

:star2: Improvements

  • Changed version number to YYYY.MM.version
  • As the automation is now included in the package, a variable automation_enabled is added to optionally disable the automation. It is enabled by default
  • Sometimes Cast devices can show as idle in Home Assistant, while they are actually playing music from Spotify. They will also be resumed now
  • Templates to store data are improved, variables to store Spotify and YouTube Music data are now integrated in the general player data variable
  • Some variables which can be useful for debugging are added

:bug: Bug fixes

  • (2022.11.1) Fixed a template error
2 Likes

Hi TheFes,
after upgrade both scripts (2022.11.1; resume + event) via pacakges, Resuming is not working correctly (but no error in the log), and following error occurs if I restart the HA:

Invalid config
The following integrations and platforms could not be set up:

  • automation (Show logs)
    Please check your config and [logs].

The automation from the package is not created; I wanted to create it myself directly via automations, but it is with some error, therefore not able to saveā€¦

No further details in that log.
Thanks.

Hmm, without errors this is a bit tricky to debug.
Is there anything which might be related if you donā€™t filter on automations only (the link from the log automatically applies a filter).

What I can imagine is that you didntā€™t remove the old automation, and that there is a conflict with the unique_id now.
Do you also have 2 Google Home Resume scripts, and 2 Helper scripts now?

I will add something to the post about this.

I deleted old 2 scripts, so now I have only 2 new not-editable scripts.
Automation - I did not have old one you have in package and it is not generated under automation section.
I call the scripts within my own automations.
If I unfilter logs, no errors.

Were you already using packages, or did you use the include as described in the setup instruction? If you were already using it, what is the include you are currently using?

First time user of packages.
But I put this into config under ā€œhomeassistant:ā€ section

homeassistant:
  ...
  ...
  ...
  packages: !include_dir_named packages

Update

Version 2022.11.2 - 22 November 2022

:bug: Bug fixes

  • Corrected a typo in the automation

@Manazer This should fix it.

I am still using the previous versionā€¦i have a questionā€¦on the google device that I have in my office, probably it is connected a second profile for google as well as for spotify (here I am not sure).
Looking at the home assistant dashboard, I can see the music which the google device is playing, but the spotify banner with my account is not active, so I suppose that the google device is using another spotify account. If I start the script, it sends the tts message, and when it tries to resume, it does not work properly (I am not sure, one time it resumed a song which usually I hear on my account).
Anyway, from the generated trace files, can I understand what is eventually the spotify user(or spotcast)?

If you have only one Spotify account integrated in Home Assistant, and you configed spotcast for only one account, that account will be used to resume Spotify.
If you are in fact using multiple Spotify accounts, you need to integrate that Spotify account as well. So that means that you need to add the Spotify integration a second time for that account, and that you need to change the spotcast settings so that account can be used as well.

See also this section in the first post.

Just to be sure that I am in the right direction. To add the second account, I need to open the developer spotify website and add the new user in user and access, is it correct? Here it is written that I can add 25 users and that zero have been assigned at the time being. The mine is the default one and I do not need to add it in this list, am I right?

Itā€™s a while ago that Iā€™ve set this up, but that sounds correct.

I have configured everything as in the instruction.
Anyway, I cannot find the info where to put the additional created user info in the script. I suppose it is somewhere under primary_spotcast, but what should I add?

Well, there is no that error anymore, automation created.
But, resuming does not work.
Here are traces of google_home_resume and google_home_resume_helper, and Google Home Automatic Resume:
https://dpaste.org/mXKcy
https://dpaste.org/ZKyRq
https://dpaste.org/TQBmg

Iā€™ll look into this this eventing or tomorrow.

Hello,

Could you give me some help?
These are the traces :

dpaste/cS6kN (JSON)
dpaste/GHZZB (JSON)

Spotify was playing with Milenaā€™s account, but it does not resume after sending the tts message.

Could you tell me more?

Hi, I updated to the latest version of your script but I got multiple log warnings but it will resume the music after playing the announcement audio.

Screenshots of warnings:



00 - Google Home Resume: dpaste/iQTba (JSON)
00 - Google Home Resume - Helper Script: dpaste/X6nyp (JSON)

PS: This is the only trace available.

Sorry about that, already working on that. New version coming soon.

1 Like

I also noticed it doesnā€™t trigger the automation script.

This will also be corrected in the new version

Update:

Hereā€™s the trace of my automation

https://www.dpaste.org/F9Ue7