Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to get device id from Spotify (3.5.4) #196

Closed
hmmbob opened this issue Apr 19, 2021 · 17 comments
Closed

Failed to get device id from Spotify (3.5.4) #196

hmmbob opened this issue Apr 19, 2021 · 17 comments

Comments

@hmmbob
Copy link
Contributor

hmmbob commented Apr 19, 2021

Hi Niklas,

Tried the new release, but it is throwing errors at me when I am using a 2nd account:

Spotcast config (3.5.4):

# configuration.yaml 

spotcast:
  sp_dc: !secret spotcast_sp_dc
  sp_key: !secret spotcast_sp_key
  accounts:
    t:
      sp_dc: !secret spotcast_t_sp_dc
      sp_key: !secret spotcast_t_sp_key
# scripts.yaml in HomeAssistant

start_music_t:
  alias: Slaaptijd
  mode: restart
  sequence:
    - service: spotcast.start
      data:
        account: "t"
        entity_id: media_player.hmt
        uri: "spotify:track:5OoSxUZSbP1p7kb1d0SozG"

Error in the log:

2021-04-19 09:35:30 DEBUG (SyncWorker_4) [custom_components.spotcast] setting up with account t
2021-04-19 09:35:30 DEBUG (SyncWorker_4) [custom_components.spotcast] get_cast_devices: media_player.soundbar: Soundbar cast info: ChromecastInfo(services={ServiceInfo(type='mdns', data='B8805-81704a75fd037a7c38090eb3c5dffea5._googlecast._tcp.local.')}, uuid='81704a75-fd03-7a7c-3809-0eb3c5dffea5', _manufacturer=None, model_name='B8805', friendly_name='Soundbar', is_audio_group=False, is_dynamic_group=None)
2021-04-19 09:35:30 DEBUG (SyncWorker_4) [custom_components.spotcast] get_cast_devices: media_player.woonkamer: Woonkamer cast info: ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Nest-Hub-4660f5b8aabe10031a93ebd362367256._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.xx.16', 8009))}, uuid='4660f5b8-aabe-1003-1a93-ebd362367256', _manufacturer='Google Inc.', model_name='Google Nest Hub', friendly_name='Woonkamer', is_audio_group=False, is_dynamic_group=None)
2021-04-19 09:35:30 DEBUG (SyncWorker_4) [custom_components.spotcast] get_cast_devices: media_player.hele_huis: Hele huis cast info: ChromecastInfo(services={ServiceInfo(type='host', data=('192.168.xx.16', 32059)), ServiceInfo(type='mdns', data='Google-Cast-Group-eec4b1d472ec428fad8f291a69a2d97d-1._googlecast._tcp.local.')}, uuid='eec4b1d4-72ec-428f-ad8f-291a69a2d97d', _manufacturer=None, model_name='Google Cast Group', friendly_name='Hele huis', is_audio_group=True, is_dynamic_group=False)
2021-04-19 09:35:30 DEBUG (SyncWorker_4) [custom_components.spotcast] get_cast_devices: media_player.studeerkamer: Studeerkamer cast info: ChromecastInfo(services={ServiceInfo(type='host', data=('192.168.xx.12', 8009)), ServiceInfo(type='mdns', data='Google-Home-d4063db0253e246c9d66d8f7fda77a6a._googlecast._tcp.local.')}, uuid='d4063db0-253e-246c-9d66-d8f7fda77a6a', _manufacturer='Google Inc.', model_name='Google Home', friendly_name='Studeerkamer', is_audio_group=False, is_dynamic_group=None)
2021-04-19 09:35:30 DEBUG (SyncWorker_4) [custom_components.spotcast] get_cast_devices: media_player.zolder: Zolder cast info: ChromecastInfo(services={ServiceInfo(type='host', data=('192.168.xx.17', 8009)), ServiceInfo(type='mdns', data='Google-Home-Mini-71d8c580bbd0166b72f10071a427b6cb-1._googlecast._tcp.local.'), ServiceInfo(type='host', data=('[::ffff:c0a8:5811]', 8009))}, uuid='71d8c580-bbd0-166b-72f1-0071a427b6cb', _manufacturer='Google Inc.', model_name='Google Home Mini', friendly_name='Zolder', is_audio_group=False, is_dynamic_group=None)
2021-04-19 09:35:30 DEBUG (SyncWorker_4) [custom_components.spotcast] get_cast_devices: media_player.boven: Boven cast info: ChromecastInfo(services={ServiceInfo(type='host', data=('[::ffff:c0a8:5811]', 32213)), ServiceInfo(type='host', data=('192.168.xx.17', 32213)), ServiceInfo(type='mdns', data='Google-Cast-Group-e18cddf284be43da9917ddb7d4ceb42c-2._googlecast._tcp.local.')}, uuid='e18cddf2-84be-43da-9917-ddb7d4ceb42c', _manufacturer=None, model_name='Google Cast Group', friendly_name='Boven', is_audio_group=True, is_dynamic_group=False)
2021-04-19 09:35:30 DEBUG (SyncWorker_4) [custom_components.spotcast] get_cast_devices: media_player.hmt: HMT cast info: ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Home-Mini-0256c1dd13b44c80849b281970d02d11._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.xx.13', 8009))}, uuid='0256c1dd-13b4-4c80-849b-281970d02d11', _manufacturer='Google Inc.', model_name='Google Home Mini', friendly_name='HMT', is_audio_group=False, is_dynamic_group=None)
2021-04-19 09:35:30 DEBUG (SyncWorker_4) [custom_components.spotcast] Chromecast devices: [ChromecastInfo(services={ServiceInfo(type='mdns', data='B8805-81704a75fd037a7c38090eb3c5dffea5._googlecast._tcp.local.')}, uuid='81704a75-fd03-7a7c-3809-0eb3c5dffea5', _manufacturer=None, model_name='B8805', friendly_name='Soundbar', is_audio_group=False, is_dynamic_group=None), ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Nest-Hub-4660f5b8aabe10031a93ebd362367256._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.xx.16', 8009))}, uuid='4660f5b8-aabe-1003-1a93-ebd362367256', _manufacturer='Google Inc.', model_name='Google Nest Hub', friendly_name='Woonkamer', is_audio_group=False, is_dynamic_group=None), ChromecastInfo(services={ServiceInfo(type='host', data=('192.168.xx.16', 32059)), ServiceInfo(type='mdns', data='Google-Cast-Group-eec4b1d472ec428fad8f291a69a2d97d-1._googlecast._tcp.local.')}, uuid='eec4b1d4-72ec-428f-ad8f-291a69a2d97d', _manufacturer=None, model_name='Google Cast Group', friendly_name='Hele huis', is_audio_group=True, is_dynamic_group=False), ChromecastInfo(services={ServiceInfo(type='host', data=('192.168.xx.12', 8009)), ServiceInfo(type='mdns', data='Google-Home-d4063db0253e246c9d66d8f7fda77a6a._googlecast._tcp.local.')}, uuid='d4063db0-253e-246c-9d66-d8f7fda77a6a', _manufacturer='Google Inc.', model_name='Google Home', friendly_name='Studeerkamer', is_audio_group=False, is_dynamic_group=None), ChromecastInfo(services={ServiceInfo(type='host', data=('192.168.xx.17', 8009)), ServiceInfo(type='mdns', data='Google-Home-Mini-71d8c580bbd0166b72f10071a427b6cb-1._googlecast._tcp.local.'), ServiceInfo(type='host', data=('[::ffff:c0a8:5811]', 8009))}, uuid='71d8c580-bbd0-166b-72f1-0071a427b6cb', _manufacturer='Google Inc.', model_name='Google Home Mini', friendly_name='Zolder', is_audio_group=False, is_dynamic_group=None), ChromecastInfo(services={ServiceInfo(type='host', data=('[::ffff:c0a8:5811]', 32213)), ServiceInfo(type='host', data=('192.168.xx.17', 32213)), ServiceInfo(type='mdns', data='Google-Cast-Group-e18cddf284be43da9917ddb7d4ceb42c-2._googlecast._tcp.local.')}, uuid='e18cddf2-84be-43da-9917-ddb7d4ceb42c', _manufacturer=None, model_name='Google Cast Group', friendly_name='Boven', is_audio_group=True, is_dynamic_group=False), ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Home-Mini-0256c1dd13b44c80849b281970d02d11._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.xx.13', 8009))}, uuid='0256c1dd-13b4-4c80-849b-281970d02d11', _manufacturer='Google Inc.', model_name='Google Home Mini', friendly_name='HMT', is_audio_group=False, is_dynamic_group=None)]
2021-04-19 09:35:30 DEBUG (SyncWorker_4) [custom_components.spotcast] cast info: ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Home-Mini-0256c1dd13b44c80849b281970d02d11._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.xx.13', 8009))}, uuid='0256c1dd-13b4-4c80-849b-281970d02d11', _manufacturer='Google Inc.', model_name='Google Home Mini', friendly_name='HMT', is_audio_group=False, is_dynamic_group=None)
2021-04-19 09:35:30 DEBUG (SyncWorker_4) [custom_components.spotcast] Found cast device: Chromecast(None, port=8009, device=DeviceStatus(friendly_name='HMT', model_name='Google Home Mini', manufacturer='Google Inc.', uuid='0256c1dd-13b4-4c80-849b-281970d02d11', cast_type='audio'))
2021-04-19 09:35:36 DEBUG (SyncWorker_4) [custom_components.spotcast] get_spotify_devices: media_player.spotify_t: Spotify T HH: []
2021-04-19 09:35:36 DEBUG (SyncWorker_4) [custom_components.spotcast] get_spotify_devices: media_player.spotify_m: Spotify M HH: []
2021-04-19 09:35:36 DEBUG (SyncWorker_4) [custom_components.spotcast] get_spotify_devices: media_player.spotify_hmmbob: Spotify Hmmbob HH: []
2021-04-19 09:35:36 DEBUG (SyncWorker_4) [custom_components.spotcast] devices_available: {'devices': []} bf7485e4bdc069dfd996748826af2f02
2021-04-19 09:35:36 ERROR (SyncWorker_4) [custom_components.spotcast] No device with id "bf7485e4bdc069dfd996748826af2f02" known by Spotify
2021-04-19 09:35:36 ERROR (SyncWorker_4) [custom_components.spotcast] Known devices: []
2021-04-19 09:35:36 ERROR (MainThread) [homeassistant.components.script.start_music_t] Slaaptijd: Error executing script. Error for call_service at pos 2: Failed to get device id from Spotify
2021-04-19 09:35:36 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 392, in _async_run
return await self.script.async_run(variables, context)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1200, in async_run
await asyncio.shield(run.async_run())
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 341, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 359, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 559, in _async_call_service_step
await service_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1480, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1519, in _execute_service
await self._hass.async_add_executor_job(handler.job.target, service_call)
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/spotcast/__init__.py", line 379, in start_casting
spotify_device_id = spotify_cast_device.getSpotifyDeviceId(get_spotify_devices(hass))
File "/config/custom_components/spotcast/__init__.py", line 574, in getSpotifyDeviceId
raise HomeAssistantError("Failed to get device id from Spotify")
homeassistant.exceptions.HomeAssistantError: Failed to get device id from Spotify

