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

Running simple scrip like this:

  alias: Start summar rewind in office
  sequence:
    - service: spotcast.start
      data:
        spotify_device_id: "7195af83e3044e449c2adf786ed72d92"
        uri : "spotify:playlist:37i9dQZF1CAiFMqgF92dBd"
        random_song: true```

Start summar rewind in office: Error executing script. Error for call_service at pos 1: Could not get spotify token
#Pastebin log here
https://pastebin.com/uF6sLMPE

Choose player
no devices found

same problem…

how did you solve?

@fondberg help please :frowning:

Hiu Red Bull

1 - You must get client_id and client_secret on https://developer.spotify.com/
2 -Config Yaml
spotify:
client_id: !secret spotify_client_id
client_secret: !secret spotify_client_secret
3 - Instal Spotify in Integration
4 - Install Spotcast in HACS (V 3.5.2)
5 - Config Yaml
spotcast:
sp_dc: !secret sp_dc
sp_key: !secret sp_key
accounts:
dan:
sp_dc: !secret dan_sp_dc
sp_key: !secret dan_sp_key
eythan:
sp_dc: !secret eythan_sp_dc
sp_key: !secret eythan_sp_key

Hi.

i did all that: but im getting: Failed to cast media spotify:playlist:7FvCHKzqYNtNCNdZ83bFYm. Please make sure the URL is: Reachable from the cast device and either a publicly resolvable hostname or an IP address

yes… my config is this

media_player:
###########################################################

Media Player Spotify

###########################################################

  • platform: spotify
    client_id: !secret spotify_CLIENT_ID
    client_secret: !secret spotify_CLIENT_SECRET
    aliases:
    abc123def456: ‘Living Room’
    9183abas000: ‘Bed Room’

spotcast:
sp_dc: !secret sp_dc
sp_key: !secret sp_key

I solved it by going:

Enter the Edit Settings dialog of your newly-created application and add a Redirect URI:

https://<your_home_assistant_url_or_local_ip>:<port>/auth/external/callback

instead of
https://<your_home_assistant_url_or_local_ip>:<port>//api/spotify`

Thanks

I’ve just created an issue as 3.5.4 is throwing me errors “Failed to get device id from Spotify” when trying to use a 2nd account - using the primary account everything works fine.

If anyone else sees this error, you can track it here.

I’ve also created an issue for last update.

Before this I just needed entity_id and uri to call the service from dev tools.

Now I need also force_playback, random_song, repeat and offset.

Yeah, I see. I guess this is unintended as all values are optional. The fix is easy (and created a PR for it already).

To apply the fix manually yourself:

  • open /custom_components/spotcast/services.yaml
  • look for any instances of required: true and replace by required: false
  • save and restart HA
1 Like

so the issue only occurs in dev tools?

1 Like

Yes. services.yaml describes how services can be called through the UI, but the actual spotcast service is described in the python code.

1 Like

Great! that was easy then. Thank you!

I have two instances of Home Assistant, on one updated Spotcast to 3.5.4 and it’s not working for second Spotify account. On the other HA instance I’m still running 3.5.2. and working fine for both primary and second Spotify account.

Failed to call service spotcast/start. module ‘pychromecast’ has no attribute ‘get_chromecast_from_cast_info’

Just updated spotcast because I have issues all the time selecting sources and playing music and now I get this error when selecting a source.

Update HA.

hello all,

sorry if this has been already discussed, but I have some troubles on getting the this integration work…

here what I have done:

  • Installed main Spotify Integation under HassOS → Configurations → Integrations and included the Spotify keys
spotify:
  client_id: 1f9a........
  client_secret: f104.......
  • Installed Spotcast Integration under HACS
  • added into my configuration file the followings
spotcast:
  sp_dc: AQBH0BE...........
  sp_key: 04...........

sensor:
  - platform: spotcast

and now I am stacked… how do I progress form here? how do I actually play Spotify on my google mini home?

Thank you all

New release today which re-adds support for multi account

how to add keys for other accounts than default when using (in chrome) chrome://settings/cookies/detail?site=spotify.com it jump from incognito to default browser

Try hitting [F12] (or open “developer tools” through the menu) → tab ‘Application’ → Under “Storage”, select “Cookies”

1 Like

thanks . now i found the keys — but it dont seem to work - only my default account.