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

HA 2021.4.0 - spotcast failed #174

Closed
rotrials opened this issue Apr 7, 2021 · 69 comments
Closed

HA 2021.4.0 - spotcast failed #174

rotrials opened this issue Apr 7, 2021 · 69 comments

Comments

@rotrials
Copy link

rotrials commented Apr 7, 2021

Hello,

After updating to Home Assistant 2021.4.0

I got the following error for spotcast
Setup failed for spotcast: Unable to import component: cannot import name 'KNOWN_CHROMECAST_INFO_KEY' from 'homeassistant.components.cast.media_player' (/usr/src/homeassistant/homeassistant/components/cast/media_player.py)

Let me know if you need further details?
Thanks for the project!

@Chimete
Copy link

Chimete commented Apr 7, 2021

Hello, same error here

Thanks for the project!

@onkytonk
Copy link

onkytonk commented Apr 7, 2021

I've just encountered the same error myself.

@hbaez81
Copy link

hbaez81 commented Apr 7, 2021

Same issue in 2021.4.0

@StreetGuru
Copy link

Same issue after 2021.4 upgrade

@smarthousetips
Copy link

Sam issue here

@justincrosby
Copy link
Contributor

Quick look through the new code and it looks like they've removed the KNOWN_CHROMECAST_INFO_KEY. The data is no longer stored in an easily accessible way. I don't see an obvious way to obtain this info now, but someone with more experience might be able to figure out a way.

@strandaster
Copy link

This issue is a duplicate of #172. There is already a potential patch available.

@rotrials
Copy link
Author

rotrials commented Apr 8, 2021

Still, it should update automatically if it's fixed.

@michaeltryl
Copy link

i can figuere out what the fix in #172 is. can someone tell me

@strandaster
Copy link

i can figuere out what the fix in #172 is. can someone tell me

@icarome created a pull request #173 with the needed code change to get it working in the new version of Home Assistant.

@ranrinc
Copy link

ranrinc commented Apr 8, 2021

Following the issues so I will get update when its fixed

@michaeltryl
Copy link

i can figuere out what the fix in #172 is. can someone tell me

@icarome created a pull request #173 with the needed code change to get it working in the new version of Home Assistant.

Thanks i copy All the files to my install.
Then update home Assistant.
There came No notifikation with fail, but i could not start my playlist

@beasthouse-au
Copy link

Also having this issue, following for a fix

@kireque
Copy link

kireque commented Apr 8, 2021

Following the issues so I will get update when its fixed

@Maaxion
Copy link
Contributor

Maaxion commented Apr 8, 2021

Please do not comment unless you have relevant new information regarding the issue at hand. Every time you comment everyone gets notified. If you wish to follow the issue click the thumbs up button on the first post. Posting non-informative comments is very disruptive.

@connor-dobbins
Copy link

I am not sure if this is part of this issue or a different issue. I updated to 2021.4.0 and got the same error about 'KNOWN_CHROMECAST_INFO_KEY'. I then commented out the spotcast lines from the configuration.yml file and now Spotcast doesn't even showup in HACS

@TheBisk
Copy link

TheBisk commented Apr 9, 2021

Same issue in 2021.4.1

@michaeltryl
Copy link

This worked for me. copy all these files over to your spotcast folder
https://github.com/raman325/spotcast/tree/fix_2021_4/custom_components/spotcast
then put this fix into the init.py file
c6b2953

reboot your system and it should work again

@pergolafabio
Copy link

i tried it, download complete folder , replaced, all files, then edited the init file, but after a restart , i got the issue thay spotcas integration could not be setup

@pergolafabio
Copy link

if i do replace the complte folder, without this : c6b2953

then seems HA to hangup on restart on a second time

@Electronlibre2012
Copy link

Hello,

like @pergolafabio doesnt work for me...

Home Assistant OS 5.13
supervisor-2021.03.9
core-2021.4.1

i tried the spotcast-fix_2021_4, doesnt work.

@pergolafabio
Copy link

nah, it made it verry worse, had extreme issues starting HA, rolled back and now disabled that one

@WirelessMind
Copy link

Integration disabled

@derandiunddasbo
Copy link

A bit off topic, but the 'Check Home Assistant configuration' addon is really handy for spotting these kind of issues, before updating to a new HA version. I'm always running it before actually updating and for the current update it threw this error right away, keeping me from getting into trouble in the first place.

@alexwohlbruck
Copy link

I tried removing the addon, but now when I check config I get:
Component error: spotcast - No module named 'custom_components.spotcast'
Is HA still referencing the module somewhere? How could I fix?