What I can see with my non-dev eye, is that the requested Cast device is actually found (media_player.hmt) by get_cast_devices, but that it isn't listed as known spotify device (in get_spotify_devices and thus throws an error. To be sure it wasn't a token error or something, I've already updated the sp_dc and sp_key values for both accounts (default and t account), without any difference.


When using the default account, it all works fine: --edit: later proved wrong, see comments below

# scripts.yaml in HomeAssistant

start_music_t:
  alias: Slaaptijd
  mode: restart
  sequence:
    - service: spotcast.start
      data:
        entity_id: media_player.hmt
        uri: "spotify:track:5OoSxUZSbP1p7kb1d0SozG"
2021-04-19 09:49:07 DEBUG (SyncWorker_5) [custom_components.spotcast] setting up with account default
2021-04-19 09:49:07 DEBUG (SyncWorker_5) [custom_components.spotcast] get_cast_devices: media_player.soundbar: Soundbar cast info: ChromecastInfo(services={ServiceInfo(type='mdns', data='B8805-81704a75fd037a7c38090eb3c5dffea5._googlecast._tcp.local.')}, uuid='81704a75-fd03-7a7c-3809-0eb3c5dffea5', _manufacturer=None, model_name='B8805', friendly_name='Soundbar', is_audio_group=False, is_dynamic_group=None)
2021-04-19 09:49:07 DEBUG (SyncWorker_5) [custom_components.spotcast] get_cast_devices: media_player.woonkamer: Woonkamer cast info: ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Nest-Hub-4660f5b8aabe10031a93ebd362367256._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.xx.16', 8009))}, uuid='4660f5b8-aabe-1003-1a93-ebd362367256', _manufacturer='Google Inc.', model_name='Google Nest Hub', friendly_name='Woonkamer', is_audio_group=False, is_dynamic_group=None)
2021-04-19 09:49:07 DEBUG (SyncWorker_5) [custom_components.spotcast] get_cast_devices: media_player.hele_huis: Hele huis cast info: ChromecastInfo(services={ServiceInfo(type='host', data=('192.168.xx.16', 32059)), ServiceInfo(type='mdns', data='Google-Cast-Group-eec4b1d472ec428fad8f291a69a2d97d-1._googlecast._tcp.local.')}, uuid='eec4b1d4-72ec-428f-ad8f-291a69a2d97d', _manufacturer=None, model_name='Google Cast Group', friendly_name='Hele huis', is_audio_group=True, is_dynamic_group=False)
2021-04-19 09:49:07 DEBUG (SyncWorker_5) [custom_components.spotcast] get_cast_devices: media_player.studeerkamer: Studeerkamer cast info: ChromecastInfo(services={ServiceInfo(type='host', data=('192.168.xx.12', 8009)), ServiceInfo(type='mdns', data='Google-Home-d4063db0253e246c9d66d8f7fda77a6a._googlecast._tcp.local.')}, uuid='d4063db0-253e-246c-9d66-d8f7fda77a6a', _manufacturer='Google Inc.', model_name='Google Home', friendly_name='Studeerkamer', is_audio_group=False, is_dynamic_group=None)
2021-04-19 09:49:07 DEBUG (SyncWorker_5) [custom_components.spotcast] get_cast_devices: media_player.zolder: Zolder cast info: ChromecastInfo(services={ServiceInfo(type='host', data=('192.168.xx.17', 8009)), ServiceInfo(type='mdns', data='Google-Home-Mini-71d8c580bbd0166b72f10071a427b6cb-1._googlecast._tcp.local.'), ServiceInfo(type='host', data=('[::ffff:c0a8:5811]', 8009))}, uuid='71d8c580-bbd0-166b-72f1-0071a427b6cb', _manufacturer='Google Inc.', model_name='Google Home Mini', friendly_name='Zolder', is_audio_group=False, is_dynamic_group=None)
2021-04-19 09:49:07 DEBUG (SyncWorker_5) [custom_components.spotcast] get_cast_devices: media_player.boven: Boven cast info: ChromecastInfo(services={ServiceInfo(type='host', data=('[::ffff:c0a8:5811]', 32213)), ServiceInfo(type='host', data=('192.168.xx.17', 32213)), ServiceInfo(type='mdns', data='Google-Cast-Group-e18cddf284be43da9917ddb7d4ceb42c-2._googlecast._tcp.local.')}, uuid='e18cddf2-84be-43da-9917-ddb7d4ceb42c', _manufacturer=None, model_name='Google Cast Group', friendly_name='Boven', is_audio_group=True, is_dynamic_group=False)
2021-04-19 09:49:07 DEBUG (SyncWorker_5) [custom_components.spotcast] get_cast_devices: media_player.hmt: HMT cast info: ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Home-Mini-0256c1dd13b44c80849b281970d02d11._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.xx.13', 8009))}, uuid='0256c1dd-13b4-4c80-849b-281970d02d11', _manufacturer='Google Inc.', model_name='Google Home Mini', friendly_name='HMT', is_audio_group=False, is_dynamic_group=None)
2021-04-19 09:49:07 DEBUG (SyncWorker_5) [custom_components.spotcast] Chromecast devices: [ChromecastInfo(services={ServiceInfo(type='mdns', data='B8805-81704a75fd037a7c38090eb3c5dffea5._googlecast._tcp.local.')}, uuid='81704a75-fd03-7a7c-3809-0eb3c5dffea5', _manufacturer=None, model_name='B8805', friendly_name='Soundbar', is_audio_group=False, is_dynamic_group=None), ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Nest-Hub-4660f5b8aabe10031a93ebd362367256._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.xx.16', 8009))}, uuid='4660f5b8-aabe-1003-1a93-ebd362367256', _manufacturer='Google Inc.', model_name='Google Nest Hub', friendly_name='Woonkamer', is_audio_group=False, is_dynamic_group=None), ChromecastInfo(services={ServiceInfo(type='host', data=('192.168.xx.16', 32059)), ServiceInfo(type='mdns', data='Google-Cast-Group-eec4b1d472ec428fad8f291a69a2d97d-1._googlecast._tcp.local.')}, uuid='eec4b1d4-72ec-428f-ad8f-291a69a2d97d', _manufacturer=None, model_name='Google Cast Group', friendly_name='Hele huis', is_audio_group=True, is_dynamic_group=False), ChromecastInfo(services={ServiceInfo(type='host', data=('192.168.xx.12', 8009)), ServiceInfo(type='mdns', data='Google-Home-d4063db0253e246c9d66d8f7fda77a6a._googlecast._tcp.local.')}, uuid='d4063db0-253e-246c-9d66-d8f7fda77a6a', _manufacturer='Google Inc.', model_name='Google Home', friendly_name='Studeerkamer', is_audio_group=False, is_dynamic_group=None), ChromecastInfo(services={ServiceInfo(type='host', data=('192.168.xx.17', 8009)), ServiceInfo(type='mdns', data='Google-Home-Mini-71d8c580bbd0166b72f10071a427b6cb-1._googlecast._tcp.local.'), ServiceInfo(type='host', data=('[::ffff:c0a8:5811]', 8009))}, uuid='71d8c580-bbd0-166b-72f1-0071a427b6cb', _manufacturer='Google Inc.', model_name='Google Home Mini', friendly_name='Zolder', is_audio_group=False, is_dynamic_group=None), ChromecastInfo(services={ServiceInfo(type='host', data=('[::ffff:c0a8:5811]', 32213)), ServiceInfo(type='host', data=('192.168.xx.17', 32213)), ServiceInfo(type='mdns', data='Google-Cast-Group-e18cddf284be43da9917ddb7d4ceb42c-2._googlecast._tcp.local.')}, uuid='e18cddf2-84be-43da-9917-ddb7d4ceb42c', _manufacturer=None, model_name='Google Cast Group', friendly_name='Boven', is_audio_group=True, is_dynamic_group=False), ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Home-Mini-0256c1dd13b44c80849b281970d02d11._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.xx.13', 8009))}, uuid='0256c1dd-13b4-4c80-849b-281970d02d11', _manufacturer='Google Inc.', model_name='Google Home Mini', friendly_name='HMT', is_audio_group=False, is_dynamic_group=None)]
2021-04-19 09:49:07 DEBUG (SyncWorker_5) [custom_components.spotcast] cast info: ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Home-Mini-0256c1dd13b44c80849b281970d02d11._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.xx.13', 8009))}, uuid='0256c1dd-13b4-4c80-849b-281970d02d11', _manufacturer='Google Inc.', model_name='Google Home Mini', friendly_name='HMT', is_audio_group=False, is_dynamic_group=None)
2021-04-19 09:49:07 DEBUG (SyncWorker_5) [custom_components.spotcast] Found cast device: Chromecast(None, port=8009, device=DeviceStatus(friendly_name='HMT', model_name='Google Home Mini', manufacturer='Google Inc.', uuid='0256c1dd-13b4-4c80-849b-281970d02d11', cast_type='audio'))
2021-04-19 09:49:13 DEBUG (SyncWorker_5) [custom_components.spotcast] get_spotify_devices: media_player.spotify_t: Spotify T HH: []
2021-04-19 09:49:13 DEBUG (SyncWorker_5) [custom_components.spotcast] get_spotify_devices: media_player.spotify_m: Spotify M HH: []
2021-04-19 09:49:13 DEBUG (SyncWorker_5) [custom_components.spotcast] get_spotify_devices: media_player.spotify_hmmbob: Spotify Hmmbob HH: []
2021-04-19 09:49:13 DEBUG (SyncWorker_5) [custom_components.spotcast] devices_available: {'devices': [{'id': 'bf7485e4bdc069dfd996748826af2f02', 'is_active': False, 'is_private_session': False, 'is_restricted': False, 'name': 'HMT', 'type': 'CastAudio', 'volume_percent': 49}]} bf7485e4bdc069dfd996748826af2f02
2021-04-19 09:49:13 DEBUG (SyncWorker_5) [custom_components.spotcast] Playing URI: spotify:track:5OoSxUZSbP1p7kb1d0SozG on device-id: bf7485e4bdc069dfd996748826af2f02
2021-04-19 09:49:13 DEBUG (SyncWorker_5) [custom_components.spotcast] Playing track using uris= for uri: spotify:track:5OoSxUZSbP1p7kb1d0SozG
2021-04-19 09:49:13 DEBUG (SyncWorker_5) [custom_components.spotcast] Turning repeat on

