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

And now 2.6.1 which should work with the normal zeroconf shipped with hass

2 Likes

It’s working over here! Thanks!

1 Like

Hi
Did you solve this issue ?

I upgrade now , and have same issue

Updating the custom component using the HACS panel to version 2.6.1 fixed it for me!

thanks @fondberg!

it works again with 2.6.1.

I have just a question : when i choose the player (i have 4 google home), each time it’s the first playlist that start and if i clik on “play” on another playlist, the “play” become green but a second after its the first “play” of the first playlist that come back green…in simple word, i cant choose to start a different playlist, except the first one…

Any idea?

Thanks

Did you mean to post this in spotify-card thread?
This component doesn’t have a UI…

1 Like

yes of course…sorry :wink:

Hey @fondberg

I was reading about https://github.com/home-assistant/home-assistant/pull/30717, and saw your comments to the new Spotify intergration (About the more “powerful” token via OAuth). However I don’t quite seem to understand whether this makes it possible to play playlists on idle chromecasts devices? Did you manage to understand that? Have a great weekend :smiley:

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

Thanks for this great component!

I have a question. The component did work great but since a few days I get the following error when I call the service: spotcast.start:

‘NoneType’ object has no attribute ‘host’

I use the latest version 2.6.1. Does anybody know what could be the problem?

Thanks in advance!

That is weird. Seems like it is similar to what 2.6.1 should fix.

Can you send the debug log after enabling debug on spotcast as well as what version of home assiatant you are running (or hassio version)

Hello all,
Thank you for the component @fondberg , it works great!!!

I am now experiencing a weird issue with the state of the media player on each cast sent. These are the steps to replicate the issue:

  1. The Google home is on ‘idle’ state and I call the spotcast.start service

  2. The Media Player changes its state to ‘off’ (instead to ‘playing’), but the music starts playing on the Google home:

Testing the issue, I have discovered that changing the source of the cast (sending spotify music with my cell phone instead of the HA service) the media player recovers the correct state ‘playing’. It could be related to the change of the internal app ID which the media_player handles: CC32E753 from Spotcast and other different app Id from my cell phone

Anyone knows about this topic or has a similar issue?
Thank you very much for your time

1 Like

Thank you for your response :grinning:
I run HA 104.3 (Hassio sv 195; HassOS 3.5).

This shows up in my log:

'NoneType' object has no attribute 'host'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 134, in handle_call_service
    connection.context(msg),
  File "/usr/src/homeassistant/homeassistant/core.py", line 1226, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1251, in _execute_service
    await handler.func(service_call)
  File "/config/custom_components/spotcast/__init__.py", line 156, in start_casting
    spotify_cast_device = SpotifyCastDevice(hass, call.data.get(CONF_DEVICE_NAME), call.data.get(CONF_ENTITY_ID))
  File "/config/custom_components/spotcast/__init__.py", line 207, in __init__
    self.castDevice = self.getChromecastDevice(device_name)
  File "/config/custom_components/spotcast/__init__.py", line 218, in getChromecastDevice
    host = str(cast_info.host)
AttributeError: 'NoneType' object has no attribute 'host'

You need to enable debug on spotcast

I’m not entirely sure I understand the issue.
When you are saying media player, which media player do you refer to? Is it the built in spotify media player? If that is the case, are you running the latest home assiatant version? It has a rewritten spotify integration which could be related. Are you sure you are using the same account for spotcast as on the phone?

Btw. What this the cast add id when casting from your phone?

Thank you very much for your fast response. I am going to try to provide the answers:

  1. The media player of the picture is the media player of the Google Home Mini which I am trying to play music, this media player shows automatically using the discovery mode of the cast integration. (It is not the spotify media player, the Spotify media player doesn’t have this issue)
  2. I am using the latest version of HA (104.3)
  3. In spotcast I have two different associated accounts, I believe I am using the same account in Spotcast and in the phone, forcing Spotcast in the service, using this way:
- service: spotcast.start
  data_template:
    account: dani
    device_name: "Salón"
    uri: "spotify:track:2UC0OxMpQeSYft4pRswyEX"

But I think the issues could appear from this point (having two accounts).

The cast app_id from the log are:
CC32E753 Spotcast
CC1AD845 Cell Phone

Thanks!

Hi

If you want to check if you really are using the same account you can check spotify on your phone and see if something is playing that you started from spotcsst.
Spotcast doesn’t hold any state and is quite simple in the way it only starts spotify on a chromecast device and then starts playing whatever you provide as a URI.

I am however intreaged with the knowledge that there are two different spotify apps on chromecast. That is indeed news to me.

Hello,
I’ve just checked, and can confirm that is the same account between Spotcast and my phone.
Making some tests trying to reproduce the issue, I can see in the log many messages like these :

INFO (SyncWorker_9) [pychromecast.controllers] Not launching app CC1AD845 - already running
(MainThread) [pychromecast.controllers] Not launching app CC32E753 - already running

Like HA was trying to change between the two app_id :confused:

Thank you.

It seems appid CC1AD845 is not spotify but rather “urn:x-cast:com.google.cast.receiver”.
Spotify appid is CC32E753 which is “urn:x-cast:com.spotify.chromecast.secure.v1”-

