Spotcast - custom component to start playback on an idle chromecast device

Would you guys happen to know why I keep getting this error “Failed to call service spotcast/start. Could not find device with name Bedroom display”. I know the device name and entity are for sure correct because I can click the power button in the mini media player and the device will chime like it is about to be casted to. This is the code I am using and it works completely fine for a nest mini:

      - type: custom:mini-media-player
        entity: media_player.bedroom_display
        name: Nest Hub
        icon: mdi:music
        artwork: cover
        shortcuts:
          columns: 1
          buttons:
            - name: Favourites
              type: service
              id: spotcast.start
              data:
                entity_id: media_player.bedroom_display
                uri: spotify:playlist:0bmtkxVk4AHAFolJxOlAw7
                random_song: true
                shuffle: true

I have the exact same problem: my script won’t run and returns the same error (“Failed to call service spotcast/start. Could not find device with name …”).
I have tried running the script using both the ‘device_name’ and the ‘entity_id’ attributes (of course not at the same time :slight_smile: but I get the same error no matter which of the two I’m using. I’m sure of the device/entity names.
Can’t figure out if this is a problem with the component or with the official built-in Spotify component in Home Assistant.
Anyone else experiencing this problem? And has anyone found a solution?

Is it possible in some way with Spotcast, or directly via Spotify, to be able to play not a specific song, but exactly the last play made with your Spotify account? I can’t do it and I’ve been trying for months

I spent sometime debugging, trying to get this to work, using the examples from the docs.

Just kept failing, with various 404 / 403, other python errors in the logs.

Found the solution: The official docs provide this example:

- service: spotcast.start
  data:
    device_name: "Kitchen"
    uri: "spotify:playlist:37i9dQZF1DX3yvAYDslnv8"
    random_song: true

This will never work…it turns out the source of the problem is…that playlist has been deleted! It would be better there was some error catching, so the logs defined the problem rather than requiring guesswork.

Dear Author: Thankyou for this find custom_component! May I suggest updating the docs to have the same playlist example that Home Assistant Spotify uses: spotify:playlist:5xddIVAtLrZKtt4YGLM1SQ

That playlist is valid, and quite nice too :slight_smile:

As of todays date, Spotcast will “crash” if a user tries to use it as per the examples in the documentation…

Great to know. I still haven’t found a way to start the music he was already listening to on Spotify, without having to recall a playlist. You who are so meticulous and have discovered this, you know?

Ha, thanks :slight_smile: Only wasted 4 hours of my life trying to figure out what the actual problem was :sweat_smile:

I’ve just submitted a Pull Request to the github repo with the updated playlist, so that the provided examples should now work.

2 Likes

I hope some other pull requests would be integrat finally too…

After Update 2024.3 i get this error.
“Setup failed for custom integration ‘spotcast’: Unable to import component: cannot import name ‘LaunchError’ from ‘pychromecast.error’ (/usr/local/lib/python3.12/site-packages/pychromecast/error.py)”
I know spotcast is no longer maintained, but is there a solution?

Version 3.7.2 was released last week to fix this.

Thanks. I’ve removed and reinstalled spotcast.
I wasn’t notified of the update. Strange!
Fixed!

Maybe I am just completely off here, but I installed spotcast via HACS as described on the github-site, but I cannot find a service named spotcast.start. Trying to call it resulted in Service spotcast.start not found.

Anybody else experienced this? I am on HA 2024.3.3.

Is it normal, that i am getting always this error just on the first click on playlist button?
On the second try it actually starts playing…
For the volume icons also i get another error on the first click.

Failed to call service spotcast/start. http status: 404, code:-1 - https://api.spotify.com/v1/me/player/play?device_id=cf7e87f2-f01c-4beb-b4ca-b2834e7a11cc_amzn_2: Not found., reason: None

Mini Media Player code looks like this:

type: custom:mini-media-player
entity: media_player.spotify_xyz
group: false
volume_stateless: true
toggle_power: false
artwork: cover
info: scroll
sound_mode: icon
source: icon
background: /local/spotify/image3.jpg
shortcuts:
  columns: 3
  buttons:
    - name: Lounge
      type: service
      id: spotcast.start
      data:
        device_name: EG
        uri: spotify:playlist:37i4dQHF1EIvbirnxqsZ2h
        random_song: true
        shuffle: true

Btw. device_name EG is a echo dot device, connected to spotify. It seems like either spotify itself, or echo sleeps, and the first click first awakes that, and then it works on the second click :thinking:

Hello all, I’ve been using Spotcast successfully for some weeks now. I have a Denon AVR-S650h network receiver (integrated in HA as two separate cast devices; HEOS and Denon AVR) and Spotcast was always able to wake the HEOS device in order to start playing.

Since five days, the integration will no longer work when the device is in standby. This will result in the following error being shown on-screen:

Failed to call service spotcast/start. Could not find device with name Home Theater

I have also checked the debug logs, which are showing:

Could not find device Home Theater from hass.data

When the device is online, this issue does not exist. Also manually turning on the AVR from the HEOS integration works perfectly alright.

An alternative solution is to target this device as a Spotify Connect device, using its spotify_device_id. This works as a work-around, turning on the device and starting the stream.

Any idea what might be the cause of this?

Are you saying that this spotcast custom integration is able to solve the issue that regularly the spotify integration in Home Assistant doesn’t ‘see’ the HEOS devices anymore? I always have to open the Spotify app on my smartphone to solve this and it’s very annoying so if spotcast can solve this that would be great.
Would you be able to give a small explanation of how it works / is set up (both your usual solution and the current workaround you are using)?

@quizzical Not actually sure, I followed this guide from Smart Home Junkie: https://youtu.be/UBTM4VB-bYc?si=3PyH4TBEXsOPKOoM

It uses Spotcast + Spotify + Mini Media Player to realise a card on which you can link songs, podcasts and playlists. When I click on it, normally it would power on the receiver. Now I need to specify the Spotify device id instead of the Home Assistant friendly name.

Recently, this has started working again. The AV Receiver is now correctly turned on when I use spotcast to start a song.

@quizzical did you get it to work?

how do i expose spotcast to assist?

ive done some tests i can control my sonos via assist using direct commands, i can trigger a spotcast playlist on my sonos directly (not via assist) but i cant get assist to send a command via spotcast.

Please help

I haven’t had time to play with spotcast yet to find out whether it does what I hope it does :slight_smile:

@quizzical @Rediwed
My SpotifyPlus integration might be able to help with re-activating the Spotify Connect device (SpotCast not required).

I put together a quick How To document on the SpotifyPlus Wiki documentation page with details and service call examples of how to do this. I have had good luck with Onkyo, Bose, PureSound, and Yamaha users that have been able to re-establish a Spotify Connect device with it.

Give it a try and let me know if you have questions or issues.

1 Like

Thanks a lot for this very interesting integration, I will definitely try this!