(interestingly enough, here get_spotify_devices also seems to return [] )
(Spotify M is another spotify account loaded in the core spotify integration, but not being used with Spotcast)

@hmmbob hmmbob changed the title Failed to get device id from Spotify (3.5.4) Failed to get device id from Spotify for 2nd account (3.5.4) Apr 19, 2021
@peterjuras
Copy link
Contributor

I'm getting the same issue (no known devices), however I get it for all accounts (default and two others that are configured).

Spotcast sadly doesn't work for me at all right now :/

@hmmbob
Copy link
Contributor Author

hmmbob commented Apr 22, 2021

Did you setup spotify in HA? It is required.

@peterjuras
Copy link
Contributor

Yes for two accounts. It was working fine for a few months now, but now I receive an empty device array similar to you.

@hmmbob
Copy link
Contributor Author

hmmbob commented Apr 22, 2021

Yeah, I see the same. Until yesterday it worked with the main account, now that is broken too.

@hmmbob hmmbob changed the title Failed to get device id from Spotify for 2nd account (3.5.4) Failed to get device id from Spotify (3.5.4) Apr 22, 2021
@hmmbob
Copy link
Contributor Author

hmmbob commented Apr 23, 2021

@fondberg Did some fiddling around. With the 'dirty fix' that has been used before, it works again. If I trace the errors, it appears that there is a valid Chromecast found, but this device isn't visible/available through spotify hence why getSpotifyDeviceId returns an error.

