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

:rotating_light: Spotcast issue :rotating_light:

Spotify made changes to their API, which caused that spotcast is no longer working, and therefor also breaking Spotify resume using the script

More info: Error when start on chromecast: KeyError: 'deviceID' · Issue #398 · fondberg/spotcast · GitHub

2 Likes

Spotcast is working again, make sure to update to 3.7.1

3 Likes

It’s not really an issue but I’ve noticed if one of my devices is unplugged the resume automation fails. It’s only when all devices are connected it runs smoothly.

Is this how it should be or is there something I need to do to prevent this?

1 Like

@Jakesa Could you send me the relevant traces of such an occurrence?

Hello @TheFes and thanks again for this amazing extension for Home Assistant!
I’ve been using it for about a year now and it is amazing.

Unfortunately I’ve been having some volume issues with any TTS sent from Home Assistant (Everything was always at 100% even tho the volume should be lower) and after months of not understanding why this is, I realized that the issue is gone when I disable the Google Home Resume AUTOMATION.

But since disabling caused some other issues and your tool didn’t work all the time anymore, I decided to update it.

Unfortunately It didn’t resume Spotify then anymore. I haven’t changed anything except updating to the latest update of yours. Since that didn’t work, I removed everything for your Script, restarted and updated HomeAssistant and re-added it. Now it won’t start at all. Home Assistant gives me the error right away on the service call:

“Fehler beim Aufrufen des Diensts script.google_home_resume. UndefinedError: ‘str object’ has no attribute ‘keys’”

Recreated it with a backup and updated it again. This issue isn’t happening anymore, but it is still not resuming my media after the TTS. But now at least it isn’t on 100% anymore.

The Logs say following: HTTP Error for PUT to https://api.spotify.com/v1/me/player/shuffle?state=true&device_id=bbf7c3f86f2739c1374XXXXXXXXXX with Params: {} returned 404 due to Not found.
But simply using spotcast to start a playback works flawlessly.

What can I do to get the resume script working again?

Thanks a lot in advance for your support! :slight_smile:

@itspuia Can you share the YAML of the service call when you run spotcast manually?
And can you share traces of the scripts?

Sure, thanks for your help:

Here’s the YAML of the script:

service: script.google_home_resume
data:
  action:
    - service: tts.cloud_say
      data:
        cache: false
        entity_id: media_player.nest_schlafzimmer
        message: "Test, 1 2 3"

I am not sure how to share traces. Do you need the “changed variables”?
Because I don’t know what else I can send you. According to the graph, it gets to the end. (See at the end)

But after removing everything again, reloading the YAMLs rebooting Home Assistant and re-adding your script it seems to be working now. I don’t understand what exactly i did differently this time, but it seems to work. The only two “problems” that are still there, are following:

Everytime It resumes (even it actually does resume), it gives me an error:

[139648940610112] http status: 404, code:-1 - https://api.spotify.com/v1/me/player/repeat?state=off&device_id=bbf7c3f86fXXXXXXXXXXXXXXXXX: Not found., reason: None

(The Xs are from me)

And the other thing that got me into reinstalling everything in the first place, is the TTS that aren’t sent directly via your script, are always at 100% volume. Deactivating the automation helps with the volume, but makes issues with resuming spotify after the TTS.

Here’s what I thought I could send you from the Script. Not sure tho, if this is what you need:

settings:
  speaker_groups:
    media_player.ganze_wohnung:
      - media_player.nest_schlafzimmer
      - media_player.nest_kuche
      - media_player.nest_flur
      - media_player.nest_wohnzimmer
      - media_player.chromecast
  default_volume_level: 0.25
  dummy_player: media_player.vlc_telnet
  default_resume_delay:
    seconds: 20
  max_runtime:
    minutes: 10
  enable_automation: true
  dashboard_cast: true
  announce_volume_automation: 0.75
this:
  entity_id: script.google_home_resume
  state: 'off'
  attributes:
    last_triggered: '2023-10-06T09:34:19.653250+00:00'
    mode: parallel
    current: 0
    max: 10
    icon: mdi:cast-audio
    friendly_name: 00 - Google Home Resume
    settings:
      speaker_groups:
        media_player.ganze_wohnung:
          - media_player.nest_schlafzimmer
          - media_player.nest_kuche
          - media_player.nest_flur
          - media_player.nest_wohnzimmer
          - media_player.chromecast
      default_volume_level: 0.25
      dummy_player: media_player.vlc_telnet
      default_resume_delay:
        seconds: 20
      max_runtime:
        minutes: 10
      enable_automation: true
      dashboard_cast: true
      announce_volume_automation: 0.75
    voice_settings:
      check_for_title: Witte ruis
      use_resume: true
  last_changed: '2023-10-06T09:34:27.596445+00:00'
  last_updated: '2023-10-06T09:34:27.596445+00:00'
  context:
    id: 01HC25D7RC72TRC5CSD700D26R
    parent_id: null
    user_id: null
action:
  - service: tts.cloud_say
    data:
      cache: false
      entity_id: media_player.nest_schlafzimmer
      message: Test, 1 2 3
context:
  id: 01HC25K3K6QQ3HP73CY68C6HBX
  parent_id: null
  user_id: 4514bb2f70c2450bb9f040ed6b64d488

I hope this is, what you need.

This explains how to access and download the traces

Thanks, I didn’t know that!

Here are the necessary traces:

Resume Script
Resume Helper
Resume Automation triggered from Script
Resume Automation triggered from normal TTS (cloud_tts.say), causing the 100% Volume

Personally Only the last point is what is bothering me, the error messages don’t bother me a lot, since the script works anyways. But I thought I might share anyways.
Thanks a lot for your amazing script and support!

1 Like

I wonder if this may be an issue with pychromecast. I have noticed casting fails to a media player group often when it includes a google nest display that fails to ‘wake up’…

hi

can you help - I cant get this to work, it resume the music but dont say the message
I can se the script is running when i call it from my speaker media_player.tv_stuen
(info : Google Home Resume works)

alias: ETA TheFes
icon: mdi:car
sequence:
  - variables:
      message: test hest
  - alias: TTS for speaker voice command
    service: script.google_home_voice
    data:
      target_conversion:
        media_player.tv_stuen: null
      use_resume: true
      target_variable: true
      action:
        - alias: Send TTS message
          service: tts.google_cloud_say
          data:
            message: "{{ message }}"
      volume: 35

Remove the target_conversion line. You are now sending it to none

it didn’t fix it

Then please give me the trace of the related scripts

this?

I need the json file, please follow the instructions here
https://github.com/TheFes/Google-Home-Resume?tab=readme-ov-file#questionsissuesbugsfeature-requests

The link it not going to the right section so it seems, but it’s at the bottom

https://www.dpaste.org/kcA0R

In this case it was still waiting for the ambient sound to start.

Google Home Resume
Google Home Resume - Helper Script

Thanks for this amazing script!
But i cannot make it work with DashCast. The script works great and resumes Spotify when i cast the camera with service: camera.play_stream. Unfortunately there is a delay of more than 30secs and it’s not usable with that option so i always use service: webrtc.dash_cast to stream cast cameras to Nest screens or TV.
What am i doing wrong with this?

Hey @ShockStruck - Quick question: You seem to have figured out how to convert the script into a Node Red script. Would you mind sharing the String that you put in the “Data” field? I can’t get it working.
Thanks in advance!