Casting returns error 'total'
See original GitHub issueDescription 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'
Issue Analytics
- State:
- Created 2 years ago
- Comments:20 (1 by maintainers)
Top Results From Across the Web
Cast Error in ORDER BY Clause - sql server - Stack Overflow
Your query is returning the TOP 25 , but when you ORDER BY something you ... Returns error: Error converting data type nvarchar...
Read more >3 Rectification of Errors - Casting Errors - By Saheb Academy
I have shown how to deal with casting errors with a simple technique and solved practical examples for complete clarity⏱TIMESTAMPS00:00 ...
Read more >Conversion Functions - Snowflake Documentation
Error -handling version of CAST. ... These functions return a NULL value instead of raising an error when the conversion ... Full or...
Read more >C Types, Casting, Segementation Violations and Bus Errors
This says to the compiler ``Yes, I know malloc() is returning an int, but I want it to be treated like a char...
Read more >SQL CAST and SQL CONVERT function overview - SQLShack
This articles explain the use of SQL Cast and SQL Convert functions in SQL Server.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.
ok we seem to have found the problem. Also I had some chat with the spotipy team and they seem to be more incline that the dev of the app should manage the user input, not their api.
In the light of that, I’ll close the issue, but I’ll work on a more robust management of the URI that will do more validation.