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

Please check v1.8.1

1 Like

Update

Version 1.8.1 - 6 April 2022

:bug: Bug fixes

  • Fix for resuming/restoring groups when interrupted by an service call sent to a group member
1 Like

Iā€™ve been scrolling around and canā€™t find the source to this Update prompt (links to static code here or another post that says ā€œno longer maintainedā€).

Could you please link to version 1.8.1?

The link in this section (from the start post) directs to the latest version on GitHub, which is 1.8.1. now.

Direct link to the script on GitHub here

If you mean that by static code, thatā€™s ineed what it is. It is not a blueprint, so youā€™ll have to update yourself by replacing the current code with the new one. Just replace the part after sequence (line 62 in my code) so you donā€™t need to set up your variables again. Make sure you donā€™t remove any scripts which are placed after this one in case you use scripts.yaml

Works like a charm, thank you!

Great! Thanks for the feedback!

Thank you for the link!
Sorry I scrolled from bottom up to see the latest information and saw code excerpts in this thread. Often is the way on the forums.
I really appreciate it being pushed to Github to receive the updates :+1:

Well, itā€™s over 1000 lines now, so it would be a big chunk of code to place here.
And I would have to change it in two places, so this is a lot easier for me. I change it in my own config, test it, and after confirmation that it works properly (or sometimes without, if Iā€™m too hasty, and trust myself too much) I commit it to GitHub.

1 Like

Update

Version 2.0.0 - 8 April 2022

:red_circle: BREAKING

  • fixed_picture has bee changed to radio_data and now also provides the option to add a fixed title for the radio stream. As TuneIn changes the title according to the song playing (well at least it should, but this seems broken lateley) it will no longer refresh after resuming the stream, as TuneIn is no longer used then. To prevent this the title can be provided as well now, for example the slogan of the radio channel can be used here.

:sparkles: New features

  • You can provide extra setttings to your service call. Curruntly supported are volume, wait and tts.
  • Supports sending TTS together with picture and text when sent to a player with a screen.
  • More information on how it works here

:receipt: Docs

  • Craeted a separate doc for script call examples which shows how to use the new features. Description how to use the script to send a TTS and change the volume is also placed there now.
  • Partial rewrite of the script docs
2 Likes

It took some time, but I did implement your suggestion now :slight_smile:

1 Like

Testing 2.0.0 - everything OK, but some error ocurring.
Would zou be so kind to help me?
https://www.codepile.net/pile/9qBPKME4

Logger: homeassistant.core
Source: custom_components/spotcast/spotify_controller.py:104
Integration: Spotcast (documentation, issues)
First occurred: 8:22:21 PM (1 occurrences)
Last logged: 8:22:21 PM

Error executing service: <ServiceCall spotcast.start (c:d2f293f527554261a768ef4c2af4358e): entity_id=media_player.google_home, force_playback=True, start_volume=101, ignore_fully_played=False, limit=20, shuffle=False, random_song=False, offset=0, repeat=off>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1652, in catch_exceptions
    await coro_or_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1677, in _execute_service
    await self._hass.async_add_executor_job(
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/spotcast/__init__.py", line 182, in start_casting
    spotify_device_id = spotcast_controller.get_spotify_device_id(
  File "/config/custom_components/spotcast/spotcast_controller.py", line 205, in get_spotify_device_id
    spotify_cast_device.startSpotifyController(access_token, expires)
  File "/config/custom_components/spotcast/spotcast_controller.py", line 87, in startSpotifyController
    sp.launch_app()
  File "/config/custom_components/spotcast/spotify_controller.py", line 104, in launch_app
    raise LaunchError(
pychromecast.error.LaunchError: Timeout when waiting for status response from Spotify app

Iā€™ve seen similar error messages today, but then when sending a TTS using Google Cloud TTS.
It sometimes didnā€™t work, and sometimes did, without changes to the script or the service call.

So I kinda expect there is something wrong in a dependency, maybe PyChromecast. I donā€™t think I can solve this on my end.

Moreover another type of error.
Did you change the way how to call the script?

Logger: homeassistant.components.script.google_home_resume
Source: helpers/script.py:1397
Integration: Script (documentation, issues)
First occurred: 9:01:34 PM (2 occurrences)
Last logged: 9:01:34 PM

00 šŸ”Š Google Home Resume: Perform service calls defined in action: Error executing script. Error rendering template for variables at pos 1: UndefinedError: 'homeassistant.helpers.template.Wrapper object' has no attribute 'target'
00 šŸ”Š Google Home Resume: Error executing script. Error rendering template for repeat at pos 15: UndefinedError: 'homeassistant.helpers.template.Wrapper object' has no attribute 'target'

Did you already upgrade to 2.0.1? I remember fixing this today :slight_smile:
Oh wait, itā€™s complaining about target, not extra. Could you share a trace again? Think I forgot a check syndrome m somewhere, and I usually use target in my service calls.

I would like to know which template caused this :slight_smile:

Yes, 2.0.1 installed

I was already editing my post, could you provide the trace?

https://www.codepile.net/pile/bgJE1GPY

Think I found it, and resolved it in v2.0.2 which I just uploaded.
Could you please check, and if let me know if that works?

I will update the start post tomorrow, going to bed now :sleeping:

2.0.2 indeed solved that type of errors.
Only one remained present:

Logger: pychromecast.socket_client
Source: /usr/local/lib/python3.9/site-packages/pychromecast/socket_client.py:396
First occurred: 11:15:04 PM (2 occurrences)
Last logged: 11:15:26 PM

[([::ffff:c0a8:114]):8009] Failed to connect to service ServiceInfo(type='host', data=('[::ffff:c0a8:114]', 8009)), retrying in 5.0s

Hi,

Decided to try this tremendous piece of work for which I am thankful, but I am not sure what to modify:

  1. I have 2 google mini speakers
  2. I donā€™t have and donā€™t want speaker groups !!!
  3. i have a script called :slight_smile: :slight_smile: radio_script which gives me my favourite radio station
  4. i have a simple ringbell which plays 10 seconds of a mp3 file.

Where I should declare (script line number xxx) my 2 google home mini (repeat, not as a group) for my radio script to resume after somebody rings doorbell ?

Thank you