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

I am legit looking for the same solution to this… Alexa does a great job at forgetting.

I think it’s Spotify forgetting the Alexa devices more than it being the other way around, but ya it’s a major pita either way.

1 Like

Yeah, only works with music unfortunately

1 Like

Did you get this to work ?
I can only get one account to work.

I have the same problem. If I have used the device previously I can start it, but if I have not I get “ChromecastInfo’ object has no attribute ‘cast_type’”. However, I have one device that is a Spotify connect (a Yamaha amplifier) - this allways works. The other devices are Google cast devices - it is for those I get the “ChromecastInfo’ object has no attribute ‘cast_type’” error. I use core-2021.12.7/supervisor-2021.12.2

Did you find the solution?

Is there a way to spotcast to multiple speakers/media_players at the same time? I somehow wrongly assumed that I could just pass in multiple entity_ids and spotcast to multiple speakers at the same time.

You can group your cast devices in the Google Home app. Then spotcast to the group.

Yes, updating Spotcast to latest version solved the issue :slight_smile:

@freekeys did you fix this? I can see sp_dc but I cant see sp_key any more :frowning:

NVM, I used Incognito mode and the sp_key showed up.

It’s working really nicely!

1 Like

I have some groups but I want to on demand select the speakers I want to cast to. For example, I have 9 speakers for different rooms, but I don’t want to create all possible permutations as a group for casting because sometimes I want room A and B to play music, sometimes room C D and E.

Could I do that (the ability to choose which multiple speakers I want to cast to) with spotcast?

I don’t think you can do that. You can ofcourse define all of the different combinations of rooms as groups in Google Home. And then create some fancy Lovelace for selecting those.

Trying to get a second account working (for the kids) but I can’t get it to play.

In the log:

Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/spotcast/spotcast_controller.py:180
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 16:05:33 (1 occurrences)
Last logged: 16:05:33

[140514968856128] 'NoneType' object is not subscriptable
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 273, in service_handler
    await script_entity.async_turn_on(
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 377, in async_turn_on
    await coro
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 403, in _async_run
    return await self.script.async_run(script_vars, context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1260, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 363, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 381, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 584, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1534, in _execute_service
    await self._hass.async_add_executor_job(handler.job.target, service_call)
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/spotcast/__init__.py", line 156, in start_casting
    spotify_device_id = spotcast_controller.get_spotify_device_id(
  File "/config/custom_components/spotcast/spotcast_controller.py", line 193, in get_spotify_device_id
    spotify_device_id = self._getSpotifyConnectDeviceId(client, device_name)
  File "/config/custom_components/spotcast/spotcast_controller.py", line 180, in _getSpotifyConnectDeviceId
    for device in devices_available["devices"]:
TypeError: 'NoneType' object is not subscriptable

Any help?

Not possible with Google Home and Home Assistant. Google Home does not offer a way for third parties to create groups and link/unlink speakers on the fly. Only possible withing Google Home. So only solution is what you’re already doing: create all combinations of groups within Google Home and them cast from Home Assistant to a pre-defined group (which acts like a single media player in Home Assistant).

This is one of the reason I ditched music from Chromecast all together. Also I got crazy with Spotcast, since Spotify keeps changing its API and this plugin breaks randomly and needs to be fixed by the dev. And the 60min token expiration just ruins the whole point of music automation (which the creator of this plugin can’t do anything about because of how shitty Spotify operates). Sometimes Chromecat group speakers became unavailable as well in my setup, only a HA restart fixed it.

I have 6 Google speakers I strictly use for voice and notifications now. I use Logitech Media Server for all my music now, which is 100x better and is like Sonos (but better imho). Full Spotify, Tidal, Deezer, Radio, YouTube support and on the fly syncing/unsyncing of multiroom speakers. Also has native integration in Home Assistant. This is their forum if your interested: https://forums.slimdevices.com There are multiple threads about Logitech Media Server in HA forums as well if you’re interested.

I am new to HA and trying to get this working so bear with my trivial questions.

I have added the necessary sp_dc and sp_key cookies to the configuration.yaml file, but in which file should I call the service?
E.g. to start the playback and use this code:
{
“spotify_device_id” : “ab123c5d7347324c2b1234567890f8d6dc40350”,
“uri” : “spotify:playlist:37i9dQZF1DX3yvAYDslnv8”,
“random_song”: true
}

…where should this be added?

Hi @ame44, you need to make a service call. Which can be made in multiple ways (scripts, automotation, from the UI with a button that calls the service)

If you want to simply test it, you can go in developper tools (the menu entry is at the bottom) and in the service section, you can select the service you want to test and fill out a form to test a certain packet of information. Otherwise, for a more day to day use, I would suggest you read on scripting. It can provide you information on how to create and write functionnal script.

The UI is laso very good now to build script for you. In configuration, you can go in scripts. And let the UI guide you in creating the sequence of action.

Hi,

Small reminder that if people have problem with the component, please fill an issue in github. Although some of the collaborators do verify this thread, the github page is the best place to make sure the issue is known for me and the other maintainer.

This way is much more usefull for debugging and resolving specific issues since we can keep one conversation per discussion thread.

Hello =)

sorry for my beginner question, but where do I put “-id” under it. I copied the lines from the Official Spotcast Github article and would like to use this.
Do I copy this directly into the YAML file? or is that a script? But then the sequence would be missing?

Please help, I would be very grateful.

  • id : ’ jul_spotify_spela_julmusik ’
    alias : Jul spela julmusik
    initial_state : ’ on ’
    trigger :
    • event_data :
      id : remote_fonsterlampor
      event : 5002
      platform : event
      event_type : deconz_event
      condition : []
      action :
    • data :
      uri : ’ spotify:playlist:56Bor5fbMJlJV7oryb2p3k ’
      random_song : true
      shuffle : true
      start_volume : 50
      entity_id : media_player.gh_kok
      service : spotcast.start

That is an automation script you pasted in.