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

Enable Proper Echo Device PLayback in Spotcast #403

Open
6 of 8 tasks
raresdragan opened this issue Sep 2, 2023 · 21 comments
Open
6 of 8 tasks

Enable Proper Echo Device PLayback in Spotcast #403

raresdragan opened this issue Sep 2, 2023 · 21 comments
Assignees
Labels
beta Related to the beta program enhancement New feature or request

Comments

@raresdragan
Copy link

raresdragan commented Sep 2, 2023

Bug Ticket

Description

I think this issue was reported before (last time in 2022?) just letting you know it's still a problem in September 2023 wit the latest Spotcast version / latest Home Assistant / everything up to date, premium Spotify account, etc.

System is a Raspberry PI 3 which works great otherwise.

When I try to play Spotify music using Spotcast to my Amazon Echo using the device name the first time it crashes, the second time it works fine.

I did a quick workaround to play first a silent track and second time the right track .. But I'm wondering .. can't this be fixed in the Spotcast directly? It seems like an extra call is needed to wake up the device? Can I help in any way fixing this?

Service Call

service: spotcast.start
data:
force_playback: true
uri: spotify:track:6mcxQ1Y3uQRU0IHsvdNLH1
start_volume: 25
device_name: Echo

Debug info

I provided (hopefully) some relevant debug info below:

(I censored my amazon device id with xxx )

  • first time it crashes with unknown error:
2023-09-03 01:31:23.255 DEBUG (SyncWorker_30) [custom_components.spotcast.spotcast_controller] setting up with account default
2023-09-03 01:31:23.256 DEBUG (SyncWorker_30) [custom_components.spotcast.spotcast_controller] expires: 1693696091 time: 1693693883.2564383
2023-09-03 01:31:23.257 DEBUG (SyncWorker_30) [custom_components.spotcast.spotcast_controller] setting up with account default
2023-09-03 01:31:23.690 DEBUG (SyncWorker_30) ...