@kongo09
Copy link

kongo09 commented Apr 10, 2021

Are you sure you really removed it from your configuration? I had that as well until I discovered a sensor somewhere using spotcast.

@beasthouse-au
Copy link

Are you sure you really removed it from your configuration? I had that as well until I discovered a sensor somewhere using spotcast.

Do you remember which sensor? I’ve had a similar Invalid Config notification ever since the big update. Had removed spotcast but still have the error.

@alexwohlbruck
Copy link

You're right, i forgot to remove the config in my yaml file. All gone!

@fondberg
Copy link
Owner

I'm going to release a new version when home-assistant/core#49045 is merged (should be today or tomorrow)

@Electronlibre2012
Copy link

Many users have Spotcast installed...i thought Ha Team care about their users...

Stop setting a scene. Just because the current offered solution isn't the right one for the core (which of course has the HA team priority), doesn't mean we don't help or don't care.

We've been talking with @fondberg on other approaches and solutions. This is how programming works. 1000's different solutions.

Let's be positive.

yes lets be positive, thanks,

i just dont understand : there is already Google Cast and Spotify, why Spotcast can not be an official integration in HA in the futur?

@frenck
Copy link

frenck commented Apr 11, 2021

why Spotcast can not be an official integration in HA in the future?

Spotcast uses an undocumented/unsupported feature of Spotify. While cool, it might cause problems for us, especially since Home Assistant hopes to get a dedicated application account with Spotify in the future.

@Electronlibre2012
Copy link

ok understand. Sounds good...wait . Thanks for explanations.

@fondberg
Copy link
Owner

Fixed in https://github.com/fondberg/spotcast/releases/tag/v3.5.2. Help me test that release.

@MagicMicky
Copy link

MagicMicky commented Apr 11, 2021

