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

The TTS command is here:

service: script.google_home_resume
data:
  target:
    entity_id: >-
      media_player.dressing_room_speaker,media_player.office_speaker,media_player.main_bedroom_speaker,media_player.kitchen_display
  action:
    - service: tts.cloud_say
      data:
        entity_id: >-
          media_player.dressing_room_speaker,media_player.office_speaker,media_player.main_bedroom_speaker,media_player.kitchen_display
        message: Daddy is Arriving

I also updated the automation but it didnā€™t work still Sep 19 2:56 PM - Codeshare

primary_spotcast is included in players_screen in the script variables.
From your trace it seems to be set up like this:

players_screen:
  primary_spotcast: jacobsach1987
default_volume_level: 0.6
dummy_player: media_player.vlc_telnet

Remove the players_screen line if you donā€™t have any devices with a screen, and make sure primary_spotcast is aligned with the rest

On the other hand, there alse seems to be an issue with the Spotify data. This is the data stored for the Spotify entities:

entity_id: "media_player.spotify_home",
source: "Main bedroom speaker"

Which implies the Home account was playing on the Main bedroom speaker. However, from the player data I see that on that speaker Magic Radio UK was playing, and that Spotify was playing on media_player.dressing_room_speaker, unless there is a strange mismatch between your entity_ids and friendly names.

ahh I must have made a mistake when editing it.

However, Iā€™ve made the changes above but it still isnā€™t working. My entity idā€™s and friendly names are a bit messed since I moved house, but I have just updated the entities/friendly names and also updated one of my scripts to test but it still hasnā€™t resolved my issue, unfortunately. Sep 19 3:43 PM - Codeshare

Tested, indeed it does. Thanks again, @TheFes

This is a trace from the daddy home script, I need a trace from the Google Home resume script

Sorry, here is the google home script trace Sep 19 3:43 PM - Codeshare

My updated script variables are now like this:

players_screen:
- media_player.kitchen_display
primary_spotcast: jacobsach1987
default_volume_level: 0.6
dummy_player: media_player.vlc_telnet

Could you also send the trace of the helper script

Sure. Sep 19 3:55 PM - Codeshare

This is a version when the player was idle, I would need the one which tried to restore the player which was playing on Spotify.
The main script looks fine now, the right Spotify account was selected.

I have edited the original code share Sep 19 3:55 PM - Codeshare

Are you sure, because this is the player data

            "player": {
              "data_source": "resume_script",
              "entity_id": "media_player.living_room_speaker",
              "state": "off",
              "members": [],
              "type": "no screen",
              "volume_level": 0.44999998807907104
            },

hmm that is wierd. It seems like there are multiple traces at the same time. I have just shared the top one, not sure if it is supposed to do this or not so thought I would share. Screenshot-2022-09-20-at-07-46-26 ā€” ImgBB. I only ran the script once.

But probably with multiple targets, it runs te helper script for each target.
Try to target it only to the one playing on Spotify.

Also, spotify was playing on main_bedroom_speaker

Okay, but you did not send me the trace of the helper script for main_bedroom_speaker. You sent it for living_room_speaker.
As I said in my earlier post, the helper script is started for all players targeted, also for the ones which are not playing the volume might need to be restored.
So try to target it only to the one playing Spotify, or check first in the trace of the helper script for which player it was.

Gotcha, this seems to be the correct one Sep 20 12:05 PM - Codeshare

"entity_id": "media_player.main_bedroom_room_speaker",
              "state": "playing",
              "app_name": "Spotify",

This is the correct one:

    "state": "stopped",
    "script_execution": "error",

And the error is:

"error": "Failed to get device id from Spotify"

This is not an error in the script. For Spotcast it is important that the Friendly names in HA, match with the names in the Google Home app, I think something is wrong there.

They all match and what is more odd is they didnā€™t match when it worked (before it broke and was updated). Thanks for your help anyway, I will have a look into Spotcast and see if I can locate the issue.

Update

Version 2.8.4 - 26 September 2022

:red_circle: BREAKING

  • dashboard_delay and picture_delay are combined in one variable resume_delay. This can be sent as variable in the script service call. You can set a default using default_resume_delay in the script. If no delay is defined, 20 seconds will be used

:star2: Improvements

  • Resume after sending webp and gif images is now also supported
1 Like

Have there been breaking changes to this script from recent HA updates? My script isnā€™t working any more (this is not the spotcast issue).

Google Home Resume Trace - Oct 10 11:21 AM - Codeshare
Helper Scipt Trace - Oct 10 11:24 AM - Codeshare