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

Thanks for your reply!
Added the indents, but still getting the same error.

The ModuleNotfound error disappeared for me after an extra restart of HA.

@fondberg
looking at the media_player on Github there seems to be two contributors cgtobi & balloob

1 Like

I restarted several times now, but still getting the same errors.

Succesfully added the custom component but when try to play something with the following service, I get the error below.

{
“device_name” : “Google Home Speelkamer”,
“uri” : “spotify:playlist:37i9dQZF1DX3yvAYDslnv8”
}

No module named ‘spotify_token’
18:21 custom_components/spotcast/init.py (ERROR) - message first occured at 18:16 and shows up 3 times

awesome work man. I like your Spotify card and now this. I’ll start testing it soon and let you know of any issues.

Which version of HA are you running? I think my component requires 0.92 because the dependencies changed in that release to be specified in a manifest instead of in the python file.

If you are running 0.92 I would look in the logs for any errors importing spotify_token

@capstan1 ^^ you should also follow this

1 Like

0.91.4. Will try again after an upgrade to 0.92

Should be the issue. Didn’t want to update Hassio because I wouldn’t have the time to troubleshoot right now. Think I will upgrade this weekend, so I’ll let you know if that helps!

Thanks!

Just updated to 0.92.1, this fixes the problem! Great!

It takes about 6-8 seconds to actually play a song after executing the command. Is this normal (for now)?

Yeah I’m seeing the same currently on .92.1

After a reboot my google does appear ad playing on HA

It’s just the delay

It takes time because it needs to launch the app after discovering hr device

I don’t know python, but am happy to help in anyway I can.

1 Like

This binary sensor will detect if Spotify is playing on a specific Google Chromecast device. I use it for my automations that automatically toggle the amp when audio is playing. Reason for this template sensor is the media_player device shows as ‘off’ when the cast was started from Spotcast, even when the device is in fact playing.

binary_sensor:
  - platform: template
    sensors:
      stereo_spotcasting:
        friendly_name: "Stereo is playing Spotcast" 
        value_template: "{{ is_state_attr('media_player.spotify','source','Stereo') and is_state('media_player.spotify','playing') }}"

Of course replace ‘Stereo’ with your device name.

2 Likes

noob question but how do i use this:

cd /config/custom_components && git clone https://github.com/fondberg/spotcast.git

thanks!

@Mikomi instead of that you can just download the files and put them in /config/custom_components/spotcast/

Thanks!
Sensor.chromecast_devices detects them now. But they dont show up he source selection of my Spotify media player. Or does this only work with the custom playlist card?

@Mikomi this component and the spotify-card custom card doesn’t use the media_player spotify… yet… I am thinking of merging my components functionality somehow in media_player.spotify.

This components sensor just lists the chromecast devices in your network and media_player.spotify doesn’t make use of chromecast devices, only logged in started Spotify connect devices… phew… this isa little bit of a mess but hopefully this can be sorted out in the future

1 Like

Aha, this explains a lot. Thanks for the detailed information. So if im correct i need to craft custom “buttons” for my playlists or use the custom card, right?
Thanks for your work it was what I wanted for a while now.

Depends on your usecase is to start Spotify playback on idle chromecast devices then yes. If it is to start playing a playlist on an already launched Spotify connect device (which launching Spotify on a chromecast device does) then stick with media_player.spotify