Would it be possible to bypass the getSpotifyDeviceId check if there has been a valid Chromecast found in the steps before?

2021-04-23 10:16:17 DEBUG (SyncWorker_15) [custom_components.spotcast] setting up with account default
2021-04-23 10:16:17 DEBUG (SyncWorker_15) [custom_components.spotcast] get_cast_devices: media_player.studeerkamer: Studeerkamer cast info: ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Home-d4063db0253e246c9d66d8f7fda77a6a._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.xx.12', 8009))}, uuid='d4063db0-253e-246c-9d66-d8f7fda77a6a', _manufacturer='Google Inc.', model_name='Google Home', friendly_name='Studeerkamer', is_audio_group=False, is_dynamic_group=None)
2021-04-23 10:16:17 DEBUG (SyncWorker_15) [custom_components.spotcast] get_cast_devices: media_player.hele_huis: Hele huis cast info: ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Cast-Group-eec4b1d472ec428fad8f291a69a2d97d-1._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.xx.16', 32059))}, uuid='eec4b1d4-72ec-428f-ad8f-291a69a2d97d', _manufacturer=None, model_name='Google Cast Group', friendly_name='Hele huis', is_audio_group=True, is_dynamic_group=False)
2021-04-23 10:16:17 DEBUG (SyncWorker_15) [custom_components.spotcast] get_cast_devices: media_player.slaapkamer: Slaapkamer cast info: ChromecastInfo(services={ServiceInfo(type='host', data=('192.168.xx.13', 8009)), ServiceInfo(type='mdns', data='Google-Home-Mini-0256c1dd13b44c80849b281970d02d11._googlecast._tcp.local.')}, uuid='0256c1dd-13b4-4c80-849b-281970d02d11', _manufacturer='Google Inc.', model_name='Google Home Mini', friendly_name='Slaapkamer', is_audio_group=False, is_dynamic_group=None)
2021-04-23 10:16:17 DEBUG (SyncWorker_15) [custom_components.spotcast] get_cast_devices: media_player.woonkamer: Woonkamer cast info: ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Nest-Hub-4660f5b8aabe10031a93ebd362367256._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.xx.16', 8009))}, uuid='4660f5b8-aabe-1003-1a93-ebd362367256', _manufacturer='Google Inc.', model_name='Google Nest Hub', friendly_name='Woonkamer', is_audio_group=False, is_dynamic_group=None)
2021-04-23 10:16:17 DEBUG (SyncWorker_15) [custom_components.spotcast] get_cast_devices: media_player.boven: Boven cast info: ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Cast-Group-e18cddf284be43da9917ddb7d4ceb42c-2._googlecast._tcp.local.'), ServiceInfo(type='host', data=('[::ffff:c0a8:5811]', 32213)), ServiceInfo(type='host', data=('192.168.xx.17', 32213))}, uuid='e18cddf2-84be-43da-9917-ddb7d4ceb42c', _manufacturer=None, model_name='Google Cast Group', friendly_name='Boven', is_audio_group=True, is_dynamic_group=False)
2021-04-23 10:16:17 DEBUG (SyncWorker_15) [custom_components.spotcast] get_cast_devices: media_player.zolder: Zolder cast info: ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Home-Mini-71d8c580bbd0166b72f10071a427b6cb-1._googlecast._tcp.local.'), ServiceInfo(type='host', data=('[::ffff:c0a8:5811]', 8009)), ServiceInfo(type='host', data=('192.168.xx.17', 8009))}, uuid='71d8c580-bbd0-166b-72f1-0071a427b6cb', _manufacturer='Google Inc.', model_name='Google Home Mini', friendly_name='Zolder', is_audio_group=False, is_dynamic_group=None)
2021-04-23 10:16:17 DEBUG (SyncWorker_15) [custom_components.spotcast] Chromecast devices: [ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Home-d4063db0253e246c9d66d8f7fda77a6a._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.xx.12', 8009))}, uuid='d4063db0-253e-246c-9d66-d8f7fda77a6a', _manufacturer='Google Inc.', model_name='Google Home', friendly_name='Studeerkamer', is_audio_group=False, is_dynamic_group=None), ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Cast-Group-eec4b1d472ec428fad8f291a69a2d97d-1._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.xx.16', 32059))}, uuid='eec4b1d4-72ec-428f-ad8f-291a69a2d97d', _manufacturer=None, model_name='Google Cast Group', friendly_name='Hele huis', is_audio_group=True, is_dynamic_group=False), ChromecastInfo(services={ServiceInfo(type='host', data=('192.168.xx.13', 8009)), ServiceInfo(type='mdns', data='Google-Home-Mini-0256c1dd13b44c80849b281970d02d11._googlecast._tcp.local.')}, uuid='0256c1dd-13b4-4c80-849b-281970d02d11', _manufacturer='Google Inc.', model_name='Google Home Mini', friendly_name='Slaapkamer', is_audio_group=False, is_dynamic_group=None), ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Nest-Hub-4660f5b8aabe10031a93ebd362367256._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.xx.16', 8009))}, uuid='4660f5b8-aabe-1003-1a93-ebd362367256', _manufacturer='Google Inc.', model_name='Google Nest Hub', friendly_name='Woonkamer', is_audio_group=False, is_dynamic_group=None), ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Cast-Group-e18cddf284be43da9917ddb7d4ceb42c-2._googlecast._tcp.local.'), ServiceInfo(type='host', data=('[::ffff:c0a8:5811]', 32213)), ServiceInfo(type='host', data=('192.168.xx.17', 32213))}, uuid='e18cddf2-84be-43da-9917-ddb7d4ceb42c', _manufacturer=None, model_name='Google Cast Group', friendly_name='Boven', is_audio_group=True, is_dynamic_group=False), ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Home-Mini-71d8c580bbd0166b72f10071a427b6cb-1._googlecast._tcp.local.'), ServiceInfo(type='host', data=('[::ffff:c0a8:5811]', 8009)), ServiceInfo(type='host', data=('192.168.xx.17', 8009))}, uuid='71d8c580-bbd0-166b-72f1-0071a427b6cb', _manufacturer='Google Inc.', model_name='Google Home Mini', friendly_name='Zolder', is_audio_group=False, is_dynamic_group=None)]
2021-04-23 10:16:17 DEBUG (SyncWorker_15) [custom_components.spotcast] cast info: ChromecastInfo(services={ServiceInfo(type='host', data=('192.168.xx.13', 8009)), ServiceInfo(type='mdns', data='Google-Home-Mini-0256c1dd13b44c80849b281970d02d11._googlecast._tcp.local.')}, uuid='0256c1dd-13b4-4c80-849b-281970d02d11', _manufacturer='Google Inc.', model_name='Google Home Mini', friendly_name='Slaapkamer', is_audio_group=False, is_dynamic_group=None)
2021-04-23 10:16:17 DEBUG (SyncWorker_15) [custom_components.spotcast] Found cast device: Chromecast(None, port=8009, device=DeviceStatus(friendly_name='Slaapkamer', model_name='Google Home Mini', manufacturer='Google Inc.', uuid='0256c1dd-13b4-4c80-849b-281970d02d11', cast_type='audio'))
2021-04-23 10:16:22 DEBUG (SyncWorker_15) [custom_components.spotcast] get_spotify_devices: media_player.spotify_t: Spotify T HH: []
2021-04-23 10:16:22 DEBUG (SyncWorker_15) [custom_components.spotcast] get_spotify_devices: media_player.spotify_m: Spotify M HH: []
2021-04-23 10:16:22 DEBUG (SyncWorker_15) [custom_components.spotcast] get_spotify_devices: media_player.spotify_hmmbob: Spotify Hmmbob HH: []
--> this now works due to the dirty fix
2021-04-23 10:16:22 DEBUG (SyncWorker_15) [custom_components.spotcast] devices_available: {'devices': [{'id': 'cab8a21e10b52899d538f8cbd312d56a', 'is_active': False, 'is_private_session': False, 'is_restricted': False, 'name': 'Slaapkamer', 'type': 'CastAudio', 'volume_percent': 49}]} cab8a21e10b52899d538f8cbd312d56a
<---
2021-04-23 10:16:22 DEBUG (SyncWorker_15) [custom_components.spotcast] Playing URI: spotify:track:5OoSxUZSbP1p7kb1d0SozG on device-id: cab8a21e10b52899d538f8cbd312d56a
2021-04-23 10:16:22 DEBUG (SyncWorker_15) [custom_components.spotcast] Playing track using uris= for uri: spotify:track:5OoSxUZSbP1p7kb1d0SozG
2021-04-23 10:16:22 DEBUG (SyncWorker_15) [custom_components.spotcast] Turning repeat on

Dirty fix also fixes the secondary account issue (again, with a valid Chromecast):

2021-04-23 10:27:53 DEBUG (SyncWorker_8) [custom_components.spotcast] setting up with account t
2021-04-23 10:27:53 DEBUG (SyncWorker_8) [custom_components.spotcast] get_cast_devices: media_player.studeerkamer: Studeerkamer cast info: ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Home-d4063db0253e246c9d66d8f7fda77a6a._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.xx.12', 8009))}, uuid='d4063db0-253e-246c-9d66-d8f7fda77a6a', _manufacturer='Google Inc.', model_name='Google Home', friendly_name='Studeerkamer', is_audio_group=False, is_dynamic_group=None)
2021-04-23 10:27:53 DEBUG (SyncWorker_8) [custom_components.spotcast] get_cast_devices: media_player.hele_huis: Hele huis cast info: ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Cast-Group-eec4b1d472ec428fad8f291a69a2d97d-1._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.xx.16', 32059))}, uuid='eec4b1d4-72ec-428f-ad8f-291a69a2d97d', _manufacturer=None, model_name='Google Cast Group', friendly_name='Hele huis', is_audio_group=True, is_dynamic_group=False)
2021-04-23 10:27:53 DEBUG (SyncWorker_8) [custom_components.spotcast] get_cast_devices: media_player.slaapkamer: Slaapkamer cast info: ChromecastInfo(services={ServiceInfo(type='host', data=('192.168.xx.13', 8009)), ServiceInfo(type='mdns', data='Google-Home-Mini-0256c1dd13b44c80849b281970d02d11._googlecast._tcp.local.')}, uuid='0256c1dd-13b4-4c80-849b-281970d02d11', _manufacturer='Google Inc.', model_name='Google Home Mini', friendly_name='Slaapkamer', is_audio_group=False, is_dynamic_group=None)
2021-04-23 10:27:53 DEBUG (SyncWorker_8) [custom_components.spotcast] get_cast_devices: media_player.woonkamer: Woonkamer cast info: ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Nest-Hub-4660f5b8aabe10031a93ebd362367256._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.xx.16', 8009))}, uuid='4660f5b8-aabe-1003-1a93-ebd362367256', _manufacturer='Google Inc.', model_name='Google Nest Hub', friendly_name='Woonkamer', is_audio_group=False, is_dynamic_group=None)
2021-04-23 10:27:53 DEBUG (SyncWorker_8) [custom_components.spotcast] get_cast_devices: media_player.boven: Boven cast info: ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Cast-Group-e18cddf284be43da9917ddb7d4ceb42c-2._googlecast._tcp.local.'), ServiceInfo(type='host', data=('[::ffff:c0a8:5811]', 32213)), ServiceInfo(type='host', data=('192.168.xx.17', 32213))}, uuid='e18cddf2-84be-43da-9917-ddb7d4ceb42c', _manufacturer=None, model_name='Google Cast Group', friendly_name='Boven', is_audio_group=True, is_dynamic_group=False)
2021-04-23 10:27:53 DEBUG (SyncWorker_8) [custom_components.spotcast] get_cast_devices: media_player.zolder: Zolder cast info: ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Home-Mini-71d8c580bbd0166b72f10071a427b6cb-1._googlecast._tcp.local.'), ServiceInfo(type='host', data=('[::ffff:c0a8:5811]', 8009)), ServiceInfo(type='host', data=('192.168.xx.17', 8009))}, uuid='71d8c580-bbd0-166b-72f1-0071a427b6cb', _manufacturer='Google Inc.', model_name='Google Home Mini', friendly_name='Zolder', is_audio_group=False, is_dynamic_group=None)
2021-04-23 10:27:53 DEBUG (SyncWorker_8) [custom_components.spotcast] Chromecast devices: [ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Home-d4063db0253e246c9d66d8f7fda77a6a._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.xx.12', 8009))}, uuid='d4063db0-253e-246c-9d66-d8f7fda77a6a', _manufacturer='Google Inc.', model_name='Google Home', friendly_name='Studeerkamer', is_audio_group=False, is_dynamic_group=None), ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Cast-Group-eec4b1d472ec428fad8f291a69a2d97d-1._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.xx.16', 32059))}, uuid='eec4b1d4-72ec-428f-ad8f-291a69a2d97d', _manufacturer=None, model_name='Google Cast Group', friendly_name='Hele huis', is_audio_group=True, is_dynamic_group=False), ChromecastInfo(services={ServiceInfo(type='host', data=('192.168.xx.13', 8009)), ServiceInfo(type='mdns', data='Google-Home-Mini-0256c1dd13b44c80849b281970d02d11._googlecast._tcp.local.')}, uuid='0256c1dd-13b4-4c80-849b-281970d02d11', _manufacturer='Google Inc.', model_name='Google Home Mini', friendly_name='Slaapkamer', is_audio_group=False, is_dynamic_group=None), ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Nest-Hub-4660f5b8aabe10031a93ebd362367256._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.xx.16', 8009))}, uuid='4660f5b8-aabe-1003-1a93-ebd362367256', _manufacturer='Google Inc.', model_name='Google Nest Hub', friendly_name='Woonkamer', is_audio_group=False, is_dynamic_group=None), ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Cast-Group-e18cddf284be43da9917ddb7d4ceb42c-2._googlecast._tcp.local.'), ServiceInfo(type='host', data=('[::ffff:c0a8:5811]', 32213)), ServiceInfo(type='host', data=('192.168.xx.17', 32213))}, uuid='e18cddf2-84be-43da-9917-ddb7d4ceb42c', _manufacturer=None, model_name='Google Cast Group', friendly_name='Boven', is_audio_group=True, is_dynamic_group=False), ChromecastInfo(services={ServiceInfo(type='mdns', data='Google-Home-Mini-71d8c580bbd0166b72f10071a427b6cb-1._googlecast._tcp.local.'), ServiceInfo(type='host', data=('[::ffff:c0a8:5811]', 8009)), ServiceInfo(type='host', data=('192.168.xx.17', 8009))}, uuid='71d8c580-bbd0-166b-72f1-0071a427b6cb', _manufacturer='Google Inc.', model_name='Google Home Mini', friendly_name='Zolder', is_audio_group=False, is_dynamic_group=None)]
2021-04-23 10:27:53 DEBUG (SyncWorker_8) [custom_components.spotcast] cast info: ChromecastInfo(services={ServiceInfo(type='host', data=('192.168.xx.13', 8009)), ServiceInfo(type='mdns', data='Google-Home-Mini-0256c1dd13b44c80849b281970d02d11._googlecast._tcp.local.')}, uuid='0256c1dd-13b4-4c80-849b-281970d02d11', _manufacturer='Google Inc.', model_name='Google Home Mini', friendly_name='Slaapkamer', is_audio_group=False, is_dynamic_group=None)
2021-04-23 10:27:53 DEBUG (SyncWorker_8) [custom_components.spotcast] Found cast device: Chromecast(None, port=8009, device=DeviceStatus(friendly_name='Slaapkamer', model_name='Google Home Mini', manufacturer='Google Inc.', uuid='0256c1dd-13b4-4c80-849b-281970d02d11', cast_type='audio'))
2021-04-23 10:27:57 DEBUG (SyncWorker_8) [custom_components.spotcast] get_spotify_devices: media_player.spotify_t: Spotify T HH: []
2021-04-23 10:27:57 DEBUG (SyncWorker_8) [custom_components.spotcast] get_spotify_devices: media_player.spotify_m: Spotify M HH: []
2021-04-23 10:27:57 DEBUG (SyncWorker_8) [custom_components.spotcast] get_spotify_devices: media_player.spotify_hmmbob: Spotify Hmmbob HH: []
2021-04-23 10:27:58 DEBUG (SyncWorker_8) [custom_components.spotcast] devices_available: {'devices': []} cab8a21e10b52899d538f8cbd312d56a
2021-04-23 10:27:58 DEBUG (SyncWorker_8) [custom_components.spotcast] Playing URI: spotify:track:5OoSxUZSbP1p7kb1d0SozG on device-id: cab8a21e10b52899d538f8cbd312d56a
2021-04-23 10:27:58 DEBUG (SyncWorker_8) [custom_components.spotcast] Playing track using uris= for uri: spotify:track:5OoSxUZSbP1p7kb1d0SozG
2021-04-23 10:27:58 DEBUG (SyncWorker_8) [custom_components.spotcast] Turning repeat on