This indicates to me that thise log lines are unrelated. To help I need you to enable debug logs for spotcast (in configuration.yaml and send everything from pychromecast and spotcast

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

Thank you for clarifying the Apps id matter. With your help, I have discovered that the appid CC1AD845 is for TTS notifying, and as you said I think is not interferring on this issue.

Please find below an extract of the log. Just to have all the context, which I am trying to do is “auto” restart Spotify after a TTS google notification (tts stops spotify playing).
So the steps from the log are:

  1. Play spotify from Spotcast (no problem here)
  2. Stop audio with service: media_player.media_stop (no problem here)
  3. Turn Off Media player with service: media_player.turn_off (no problem here)
  4. Notify TTS (no problem here)
  5. Relaunch Spotcast: here is the problem, the Google home starts playing music in the correct way but the home assistant media player shows “Off” state, until I send music with other source (my phone for example)
View Log code

2020-02-04 23:48:55 DEBUG (SyncWorker_31) [custom_components.spotcast.sensor] Found chromecast devices: [Chromecast(‘record[a,in-unique,c44aba16-109c-5510-14c9-85c2aa74f5f2.local.]=120/119,192.168.1.34’, port=8009, device=DeviceStatus(friendly_name=‘BRAVIA 4K GB’, model_name=‘BRAVIA 4K GB’, manufacturer=None, uuid=UUID(‘c44aba16-109c-5510-14c9-85c2aa74f5f2’), cast_type=‘cast’)), Chromecast(‘record[a,in-unique,98d003f2-0a48-d9a7-0f27-07d65bf41b68.local.]=120/119,192.168.1.144’, port=8009, device=DeviceStatus(friendly_name=‘Cocina’, model_name=‘Google Home Mini’, manufacturer=None, uuid=UUID(‘98d003f2-0a48-d9a7-0f27-07d65bf41b68’), cast_type=‘audio’)), Chromecast(‘record[a,in-unique,ac7b5a4d-4dda-2aa3-d8b0-23f1b9e62df5.local.]=120/119,192.168.1.7’, port=8009, device=DeviceStatus(friendly_name=‘Salón’, model_name=‘Google Home’, manufacturer=None, uuid=UUID(‘ac7b5a4d-4dda-2aa3-d8b0-23f1b9e62df5’), cast_type=‘audio’)), Chromecast(‘record[a,in-unique,ac7b5a4d-4dda-2aa3-d8b0-23f1b9e62df5.local.]=120…
2020-02-04 23:48:55 INFO (SyncWorker_31) [pychromecast] Querying device status
2020-02-04 23:48:55 INFO (SyncWorker_31) [pychromecast] Querying device status
2020-02-04 23:48:55 INFO (SyncWorker_31) [pychromecast] Querying device status
2020-02-04 23:48:55 INFO (SyncWorker_31) [pychromecast] Querying device status
2020-02-04 23:48:55 INFO (SyncWorker_31) [pychromecast] Querying device status
2020-02-04 23:48:55 INFO (SyncWorker_31) [pychromecast] Querying device status
2020-02-04 23:48:55 INFO (SyncWorker_31) [pychromecast] Querying device status
2020-02-04 23:49:15 DEBUG (MainThread) [custom_components.spotcast] setting up with different account than default dani
2020-02-04 23:49:16 DEBUG (MainThread) [custom_components.spotcast] cast info: ChromecastInfo(host=‘record[a,in-unique,ac7b5a4d-4dda-2aa3-d8b0-23f1b9e62df5.local.]=120/119,192.168.1.7’, port=8009, service=‘Google-Home-ac7b5a4d4dda2aa3d8b023f1b9e62df5._googlecast._tcp.local.’, uuid=‘ac7b5a4d-4dda-2aa3-d8b0-23f1b9e62df5’, manufacturer=’’, model_name=‘Google Home’, friendly_name=‘Salón’, is_dynamic_group=None)
2020-02-04 23:49:16 DEBUG (MainThread) [custom_components.spotcast] Found cast device: Chromecast(‘192.168.1.7’, port=8009, device=DeviceStatus(friendly_name=‘Salón’, model_name=‘Google Home’, manufacturer=‘Unknown manufacturer’, uuid=‘ac7b5a4d-4dda-2aa3-d8b0-23f1b9e62df5’, cast_type=‘audio’))
2020-02-04 23:49:16 INFO (MainThread) [pychromecast] Querying device status
2020-02-04 23:49:16 INFO (Thread-18527) [pychromecast.controllers] Receiver:Launching app CC32E753
2020-02-04 23:49:19 DEBUG (MainThread) [custom_components.spotcast] Playing context uri using context_uri for uri: “spotify:playlist:37i9dQZF1DX3yvAYDslnv8” (random_song: False)
2020-02-04 23:49:19 DEBUG (MainThread) [custom_components.spotcast] Version: 2.6.1, playing URI: spotify:playlist:37i9dQZF1DX3yvAYDslnv8 on device-id: ac7b5a4d4dda2aa3d8b023f1b9e62df5
2020-02-04 23:49:28 DEBUG (SyncWorker_28) [custom_components.spotcast.sensor] Found chromecast devices: [Chromecast(‘record[a,in-unique,c44aba16-109c-5510-14c9-85c2aa74f5f2.local.]=120/119,192.168.1.34’, port=8009, device=DeviceStatus(friendly_name=‘BRAVIA 4K GB’, model_name=‘BRAVIA 4K GB’, manufacturer=None, uuid=UUID(‘c44aba16-109c-5510-14c9-85c2aa74f5f2’), cast_type=‘cast’)), Chromecast(‘record[a,in-unique,ac7b5a4d-4dda-2aa3-d8b0-23f1b9e62df5.local.]=120/119,192.168.1.7’, port=8009, device=DeviceStatus(friendly_name=‘Salón’, model_name=‘Google Home’, manufacturer=None, uuid=UUID(‘ac7b5a4d-4dda-2aa3-d8b0-23f1b9e62df5’), cast_type=‘audio’)), Chromecast(‘record[a,in-unique,ac7b5a4d-4dda-2aa3-d8b0-23f1b9e62df5.local.]=120/119,192.168.1.7’, port=42310, device=DeviceStatus(friendly_name=‘Toda La Casa’, model_name=‘Google Cast Group’, manufacturer=None, uuid=UUID(‘51eb1145-a850-44e4-9d4e-76ab9e552412’), cast_type=‘group’)), Chromecast(‘record[a,in-unique,98d003f2-0a48-d9a7-0f27-07d65bf41b68.local…
2020-02-04 23:49:28 INFO (SyncWorker_28) [pychromecast] Querying device status
2020-02-04 23:49:28 INFO (SyncWorker_28) [pychromecast] Querying device status
2020-02-04 23:49:28 INFO (SyncWorker_28) [pychromecast] Querying device status
2020-02-04 23:49:28 INFO (SyncWorker_28) [pychromecast] Querying device status
2020-02-04 23:49:28 INFO (SyncWorker_28) [pychromecast] Querying device status
2020-02-04 23:49:28 INFO (SyncWorker_28) [pychromecast] Querying device status
2020-02-04 23:49:28 INFO (SyncWorker_28) [pychromecast] Querying device status
2020-02-04 23:49:38 INFO (SyncWorker_13) [pychromecast.controllers] Receiver:Stopping current app ‘None’
2020-02-04 23:49:38 INFO (SyncWorker_13) [pychromecast] Quiting current app
2020-02-04 23:49:38 INFO (SyncWorker_25) [pychromecast.controllers] Receiver:Stopping current app ‘None’
2020-02-04 23:49:38 INFO (SyncWorker_25) [pychromecast] Quiting current app
2020-02-04 23:49:38 INFO (SyncWorker_27) [pychromecast.controllers] Receiver:Stopping current app ‘None’
2020-02-04 23:49:38 INFO (SyncWorker_27) [pychromecast] Quiting current app
2020-02-04 23:49:38 INFO (SyncWorker_31) [pychromecast.controllers] Receiver:Stopping current app ‘CC32E753’
2020-02-04 23:49:38 INFO (SyncWorker_31) [pychromecast] Quiting current app
2020-02-04 23:49:38 INFO (SyncWorker_38) [pychromecast.controllers] Receiver:Stopping current app ‘None’
2020-02-04 23:49:38 INFO (SyncWorker_38) [pychromecast] Quiting current app
2020-02-04 23:49:38 WARNING (SyncWorker_12) [pychromecast.controllers] STOP command requested but no session is active.
2020-02-04 23:49:38 WARNING (SyncWorker_15) [pychromecast.controllers] STOP command requested but no session is active.
2020-02-04 23:49:38 WARNING (SyncWorker_8) [pychromecast.controllers] STOP command requested but no session is active.
2020-02-04 23:49:38 WARNING (SyncWorker_9) [pychromecast.controllers] STOP command requested but no session is active.
2020-02-04 23:49:44 INFO (Thread-5) [pychromecast.controllers] Receiver:Launching app CC1AD845
2020-02-04 23:49:44 INFO (Thread-6) [pychromecast.controllers] Receiver:Launching app CC1AD845
2020-02-04 23:49:44 INFO (Thread-7) [pychromecast.controllers] Receiver:Launching app CC1AD845
2020-02-04 23:49:44 INFO (Thread-8) [pychromecast.controllers] Receiver:Launching app CC1AD845
2020-02-04 23:49:44 INFO (Thread-9) [pychromecast.controllers] Receiver:Launching app CC1AD845
2020-02-04 23:49:55 INFO (SyncWorker_3) [pychromecast.controllers] Not launching app CC1AD845 - already running
2020-02-04 23:49:59 DEBUG (SyncWorker_22) [custom_components.spotcast.sensor] Found chromecast devices: [Chromecast(‘record[a,in-unique,c44aba16-109c-5510-14c9-85c2aa74f5f2.local.]=120/119,192.168.1.34’, port=8009, device=DeviceStatus(friendly_name=‘BRAVIA 4K GB’, model_name=‘BRAVIA 4K GB’, manufacturer=None, uuid=UUID(‘c44aba16-109c-5510-14c9-85c2aa74f5f2’), cast_type=‘cast’)), Chromecast(‘record[a,in-unique,ac7b5a4d-4dda-2aa3-d8b0-23f1b9e62df5.local.]=120/119,192.168.1.7’, port=8009, device=DeviceStatus(friendly_name=‘Salón’, model_name=‘Google Home’, manufacturer=None, uuid=UUID(‘ac7b5a4d-4dda-2aa3-d8b0-23f1b9e62df5’), cast_type=‘audio’)), Chromecast(‘record[a,in-unique,ac7b5a4d-4dda-2aa3-d8b0-23f1b9e62df5.local.]=120/119,192.168.1.7’, port=42310, device=DeviceStatus(friendly_name=‘Toda La Casa’, model_name=‘Google Cast Group’, manufacturer=None, uuid=UUID(‘51eb1145-a850-44e4-9d4e-76ab9e552412’), cast_type=‘group’)), Chromecast(‘record[a,in-unique,a0074f4a-243c-6f09-34d7-56c89fffd18f.local…
2020-02-04 23:49:59 INFO (SyncWorker_22) [pychromecast] Querying device status
2020-02-04 23:49:59 INFO (SyncWorker_22) [pychromecast] Querying device status
2020-02-04 23:49:59 INFO (SyncWorker_22) [pychromecast] Querying device status
2020-02-04 23:49:59 INFO (SyncWorker_22) [pychromecast] Querying device status
2020-02-04 23:49:59 INFO (SyncWorker_22) [pychromecast] Querying device status
2020-02-04 23:49:59 INFO (SyncWorker_22) [pychromecast] Querying device status
2020-02-04 23:49:59 INFO (SyncWorker_22) [pychromecast] Querying device status
2020-02-04 23:50:01 DEBUG (MainThread) [custom_components.spotcast] cast info: ChromecastInfo(host=‘record[a,in-unique,ac7b5a4d-4dda-2aa3-d8b0-23f1b9e62df5.local.]=120/119,192.168.1.7’, port=8009, service=‘Google-Home-ac7b5a4d4dda2aa3d8b023f1b9e62df5._googlecast._tcp.local.’, uuid=‘ac7b5a4d-4dda-2aa3-d8b0-23f1b9e62df5’, manufacturer=’’, model_name=‘Google Home’, friendly_name=‘Salón’, is_dynamic_group=None)
2020-02-04 23:50:01 DEBUG (MainThread) [custom_components.spotcast] Found cast device: Chromecast(‘192.168.1.7’, port=8009, device=DeviceStatus(friendly_name=‘Salón’, model_name=‘Google Home’, manufacturer=‘Unknown manufacturer’, uuid=‘ac7b5a4d-4dda-2aa3-d8b0-23f1b9e62df5’, cast_type=‘audio’))
2020-02-04 23:50:01 DEBUG (MainThread) [custom_components.spotcast] setting up with different account than default dani
2020-02-04 23:50:01 INFO (MainThread) [pychromecast.controllers] Receiver:Launching app CC32E753
2020-02-04 23:50:01 INFO (MainThread) [pychromecast] Querying device status
2020-02-04 23:50:04 DEBUG (MainThread) [custom_components.spotcast] Playing track using uris= for uri: spotify:track:1yo16b3u0lptm6Cs7lx4AD
2020-02-04 23:50:04 DEBUG (MainThread) [custom_components.spotcast] Version: 2.6.1, playing URI: spotify:track:1yo16b3u0lptm6Cs7lx4AD on device-id: ac7b5a4d4dda2aa3d8b023f1b9e62df5
2020-02-04 23:50:31 DEBUG (SyncWorker_18) [custom_components.spotcast.sensor] Found chromecast devices: [Chromecast(‘record[a,in-unique,c44aba16-109c-5510-14c9-85c2aa74f5f2.local.]=120/119,192.168.1.34’, port=8009, device=DeviceStatus(friendly_name=‘BRAVIA 4K GB’, model_name=‘BRAVIA 4K GB’, manufacturer=None, uuid=UUID(‘c44aba16-109c-5510-14c9-85c2aa74f5f2’), cast_type=‘cast’)), Chromecast(‘record[a,in-unique,ac7b5a4d-4dda-2aa3-d8b0-23f1b9e62df5.local.]=120/119,192.168.1.7’, port=8009, device=DeviceStatus(friendly_name=‘Salón’, model_name=‘Google Home’, manufacturer=None, uuid=UUID(‘ac7b5a4d-4dda-2aa3-d8b0-23f1b9e62df5’), cast_type=‘audio’)), Chromecast(‘record[a,in-unique,ac7b5a4d-4dda-2aa3-d8b0-23f1b9e62df5.local.]=120/119,192.168.1.7’, port=42310, device=DeviceStatus(friendly_name=‘Toda La Casa’, model_name=‘Google Cast Group’, manufacturer=None, uuid=UUID(‘51eb1145-a850-44e4-9d4e-76ab9e552412’), cast_type=‘group’)), Chromecast('record[a,in-unique,b453eceb-b1a4-b595-b1cf-f0dce41f4d34.local…
2020-02-04 23:50:31 INFO (SyncWorker_18) [pychromecast] Querying device status
2020-02-04 23:50:31 INFO (SyncWorker_18) [pychromecast] Querying device status
2020-02-04 23:50:31 INFO (SyncWorker_18) [pychromecast] Querying device status
2020-02-04 23:50:31 INFO (SyncWorker_18) [pychromecast] Querying device status
2020-02-04 23:50:31 INFO (SyncWorker_18) [pychromecast] Querying device status
2020-02-04 23:50:31 INFO (SyncWorker_18) [pychromecast] Querying device status
2020-02-04 23:50:31 INFO (SyncWorker_18) [pychromecast] Querying device status
2020-02-04 23:51:01 DEBUG (SyncWorker_11) [custom_components.spotcast.sensor] Found chromecast devices: [Chromecast(‘record[a,in-unique,c44aba16-109c-5510-14c9-85c2aa74f5f2.local.]=120/119,192.168.1.34’, port=8009, device=DeviceStatus(friendly_name=‘BRAVIA 4K GB’, model_name=‘BRAVIA 4K GB’, manufacturer=None, uuid=UUID(‘c44aba16-109c-5510-14c9-85c2aa74f5f2’), cast_type=‘cast’)), Chromecast(‘record[a,in-unique,b453eceb-b1a4-b595-b1cf-f0dce41f4d34.local.]=120/119,192.168.1.190’, port=8009, device=DeviceStatus(friendly_name=‘Despacho’, model_name=‘Google Home Mini’, manufacturer=None, uuid=UUID(‘b453eceb-b1a4-b595-b1cf-f0dce41f4d34’), cast_type=‘audio’)), Chromecast(‘record[a,in-unique,a0074f4a-243c-6f09-34d7-56c89fffd18f.local.]=120/119,192.168.1.173’, port=8009, device=DeviceStatus(friendly_name=‘Aseo’, model_name=‘Google Home Mini’, manufacturer=None, uuid=UUID(‘a0074f4a-243c-6f09-34d7-56c89fffd18f’), cast_type=‘audio’)), Chromecast('record[a,in-unique,ac7b5a4d-4dda-2aa3-d8b0-23f1b9e62df5.loc…
2020-02-04 23:51:01 INFO (SyncWorker_11) [pychromecast] Querying device status
2020-02-04 23:51:01 INFO (SyncWorker_11) [pychromecast] Querying device status
2020-02-04 23:51:01 INFO (SyncWorker_11) [pychromecast] Querying device status
2020-02-04 23:51:01 INFO (SyncWorker_11) [pychromecast] Querying device status
2020-02-04 23:51:01 INFO (SyncWorker_11) [pychromecast] Querying device status
2020-02-04 23:51:01 INFO (SyncWorker_11) [pychromecast] Querying device status
2020-02-04 23:51:01 INFO (SyncWorker_11) [pychromecast] Querying device status