spotcast: Spotcast breaks with HA 2024.10.0b0
Bug Ticket
Describe the bug
Spotcast breaks when you upgrade from HA 2024.9 to 2024.10
Likely a regression because of https://github.com/home-assistant/core/pull/123548
Troubleshooting
Make sure to validate all the elements before submitting the ticket (Exception to the steps marked as optional)
- Using latest version of spotcast
- [beta] Using latest stable version of Home Assistant
- I have setup the Spotify integration in Home Assistant
- I have renewed my
sp_dcandsp_keyvalues 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
Environment
- Installation type: Container
- HA version: 2024.10.0b0
- spotcast version: 3.8.1
Logs
- normal
2024-09-26 21:01:41.484 ERROR (MainThread) [homeassistant.components.script.start_music_t] Slaaptijd: Error executing script. Unexpected error for call_service at pos 2: 'SpotifyMediaPlayer' object has no attribute 'data'
Traceback (most recent call last):
File "/config/custom_components/spotcast/helpers.py", line 39, in get_spotify_media_player
entity_devices = entity._devices
^^^^^^^^^^^^^^^
AttributeError: 'SpotifyMediaPlayer' object has no attribute '_devices'. Did you mean: 'devices'?
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
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 256, in start_casting
spotify_device_id = spotcast_controller.get_spotify_device_id(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/spotcast/spotcast_controller.py", line 284, in get_spotify_device_id
spotify_device_id = self._getSpotifyConnectDeviceId(client, device_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/spotcast/spotcast_controller.py", line 268, in _getSpotifyConnectDeviceId
media_player = get_spotify_media_player(self.hass, client._get("me")["id"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/spotcast/helpers.py", line 41, in get_spotify_media_player
entity_devices = entity.data.devices.data
^^^^^^^^^^^
AttributeError: 'SpotifyMediaPlayer' object has no attribute 'data'
2024-09-26 21:01:41.491 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
File "/config/custom_components/spotcast/helpers.py", line 39, in get_spotify_media_player
entity_devices = entity._devices
^^^^^^^^^^^^^^^
AttributeError: 'SpotifyMediaPlayer' object has no attribute '_devices'. Did you mean: 'devices'?
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 707, in _async_run
return await self.script.async_run(script_vars, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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 256, in start_casting
spotify_device_id = spotcast_controller.get_spotify_device_id(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/spotcast/spotcast_controller.py", line 284, in get_spotify_device_id
spotify_device_id = self._getSpotifyConnectDeviceId(client, device_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/spotcast/spotcast_controller.py", line 268, in _getSpotifyConnectDeviceId
media_player = get_spotify_media_player(self.hass, client._get("me")["id"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/spotcast/helpers.py", line 41, in get_spotify_media_player
entity_devices = entity.data.devices.data
^^^^^^^^^^^
AttributeError: 'SpotifyMediaPlayer' object has no attribute 'data'
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 34 (2 by maintainers)
For me, Version 3.8.2 does not work on HA 2024.9.3. I updated today, directly after the restart the playlists and players stay empty in spotcard. Protocol monitors some errors:
Going back to 3.8.1 and everything works as expected.
Same… Spotify Card not work after update to ver. 3.8.2 …((( https://github.com/custom-cards/spotify-card
ok found the solution, had to add the
hassobject to the get_spotify_device_id function to force the refresh of the data. Its now working.This might be a really good improvement, because that would also mean we can force refresh the list of devices now.
Should be fixed in v3.9.0
@PerSterin, @Flibbmaster, can you confirm?
Works for 2024.10 indeed, thanks.
@fcusson To fix
You could raise the HA version in hacs.json to 2024.10.0b0:
https://github.com/fondberg/spotcast/blob/cb2f905a6c62022b4a97a0f611026c409e661e3f/hacs.json#L4
User that are on an older version will not get this update pushed by HACS then. I don’t think you need a new release for that, just change the json.