@fondberg
Copy link
Owner

I'll have a look

@peterjuras
Copy link
Contributor

Thanks for looking into this!

I think that this might have something to do with spotcast using the wrong Spotify account by default. When I checked the logs, I saw a device listing which only could have been from a different account, although the service call did not specify an account but should have used the default one. The spotify-card also sometimes shows the wrong playback state from a different account (i.e. a playlist is highlighted in blue although a different account listens to a different playlist that happens to share the same name)

Sadly the log is no longer in home assistant, but I'll keep my eye on it to see whether it happens again.

@fondberg
Copy link
Owner

With fixing the playback issues a couple of weeks back we now use the device list from spotify media player core which has its account and spotcast MIGHT have another account.

Can you confirm that this is the case for you (that you are using different accounts between them)?

@fondberg
Copy link
Owner

As I can't solve the multiple accounts issue there is only one alternative and that is to either leave it semi-broken or remove multi-account support.
The other alternative (which I don't have time for) is if someone implements another authentication with OATH and scopes similar to code spotify. Note that I won't do this

@hmmbob
Copy link
Contributor Author

hmmbob commented Apr 26, 2021

With fixing the playback issues a couple of weeks back we now use the device list from spotify media player core which has its account and spotcast MIGHT have another account.

Can you confirm that this is the case for you (that you are using different accounts between them)?

This could be the case. Core Spotify has 3 accounts setup, with Spotcast I am using 2. So, it could be that Spotcast account "T" (in my case) is talking to the "Hmmbob" core Spotify account. This shouldn't be too much of a problem though, as T us my son and thus uses the same devices as I do ;-)

@fondberg
Copy link
Owner

OK, then we need to map this to the correct core player. Do you have a proposal on how to do this?

@fondberg
Copy link
Owner

The code that needs to get the "correct" player is
https://github.com/fondberg/spotcast/blob/master/custom_components/spotcast/__init__.py#L120-L137

@fondberg
Copy link
Owner

@hmmbob maybe we should readd the dirty fix

        if not devices_available["devices"] and self.spotifyController.device:
            return self.spotifyController.device

Can you do a PR for it?

@hmmbob
Copy link
Contributor Author

hmmbob commented Apr 26, 2021

Sure. It is at least a little band aid on the error.

@fondberg
Copy link
Owner

fondberg commented May 3, 2021

@gabosom
Copy link

gabosom commented May 3, 2021

Hi @fondberg , I tried with the latest and still have the issue with v 3.5.7. Thoughts?

Play Spotify Playlist on Receiver: Error executing script. Error for call_service at pos 2: Could not find device with name Pioneer Receiver

This is my spotify card and if I choose "pioneer receiver" from the spotify card, it'll play on the device just fine.
image

@fondberg
Copy link
Owner

@gabosom I think there might be something else that is a problem for you. Feel free to post a new bugreport if you have the problem. closing this seeing as it solved it for the actual reported issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants