And now I got another test
I was drive by car, so music was played through my A55 mobile phone.
I come to home, stop playing.
Go to spotify card - click “Play” - and error “Unknown device”
SO I go to devices section, and noticed, that in title I have “A55” - so integration still stick to last device which was in use.
So this is unknown device, as mobile app is closed on phone.
So I click on MiBox - I got error “unkown device”
Then I go to player section and click play - now music is played through MiBox, so context was switched to this device…
In logs:
31m2024-12-13 08:49:01.900 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139659762505408] Unexpected exception
Traceback (most recent call last):
File "/config/custom_components/spotifyplus/media_player.py", line 7280, in service_spotify_player_transfer_playback
self.data.spotifyClient.PlayerTransferPlayback(deviceId, play, delay, refreshDeviceList=False)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/spotifywebapipython/spotifyclient.py", line 12739, in PlayerTransferPlayback
self.PlayerMediaResume()
~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/local/lib/python3.13/site-packages/spotifywebapipython/spotifyclient.py", line 11830, in PlayerMediaResume
self.MakeRequest('PUT', msg)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/spotifywebapipython/spotifyclient.py", line 825, in MakeRequest
msg.ResponseData = self._CheckResponseForErrors(msg, response)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/spotifywebapipython/spotifyclient.py", line 629, in _CheckResponseForErrors
raise SpotifyWebApiError(errCode, errMessage, msg.MethodName, response.reason, _logsi)
spotifywebapipython.spotifywebapierror.SpotifyWebApiError: SAM1001E - Spotify Web API returned an error status while processing the "PlayerMediaResume" method.
Status: 403 - Forbidden
Message: "Player command failed: Restriction violated"
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 245, in handle_call_service
response = await hass.services.async_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<7 lines>...
)
^
File "/usr/src/homeassistant/homeassistant/core.py", line 2802, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2845, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1007, in entity_service_call
single_response = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
hass, entity, func, data, call.context
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1079, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 889, in async_select_source
await self.hass.async_add_executor_job(self.select_source, source)
File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/spotifyplus/media_player.py", line 273, in wrapper
result = func(self, *args, **kwargs)
File "/config/custom_components/spotifyplus/media_player.py", line 902, in select_source
self.service_spotify_player_transfer_playback(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
source,
^^^^^^^
play=True,
^^^^^^^^^^
refreshDeviceList=True,
^^^^^^^^^^^^^^^^^^^^^^^
forceActivateDevice=True)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/spotifyplus/media_player.py", line 7333, in service_spotify_player_transfer_playback
raise HomeAssistantError(ex.Message)
homeassistant.exceptions.HomeAssistantError: Player command failed: Restriction violatede[0m
and
e[31m2024-12-13 08:49:01.900 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139659762505408] Unexpected exception
Traceback (most recent call last):
File "/config/custom_components/spotifyplus/media_player.py", line 7280, in service_spotify_player_transfer_playback
self.data.spotifyClient.PlayerTransferPlayback(deviceId, play, delay, refreshDeviceList=False)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/spotifywebapipython/spotifyclient.py", line 12739, in PlayerTransferPlayback
self.PlayerMediaResume()
~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/local/lib/python3.13/site-packages/spotifywebapipython/spotifyclient.py", line 11830, in PlayerMediaResume
self.MakeRequest('PUT', msg)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/spotifywebapipython/spotifyclient.py", line 825, in MakeRequest
msg.ResponseData = self._CheckResponseForErrors(msg, response)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/spotifywebapipython/spotifyclient.py", line 629, in _CheckResponseForErrors
raise SpotifyWebApiError(errCode, errMessage, msg.MethodName, response.reason, _logsi)
spotifywebapipython.spotifywebapierror.SpotifyWebApiError: SAM1001E - Spotify Web API returned an error status while processing the "PlayerMediaResume" method.
Status: 403 - Forbidden
Message: "Player command failed: Restriction violated"
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 245, in handle_call_service
response = await hass.services.async_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<7 lines>...
)
^
File "/usr/src/homeassistant/homeassistant/core.py", line 2802, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2845, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1007, in entity_service_call
single_response = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
hass, entity, func, data, call.context
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1079, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 889, in async_select_source
await self.hass.async_add_executor_job(self.select_source, source)
File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/spotifyplus/media_player.py", line 273, in wrapper
result = func(self, *args, **kwargs)
File "/config/custom_components/spotifyplus/media_player.py", line 902, in select_source
self.service_spotify_player_transfer_playback(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
source,
^^^^^^^
play=True,
^^^^^^^^^^
refreshDeviceList=True,
^^^^^^^^^^^^^^^^^^^^^^^
forceActivateDevice=True)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/spotifyplus/media_player.py", line 7333, in service_spotify_player_transfer_playback
raise HomeAssistantError(ex.Message)
and 3rd type:
e[31m2024-12-13 08:49:01.900 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139659762505408] Unexpected exception
Traceback (most recent call last):
File "/config/custom_components/spotifyplus/media_player.py", line 7280, in service_spotify_player_transfer_playback
self.data.spotifyClient.PlayerTransferPlayback(deviceId, play, delay, refreshDeviceList=False)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/spotifywebapipython/spotifyclient.py", line 12739, in PlayerTransferPlayback
self.PlayerMediaResume()
~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/local/lib/python3.13/site-packages/spotifywebapipython/spotifyclient.py", line 11830, in PlayerMediaResume
self.MakeRequest('PUT', msg)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/spotifywebapipython/spotifyclient.py", line 825, in MakeRequest
msg.ResponseData = self._CheckResponseForErrors(msg, response)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/spotifywebapipython/spotifyclient.py", line 629, in _CheckResponseForErrors
raise SpotifyWebApiError(errCode, errMessage, msg.MethodName, response.reason, _logsi)
spotifywebapipython.spotifywebapierror.SpotifyWebApiError: SAM1001E - Spotify Web API returned an error status while processing the "PlayerMediaResume" method.
Status: 403 - Forbidden
Message: "Player command failed: Restriction violated"
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 245, in handle_call_service
response = await hass.services.async_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<7 lines>...
)
^
File "/usr/src/homeassistant/homeassistant/core.py", line 2802, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2845, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1007, in entity_service_call
single_response = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
hass, entity, func, data, call.context
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1079, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 889, in async_select_source
await self.hass.async_add_executor_job(self.select_source, source)
File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/spotifyplus/media_player.py", line 273, in wrapper
result = func(self, *args, **kwargs)
File "/config/custom_components/spotifyplus/media_player.py", line 902, in select_source
self.service_spotify_player_transfer_playback(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
source,
^^^^^^^
play=True,
^^^^^^^^^^
refreshDeviceList=True,
^^^^^^^^^^^^^^^^^^^^^^^
forceActivateDevice=True)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/spotifyplus/media_player.py", line 7333, in service_spotify_player_transfer_playback
raise HomeAssistantError(ex.Message)
homeassistant.exceptions.HomeAssistantError: Player command failed: Restriction violatede[0m
and
4th:
31m2024-12-13 08:48:27.789 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139659762505408] Unexpected exception
Traceback (most recent call last):
File "/config/custom_components/spotifyplus/media_player.py", line 273, in wrapper
result = func(self, *args, **kwargs)
File "/config/custom_components/spotifyplus/media_player.py", line 671, in media_play
self.data.spotifyClient.PlayerMediaResume()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/local/lib/python3.13/site-packages/spotifywebapipython/spotifyclient.py", line 11830, in PlayerMediaResume
self.MakeRequest('PUT', msg)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/spotifywebapipython/spotifyclient.py", line 825, in MakeRequest
msg.ResponseData = self._CheckResponseForErrors(msg, response)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/spotifywebapipython/spotifyclient.py", line 629, in _CheckResponseForErrors
raise SpotifyWebApiError(errCode, errMessage, msg.MethodName, response.reason, _logsi)
spotifywebapipython.spotifywebapierror.SpotifyWebApiError: SAM1001E - Spotify Web API returned an error status while processing the "PlayerMediaResume" method.
Status: 404 - Not Found
Message: "Device not found"
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 245, in handle_call_service
response = await hass.services.async_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<7 lines>...
)
^
File "/usr/src/homeassistant/homeassistant/core.py", line 2802, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2845, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1007, in entity_service_call
single_response = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
hass, entity, func, data, call.context
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1079, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 827, in async_media_play
await self.hass.async_add_executor_job(self.media_play)
File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/spotifyplus/media_player.py", line 287, in wrapper
raise HomeAssistantError(ex.Message)
homeassistant.exceptions.HomeAssistantError: Device not founde[0m