I might be doing something wrong, but even on v3.5.2 it doesn't work for me.

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 143, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1480, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1515, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 264, in service_handler
    await script_entity.async_turn_on(
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 375, in async_turn_on
    await coro
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 392, in _async_run
    return await self.script.async_run(variables, context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1195, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 341, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 359, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 559, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1480, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1519, in _execute_service
    await self._hass.async_add_executor_job(handler.job.target, service_call)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/spotcast/__init__.py", line 377, in start_casting
    spotify_device_id = spotify_cast_device.getSpotifyDeviceId(client)
  File "/config/custom_components/spotcast/__init__.py", line 564, in getSpotifyDeviceId
    for device in devices_available["devices"]:
TypeError: 'NoneType' object is not iterable

Script:

data:
  entity_id: media_player.Bedroom
  force_playback: true
service: spotcast.start

Also the Spotify Lovelace Card doesn't load anymore which might be unrelated

Edit: looking more closely to my logs I also have a spotipy error HTTP Error for GET to https://api.spotify.com/v1/me/ returned 401 due to The access token expired; investigating

Edit 2: After reinstalling spotcast from scratch, reinstalling spotify integration, updating my sp_dc and sp_key credentials. It still wasn't working.
After completely recreating an app on the Spotify Developer Console and updating the values for the Client ID and Secret ID (from the new app) for spotify this ended up working for me (including automations and spotify lovelace card). This seem unrelated and more an issue from the spotify integration? I'm still unsure why my previous developer app stopped working.

@ssiergl
Copy link

ssiergl commented Apr 11, 2021

Working without problems here. Getting all chromcast devices...can play and switch between the devices. Everything well again tested with spotify lovelace card.

Thanks @fondberg and as well @frenck for the fix and the support

(core-2021.4.3 supervised debian buster installation here)

@joselito11
Copy link

Working, thank you!

@XalaTheShepard
Copy link

XalaTheShepard commented Apr 11, 2021

Many thanks for the update. I tested it immediately out, but am sorry to inform you that it also does not work for me. I am running HA supervised in HA OS. The playlists keep on loading endlessly and the devices can not be found:
image

@icarome
Copy link
Contributor

icarome commented Apr 11, 2021

How did you update? It's working perfectly for me, even the spotify card. I've use the hacs release

@jghaanstra
Copy link

Works for me as well, thanx @fondberg !

Cup of coffee coming your way.

@MagicMicky
Copy link

MagicMicky commented Apr 11, 2021

Replying here on top of edit for visibility, and might help @XalaTheShepard
I had errors from spotipy regarding credentials too.
After recreating an app on the Spotify Developer console (https://developer.spotify.com/dashboard/applications), reinstalling the spotify app and restarting things ended up working like before. Including the lovelace card.
Unsure about the root cause, but everything seems fine from Spotcast!

Thanks again for your work there @fondberg!

@roschi02
Copy link

Don't forget to give him a coffee for his work!
https://www.buymeacoffee.com/fondberg

@callebridholm
Copy link

callebridholm commented Apr 11, 2021

I might be doing something wrong, but even on v3.5.2 it doesn't work for me.

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 143, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1480, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1515, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 264, in service_handler
    await script_entity.async_turn_on(
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 375, in async_turn_on
    await coro
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 392, in _async_run
    return await self.script.async_run(variables, context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1195, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 341, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 359, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 559, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1480, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1519, in _execute_service
    await self._hass.async_add_executor_job(handler.job.target, service_call)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/spotcast/__init__.py", line 377, in start_casting
    spotify_device_id = spotify_cast_device.getSpotifyDeviceId(client)
  File "/config/custom_components/spotcast/__init__.py", line 564, in getSpotifyDeviceId
    for device in devices_available["devices"]:
TypeError: 'NoneType' object is not iterable

Script:

data:
  entity_id: media_player.Bedroom
  force_playback: true
service: spotcast.start

Also the Spotify Lovelace Card doesn't load anymore which might be unrelated

Edit: looking more closely to my logs I also have a spotipy error HTTP Error for GET to https://api.spotify.com/v1/me/ returned 401 due to The access token expired; investigating

Edit 2: After reinstalling spotcast from scratch, reinstalling spotify integration, updating my sp_dc and sp_key credentials. It still wasn't working.
After completely recreating an app on the Spotify Developer Console and updating the values for the Client ID and Secret ID (from the new app) for spotify this ended up working for me (including automations and spotify lovelace card). This seem unrelated and more an issue from the spotify integration? I'm still unsure why my previous developer app stopped working.

I have the exact same problem as you after upgrade of HA and this component

2021-04-11 20:25:28 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Unexpected error for call_service at pos 1: 'NoneType' object is not iterable
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 359, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 559, in _async_call_service_step
await service_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1480, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1519, in _execute_service
await self._hass.async_add_executor_job(handler.job.target, service_call)
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/spotcast/init.py", line 377, in start_casting
spotify_device_id = spotify_cast_device.getSpotifyDeviceId(client)
File "/config/custom_components/spotcast/init.py", line 564, in getSpotifyDeviceId
for device in devices_available["devices"]:
TypeError: 'NoneType' object is not iterable
2021-04-11 20:25:28 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140379664766720] Error handling message: Unknown error
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 18, in _handle_async_response
await func(hass, connection, msg)
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 439, in handle_execute_script
await script_obj.async_run(context=context)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1195, in async_run
await asyncio.shield(run.async_run())
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 341, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 359, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 559, in _async_call_service_step
await service_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1480, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1519, in _execute_service
await self._hass.async_add_executor_job(handler.job.target, service_call)
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/spotcast/init.py", line 377, in start_casting
spotify_device_id = spotify_cast_device.getSpotifyDeviceId(client)
File "/config/custom_components/spotcast/init.py", line 564, in getSpotifyDeviceId
for device in devices_available["devices"]:
TypeError: 'NoneType' object is not iterable

@zhdenny
Copy link

zhdenny commented Apr 11, 2021

Update through HACS, restarted Home Assistant....and everything works. Good!

@Electronlibre2012
Copy link

Don't forget to give him a coffee for his work!
https://www.buymeacoffee.com/fondberg

hope generosity and plenty of coffee cups for his nice and usefull Spotcast and card!

@mteuscher
Copy link

HA via docker lastest release, updated through HACS, works like a charm! Thank you very much!

@walkercz
Copy link

walkercz commented Apr 11, 2021

HA virtual box
core-2021.4.3
supervisor-2021.03.9
HACS - spotcast v3.5.2 - reinstall not helping
google home

I am newbie with spotcast - never run it successfully installed few days ago

tried to run it using mini media player or developer tools > services >
spotcast.start

using service data:
"entity_id" : "media_player.living_room",
"uri" : "spotify:playlist:37i9dQZF1DX3yvAYDslnv8"

[140685081292080] 'NoneType' object is not iterable
[140685073151840] Error handling message: Unknown error
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 143, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1480, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1519, in _execute_service
await self._hass.async_add_executor_job(handler.job.target, service_call)
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/spotcast/init.py", line 377, in start_casting
spotify_device_id = spotify_cast_device.getSpotifyDeviceId(client)
File "/config/custom_components/spotcast/init.py", line 564, in getSpotifyDeviceId
for device in devices_available["devices"]:
TypeError: 'NoneType' object is not iterable

@XalaTheShepard
Copy link

Thanks everyone, working perfectly again. The spotify integration had to be reinstalled again. A good, well deserved cup of coffee is coming up :)

@lambdahindiii
Copy link

It’s working great for me again too! I just updated via HACS and added the spotcast lines back into configuration.yaml and restarted. Everything working normally now (HA 2021.4.3 on HA OS on Raspberry Pi 4).

Thanks for all your hard work!

@pystha
Copy link

pystha commented Apr 11, 2021

HA 2021.4.3 in docker , Spotcast 3.5.2 it is not working anymore.

'Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/spotcast/init.py:323
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 1:50:47 AM (1 occurrences)
Last logged: 1:50:47 AM

[139970235530784] empty range for randrange() (0, 0, 0)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 143, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1480, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1519, in _execute_service
await self._hass.async_add_executor_job(handler.job.target, service_call)
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/spotcast/init.py", line 390, in start_casting
play(client, spotify_device_id, uri, random_song, repeat, shuffle, position)
File "/config/custom_components/spotcast/init.py", line 323, in play
position = random.randint(0, results["total"] - 1)
File "/usr/local/lib/python3.8/random.py", line 248, in randint
return self.randrange(a, b+1)
File "/usr/local/lib/python3.8/random.py", line 226, in randrange
raise ValueError("empty range for randrange() (%d, %d, %d)" % (istart, istop, width))
ValueError: empty range for randrange() (0, 0, 0)'

@johnjoemorgan
Copy link

I had reverted to 2021.3.4 while waiting for this and another as yet to to worked out bug with Xiaomi Miio,

However, this morning saw the new HACS update for this and the requirement for 2021.4.x. Being the contrarian I am I went ahead and updated with 2021.3.4 and I'm now typing this listening to spotify:artist:3BqAAo5E60L15TcFgWI8xH

@fondberg and other ... many thanks.

@mcfly2283
Copy link

mcfly2283 commented Apr 12, 2021

Updated, but i got the same error than a few other "TypeError: 'NoneType' object is not iterable" when i want to start playback on Google-Device.

EDIT: After readding Spotify Developer-Application and configuration of the Spotify-Integration evereything`s working. Thank you! :)

@fondberg
Copy link
Owner

@walkercz ask in the forum. Seems like you haven't gotten the keys correctly

@callebridholm
Copy link

Updated, but i got the same error than a few other "TypeError: 'NoneType' object is not iterable" when i want to start playback on Google-Device.

EDIT: After readding Spotify Developer-Application and configuration of the Spotify-Integration evereything`s working. Thank you! :)

Do we need to have the Spotify integration also in Home Assistant to get this working? Thought that this component was the only one needed and that is how I used it for a long time. Can´t see any required step in the installation part of this plugin either.
Tried to reinstall the plugin and get new sp_dc and sp_key without any luck, still same error

@mcfly2283
Copy link

Updated, but i got the same error than a few other "TypeError: 'NoneType' object is not iterable" when i want to start playback on Google-Device.
EDIT: After readding Spotify Developer-Application and configuration of the Spotify-Integration evereything`s working. Thank you! :)

Do we need to have the Spotify integration also in Home Assistant to get this working? Thought that this component was the only one needed and that is how I used it for a long time. Can´t see any required step in the installation part of this plugin either.
Tried to reinstall the plugin and get new sp_dc and sp_key without any luck, still same error

This is what i`ve found for the custom Spotify-Card:
"Spotify Integration and spotcast have to be installed (Spotcast is needed for many other things than playing on cast devices). This card should work in all newer major browsers. If it does not work for you please provide detailed reports in an issue ticket."
https://github.com/custom-cards/spotify-card

@callebridholm
Copy link

Updated, but i got the same error than a few other "TypeError: 'NoneType' object is not iterable" when i want to start playback on Google-Device.
EDIT: After readding Spotify Developer-Application and configuration of the Spotify-Integration evereything`s working. Thank you! :)

Do we need to have the Spotify integration also in Home Assistant to get this working? Thought that this component was the only one needed and that is how I used it for a long time. Can´t see any required step in the installation part of this plugin either.
Tried to reinstall the plugin and get new sp_dc and sp_key without any luck, still same error

This is what i`ve found for the custom Spotify-Card:
"Spotify Integration and spotcast have to be installed (Spotcast is needed for many other things than playing on cast devices). This card should work in all newer major browsers. If it does not work for you please provide detailed reports in an issue ticket."
https://github.com/custom-cards/spotify-card

Added this Spotify integration now and it start working again, thanks for help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests