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

OK, thanks for your time and efforts so far @fondberg, appreciate it! :+1:

Waiting eagerly for group support so I can automate my “come home from work on friday” playlist. :wink:

Grym component fö!

1 Like

Me too, seems like we are close… there was a “solution example” posted in the Github Issue for Group Play :slight_smile: Im very hopeful that soon this will work from Home Assistant.

1 Like

Yes I tried it and added comments. Problem is that the results fluctuates between my findings and @Ph0z findings…

I’m getting the sensor.chromecast is taking over 10 seconds error very frequently:

2019-05-11 12:40:09 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.chromecast_devices is taking over 10 seconds
2019-05-11 13:08:03 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.chromecast_devices is taking over 10 seconds
2019-05-11 13:10:07 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.chromecast_devices is taking over 10 seconds
2019-05-11 13:25:06 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.chromecast_devices is taking over 10 seconds
2019-05-11 13:41:07 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.chromecast_devices is taking over 10 seconds
2019-05-11 13:55:04 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.chromecast_devices is taking over 10 seconds
2019-05-11 14:10:02 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.chromecast_devices is taking over 10 seconds
2019-05-11 14:25:01 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.chromecast_devices is taking over 10 seconds
2019-05-11 14:32:15 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.chromecast_devices is taking over 10 seconds
2019-05-11 14:40:00 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.chromecast_devices is taking over 10 seconds

My Hass.io is freezing within the last days and mostly these are the latest error messages I get. I’m still not sure if its really connected. Do you see any possible connection?
You said before, the error can be ignored. Is there a way to hide this error, then?

Weird. This should be kind of quick and I think it might be due to slow network. Are you connected using wifi?

The Raspi is connected with Ethernet. (All Google Homes obviously are connected with WiFi)

@capstan1 you can try commenting out the init of the chromecast sensor (not needed to start casting)

# hass.helpers.discovery.load_platform('sensor', DOMAIN, {}, config)

Maybe it is pychromecast which is bogging things down

1 Like

For anyone who want to try bleeding edge until fondberg has updated his. I’ve created a fork which should allow support for group casting and also transferring of playback to your chromecast devices.

Requires the updated pychromecast controller.

Use at your own risk :slight_smile:

Speaker groups and multi accounts is now released. Head over to https://github.com/fondberg/spotcast to download the latest.
I also moved all logging to debug level so if you experience problems add custom_components.spotcast: debug to your logger configuration.
Example:

logger:
  default: info
  logs:
    custom_components.spotcast.: debug
1 Like

Works like a charm! Thanks for this wonderful project.

:exclamation:For people updating manually by replacing the component’s files: be sure to delete the __pycache__ folder. Been pulling my hairs out over that the last hour, because streaming didn’t start.:exclamation:

Did comment it out, up to now the error didn’ts show up. Thanks!

btw: any way to buy you a coffee?

Great it resolved itself. Can you open a ticket on github so I can investigate if there is a better way to run pychromecast?

For a coffee I added the link button in the README in the repo.
Here it also comes. I love coffee :wink:
Buy Me A Coffee

1 Like

All, anyone with knowledge custom updater who can help me with adding support for this?
You can either tell me what to do or just create a PR yourself

Hope you’ll get a good coffee!

I’ll wait a bit with reporting the bug. I noticed that I didn’t get an error within the last 2 hours, although I didn’t yet change the sensor in your latest version. So I’ll have to investigate a little bit more (also it came to my mind that my Google Home Max dropped Wifi connection several times within the last week - maybe that caused the error)

1 Like

I need a bit help, have not figured out everything about all the things in HA. But could someone point me to the direction how to get the music starts to play when i push a button?
Thanks in advance

You first need to make a script like so:

script:
play_music_cc:
alias: Play music
sequence:
- service: spotcast.start
data:
device_name: “CC device name”
uri: “yourplaylistURI”

Then we can trigger it in an automation, like so:

  • alias: ‘Play music’
    initial_state: ‘on’
    trigger:
    platform: event
    event_type: deconz_event
    event_data:
    id: button_Id
    event: 1002
    > action:
    > service: script.turn_on
    > entity_id: script.play_music_cc

Sorry for my formatting, could not find an option for code…

+1 Coffee from me. Very well deserved. Just installed the latest version. Casting to Group Works without a flaw so far for me. I was using hacky work arounds for too long. Thank you a lot!

1 Like

@Pliind Thank you for the input. I made it work with your help.

Is there a way to make the playlist shuffle as well?

2 Likes

Glad to be of help, sat with that issue myself a while, noticed that a reboot helps alot with making new scripts triggable in the automation.

Shuffle was also one of the things i fixed, since you dont want the same song to start every time you press that button. So you need the spotify component for this Spotify

See here: With this script i get a new song every time it starts playing.

bathroom_music_cc:
alias: Playing Bathroom
sequence:
- service: spotcast.start
data:
device_name: “CC device”
uri: “Playlist”
- service: media_player.shuffle_set
data:
entity_id: media_player.spotify
shuffle: true

Hi there, i was just creating a service call for the Spotcast component. And i realized that the call for the device is: “device_name”.

I was wondering if its possible to use the entity_id of the Cast Media Players to send the required names. i.e.:
states.media_player.tv.attributes.friendly_name

I was trying to rename some fields in the custom component it to “entity_id” to make it work with the entity selector. It works but only partialy because i do not know if its even possible to have an attribute from a state to be read by the component.
To me it seems like i need to tell the component to take the entity_id: media_player.tv but then internally only parse the attribute friendly_name and use this instead of device_name. No idea how to do that.

Basically what im asking is this:
Would it be possible to match the already installed media player chromecasts, google homes etc with the component to use them as entities?