2023-09-03 01:31:24.085 DEBUG (SyncWorker_30) [custom_components.spotcast.spotcast_controller] Playing URI: spotify:track:6mcxQ1Y3uQRU0IHsvdNLH1 on device-id: xxx-xxx-xxx-xxx-xxx
2023-09-03 01:31:24.086 DEBUG (SyncWorker_30) [custom_components.spotcast.spotcast_controller] Playing track using uris= for uri: spotify:track:6mcxQ1Y3uQRU0IHsvdNLH1
2023-09-03 01:31:24.850 ERROR (SyncWorker_30) [spotipy.client] HTTP Error for PUT to https://api.spotify.com/v1/me/player/play?device_id=xxx-xxx-xxx-xxx-xxx with Params: {} returned 404 due to Not found.
2023-09-03 01:31:24.865 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Unexpected error for call_service at pos 1: http status: 404, code:-1 - https://api.spotify.com/v1/me/player/play?device_id=xxx-xxx-xxx-xxx-xxx:
Not found., reason: None
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/spotipy/client.py", line 271, in _internal_call
response.raise_for_status()
File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.spotify.com/v1/me/player/play?device_id=xxx-xxx-xxx-xxx-xxx
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 703, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 665, in _async_run_long_action
return long_task.result()
^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 1974, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2018, in _execute_service
return await self._hass.async_add_executor_job(target, service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/spotcast/__init__.py", line 256, in start_casting
spotcast_controller.play(
File "/config/custom_components/spotcast/spotcast_controller.py", line 294, in play
client.start_playback(device_id=spotify_device_id, uris=[uri])
File "/usr/local/lib/python3.11/site-packages/spotipy/client.py", line 1821, in start_playback
return self._put(
^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/spotipy/client.py", line 338, in _put
return self._internal_call("PUT", url, payload, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/spotipy/client.py", line 293, in _internal_call
raise SpotifyException(
spotipy.exceptions.SpotifyException: http status: 404, code:-1 - https://api.spotify.com/v1/me/player/play?device_id=xxx-xxx-xxx-xxx-xxx:
Not found., reason: None
2023-09-03 01:31:24.919 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [1491981352] Error handling message: Unknown error (unknown_error) DRG from 192.168.xx.yy (Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36)
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/spotipy/client.py", line 271, in _internal_call
response.raise_for_status()
File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.spotify.com/v1/me/player/play?device_id=xxx-xxx-xxx-xxx-xxx
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response
await func(hass, connection, msg)
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 716, in handle_execute_script
response = await script_obj.async_run(msg.get("variables"), context=context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1569, in async_run
return await asyncio.shield(run.async_run())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 420, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 470, in _async_step
self._handle_exception(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 493, in _handle_exception
raise exception
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 703, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 665, in _async_run_long_action
return long_task.result()
^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 1974, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2018, in _execute_service
return await self._hass.async_add_executor_job(target, service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/spotcast/__init__.py", line 256, in start_casting
spotcast_controller.play(
File "/config/custom_components/spotcast/spotcast_controller.py", line 294, in play
client.start_playback(device_id=spotify_device_id, uris=[uri])
File "/usr/local/lib/python3.11/site-packages/spotipy/client.py", line 1821, in start_playback
return self._put(
^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/spotipy/client.py", line 338, in _put
return self._internal_call("PUT", url, payload, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/spotipy/client.py", line 293, in _internal_call
raise SpotifyException(
spotipy.exceptions.SpotifyException: http status: 404, code:-1 - https://api.spotify.com/v1/me/player/play?device_id=xxx-xxx-xxx-xxx-xxx_amzn_1:
Not found., reason: None

SECOND TIME CALLING THE SAME SCRIPT IT WORKS:

2023-09-03 01:37:27.298 DEBUG (SyncWorker_21) [custom_components.spotcast.spotcast_controller] Playing URI: spotify:track:6mcxQ1Y3uQRU0IHsvdNLH1 on device-id: xxx-xxx-xxx-xxx-xxx
2023-09-03 01:37:27.298 DEBUG (SyncWorker_21) [custom_components.spotcast.spotcast_controller] Playing track using uris= for uri: spotify:track:6mcxQ1Y3uQRU0IHsvdNLH1
2023-09-03 01:37:27.886 DEBUG (SyncWorker_21) [custom_components.spotcast] Setting volume to 25
2023-09-03 01:37:30.018 DEBUG (SyncWorker_21) [custom_components.spotcast] Turning repeat on

Troubleshooting

Make sure to validate all the elements before submitting the ticket (Exception to the steps marked as optional)

  • Using latest version of spotcast
  • Using latest stable version of Home Assistant
  • I have setup the Spotify integration in Home Assistant
  • I have renewed my sp_dc and sp_key values and restarted Home Assistant (see README)
  • (optional) I have Spotify Premium
  • (optional) I am using multiple accounts
  • (optional) I'm attaching relevant logs with level debug for component spotcast (see README)
  • (optional) I'm using entity_id in the service call and have tried device_name but the issue remains
@raresdragan raresdragan added the bug Something isn't working label Sep 2, 2023
@raresdragan
Copy link
Author

raresdragan commented Sep 13, 2023

Update:

Still crashing in latest Spotcast version [3.7.1]

Even if I used directly the spotify_device_id in the spotcast call ..

Unfortunately the crash stops the script from running even if I use continue_on_error .. This means I cannot catch the error and do a second call..

The second time I run exactly the same script it works.. music starts playing..
Is there any chance to fix this?
Can I help in any way?

The complexity of the problem can be explained in a pseudo-dramatic phrase: At this moment, because of this bug it's impossible to automate playing music using Spotify in Home Assistant on an idle device. 🥲

Below some info.
I replaced my amazon device id with xxx

This error originated from a custom integration.
Logger: spotipy.client
Source: custom_components/spotcast/spotcast_controller.py:349
Integration: Spotcast (documentation, issues)
First occurred: 12 September 2023 at 11:11:00 (8 occurrences)
Last logged: 02:52:28

HTTP Error for PUT to https://api.spotify.com/v1/me/player/play?device_id=xxx_amzn_2 with Params: {} returned 404 due to Not found.

Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/spotipy/client.py", line 271, in _internal_call
response.raise_for_status()
File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.spotify.com/v1/me/player/play?device_id=xxx_amzn_2

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 703, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 665, in _async_run_long_action
return long_task.result()
^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 1974, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2018, in _execute_service
return await self._hass.async_add_executor_job(target, service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/spotcast/init.py", line 256, in start_casting
spotcast_controller.play(
File "/config/custom_components/spotcast/spotcast_controller.py", line 349, in play
client.start_playback(device_id=spotify_device_id, uris=[uri])
File "/usr/local/lib/python3.11/site-packages/spotipy/client.py", line 1821, in start_playback
return self._put(
^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/spotipy/client.py", line 338, in _put
return self._internal_call("PUT", url, payload, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/spotipy/client.py", line 293, in _internal_call
raise SpotifyException(
spotipy.exceptions.SpotifyException: http status: 404, code:-1 - https://api.spotify.com/v1/me/player/play?device_id=xxx_amzn_2:
Not found., reason: None

@fcusson
Copy link
Collaborator

fcusson commented Sep 13, 2023

Echoes are very finicky, is the device available from device list in spotify console when idle?

@raresdragan
Copy link
Author

Yes, the device is available in the devices list.

Here's a part of the response from
https://api.spotify.com/v1/me/player/devices

{
  "id": "xxx_amzn_2",
  "is_active": false,
  "is_private_session": false,
  "is_restricted": false,
  "name": "Echo",
  "supports_volume": true,
  "type": "Speaker",
  "volume_percent": 49
},

After making sure the deive is in the list I called:

service: spotcast.start
data:
device_name: Echo
uri: spotify:playlist:xxx

Same error:

Logger: homeassistant.helpers.script.websocket_api_script
Source: custom_components/spotcast/spotcast_controller.py:384
Integration: Spotcast (documentation, issues)
First occurred: 14 September 2023 at 15:30:58 (2 occurrences)
Last logged: 14:11:13

websocket_api script: Error executing script. Unexpected error for call_service at pos 1: http status: 404, code:-1 - https://api.spotify.com/v1/me/player/play?device_id=xxx_amzn_2: Not found., reason: None
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/spotipy/client.py", line 271, in _internal_call
response.raise_for_status()
File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.spotify.com/v1/me/player/play?device_id=xxx_amzn_2

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 704, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 666, in _async_run_long_action
return long_task.result()
^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 1969, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2013, in _execute_service
return await self._hass.async_add_executor_job(target, service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/spotcast/init.py", line 256, in start_casting
spotcast_controller.play(
File "/config/custom_components/spotcast/spotcast_controller.py", line 384, in play
client.start_playback(**kwargs)
File "/usr/local/lib/python3.11/site-packages/spotipy/client.py", line 1821, in start_playback
return self._put(
^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/spotipy/client.py", line 338, in _put
return self._internal_call("PUT", url, payload, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/spotipy/client.py", line 293, in _internal_call
raise SpotifyException(
spotipy.exceptions.SpotifyException: http status: 404, code:-1 - https://api.spotify.com/v1/me/player/play?device_id=xxx_amzn_2:
Not found., reason: None

@raresdragan
Copy link
Author

The ugliest part of this is that this error completely breaks any automation.
Even if I use continue_on_error to try a second time a spotcast start .. it doesn't work.

Home Assistant uses continue_on_error for HomeAssistantError
But Spotcast (and all integrations actually) may not raise an exception based on HomeAssistantError

https://github.com/home-assistant/core/blob/ba8a530d19dc3e93602275961de46d700611f4a1/homeassistant/helpers/script.py#L493

    # Only Home Assistant errors can be ignored.
    if not isinstance(exception, exceptions.HomeAssistantError):
        raise exception

@fcusson
Copy link
Collaborator

fcusson commented Sep 17, 2023

Have you tried directly with the device Id, because the device name is used to register a Chromecast device to a Spotify session, it should actually fail in the way you are using it.

@raresdragan
Copy link
Author

Yes. I tried using directly the spotify_device_id

Still crashing in latest Spotcast version [3.7.1]

Even if I used directly the spotify_device_id in the spotcast call ..

I tried all possible options:
spotify_device_id
entity_id
device_name

same result every time.
I tested this in every possible way last few weeks before posting this bug report.

I tried different Amazon Echo devices too.

@duczz
Copy link

duczz commented Sep 19, 2023

i have the same issue with my echo dot, i hope we found a solution :(
When i try it multiple times it works.

@duczz
Copy link

duczz commented Oct 4, 2023

@fcusson any news for this Problem?

@raresdragan
Copy link
Author

Still the same problem in March 2024.
I’m curious if anyone can use spotcast to play Spotify songs to a “sleeping” Amazon echo device without first waking it up by .. paradoxically.. playing a song on it 🥲

@AeroV95
Copy link

AeroV95 commented Mar 11, 2024

Still the same problem in March 2024. I’m curious if anyone can use spotcast to play Spotify songs to a “sleeping” Amazon echo device without first waking it up by .. paradoxically.. playing a song on it 🥲

I still get this, no idea how to fix it.

@miumer
Copy link

miumer commented Sep 27, 2024

Same issue for me with Denon receiver

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 28, in _handle_async_response
await func(hass, connection, msg)
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 816, in handle_execute_script
script_result = await script_obj.async_run(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1795, in async_run
return await asyncio.shield(create_eager_task(run.async_run()))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 463, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 527, in _async_step
self._handle_exception(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 557, in _handle_exception
raise exception
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 525, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 763, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 726, in _async_run_long_action
return await long_task
^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2761, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2811, in _execute_service
return await self._hass.async_add_executor_job(target, service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/spotcast/init.py", line 287, in start_casting
client.transfer_playback(
File "/usr/local/lib/python3.12/site-packages/spotipy/client.py", line 1780, in transfer_playback
return self._put("me/player", payload=data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/spotipy/client.py", line 338, in _put
return self._internal_call("PUT", url, payload, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/spotipy/client.py", line 293, in _internal_call
raise SpotifyException(
spotipy.exceptions.SpotifyException: http status: 404, code:-1 - https://api.spotify.com/v1/me/player:
Device not found, reason: None

@fcusson
Copy link
Collaborator

fcusson commented Sep 28, 2024

@raresdragan

It seems like an extra call is needed to wake up the device

In its current state (v3) the code can only register and wake up a Chromecast device. All other devices are expected to register by themselves.

The refactor I'm working on (v4) will be able to expand to other speaker technology, but this will be up to the community to build the connectors as I only have Chromecast devices currently.

Since this is a complete rewrite and I'm working on it alone in my free time this could be months before this is ready.

@miumer
Copy link

miumer commented Sep 29, 2024

Im using the endpoint https://api.spotify.com/v1/me/player/devices to get the device ID and putting the device ID into the "Spotify Device ID" field in spotcast. Still getting this weird error. When i connect from my phone to the device it plays fine. The Denon receiver is turned on....Not sure what im supposed to wake up...

@raresdragan
Copy link
Author

@miumer I did the same, same result. :(

@raresdragan
Copy link
Author

@fcusson @AeroV95 @miumer @duczz

I tried making Spotcast work with Amazon Echo devices (Spotify Connect devices) a few months in all possible ways and trying again after each Spotcast new update. No luck yet.

But here is what I noticed:

When I try playing on an idle Spotify Connect device (Amazon Echo in my case) the first time, Spotcast will crash with an error.

But if I retry the same script call after that error, the Spotcast play will work fine.

This means that, during the "crash", Spotcast actually managed to wake up the device.

Unfortunatelly the first crash will trigger an error and stop the script.
Even if I set continue_on_error: true the script will still stop working so I cannot automate a second call. I have to manually run the play script again.

Maybe we can work something out based on this finding?
I think it would be enough if the script would not fail anymore so I can run the same script again.

Thoughts?

@fcusson
Copy link
Collaborator

fcusson commented Sep 29, 2024

@raresdragan this would require a revamp of the error management. Currently, a lot of the processes in the integration do not cleanly raise a HomeAssistantError which is required to be able to continue on error.

Short term, this could be simply wrapping the service call in a try... excet and raise to a generic HomeAssistantError.

Long term, we would need a proper system to wake up an echo device and register the account to the spotify account requested. The current method you are using (spotify_id call) was meant for a device already registered to the spotify account. The fact it works on the second time is an happy side-effect of what we are doing. Not a controlled consequence.

To be able to integrate Echo Devices correctly, this would need to be integrated in V4 which I'm currently working on my fork. Any help is appreciated as I do not own echo devices

@duczz
Copy link

duczz commented Sep 29, 2024

i think spotifyplus can do this things and more, maybe fcusson can get some informations from him? or this changes can be implement in the nativ spotify integration

@fcusson
Copy link
Collaborator

fcusson commented Sep 29, 2024

@duczz as mentioned I do not have an echo device someone else with the device will have to do the research and testing but I am working on an easier way to add protocol for other smart speaker in v4.

@raresdragan
Copy link
Author

@duczz I also tried spotifyplus without luck so far. similar results.

@fcusson

Short term, this could be simply wrapping the service call in a try... excet and raise to a generic HomeAssistantError.

Is it possible to do this as a quick update?

@fcusson
Copy link
Collaborator

fcusson commented Oct 30, 2024

@raresdragan should be available shortly, just pushed the change, but need to test it when I get home

@fcusson fcusson added help wanted Extra attention is needed enhancement New feature or request beta Related to the beta program and removed bug Something isn't working help wanted Extra attention is needed labels Dec 5, 2024
@fcusson fcusson changed the title HTTP Error 404 for PUT to https://api.spotify.com/v1/me/player/play... Enable Proper Echo Device PLayback in Spotcast Dec 5, 2024
@fcusson
Copy link
Collaborator

fcusson commented Dec 5, 2024

renamed ticket to better encapulate the expected outcome and moved to beta improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta Related to the beta program enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants