spotcast: Casting returns error 'total'
Description Spotcasting my playlist to a device (through entity_id) works fine, however whenever I enable ‘Random Song’ or ‘Offset’ the service doesn’t run at all and errors out saying ‘total’. See logs below for more information.
- Using latest version of spotcast
- I have setup the Spotify integration in Home Assistant
- Using latest stable version of Home Assistant
- I have Spotify Premium
- I’m attaching relevant logs with level debug for component spotcast (see README)
- I’m using entity_id in the service call and have tried device_name but the issue remains
Environment (please complete the following information):
- HA version: core-2021.11.5
- spotcast version: 3.6.21
LOGS:
Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/spotcast/spotcast_controller.py:263
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 3:59:24 p.m. (14 occurrences)
Last logged: 4:13:59 p.m.
[281472494122992] 'total'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
await handler.job.target(service_call)
File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 280, in service_handler
await script_entity.async_turn_on(
File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 384, in async_turn_on
await coro
File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 410, in _async_run
return await self.script.async_run(script_vars, context)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1243, in async_run
await asyncio.shield(run.async_run())
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 353, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 371, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 571, in _async_call_service_step
await service_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1534, in _execute_service
await self._hass.async_add_executor_job(handler.job.target, service_call)
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/spotcast/__init__.py", line 176, in start_casting
spotcast_controller.play(
File "/config/custom_components/spotcast/spotcast_controller.py", line 263, in play
position = random.randint(0, results["total"] - 1)
KeyError: 'total'
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 20 (1 by maintainers)
Commits related to this issue
- correction for #267 — committed to fcusson/spotcast by fcusson 3 years ago
- Merge pull request #277 from Darkfull-Dante/master correction for #267 — committed to fondberg/spotcast by fcusson 3 years ago
@Mothamoz don’t worry I wouldn’t participate in an open source project if I didn’t enjoy trying to figure these things. While composing the issue for spotipy, I seem to have figured out something. I tested on my dev env and in the first dictionary I printed, we have a key which is
tracks. The value inside that is the actual dictionary we are looking for.I think I have a way of resolving the issue from our end without modifying the uri itself, which would be ideal. If I have a potential fix, I will update this issue, but I won’t close it, because it is still the Spotipy that should make sure to return consistent dictyionaries for valid URIs.