fondberg / spotcast

Home assistant custom component to start Spotify playback on an idle chromecast device as well as control spotify connect devices
Apache License 2.0
684 stars 98 forks source link

HA 2021.4.0 - spotcast failed #174

Closed rotrials closed 3 years ago

rotrials commented 3 years ago

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 commented 3 years ago

Hello, same error here

Thanks for the project!

onkytonk commented 3 years ago

I've just encountered the same error myself.

hbaez81 commented 3 years ago

Same issue in 2021.4.0

StreetGuru commented 3 years ago

Same issue after 2021.4 upgrade

smarthousetips commented 3 years ago

Sam issue here

justincrosby commented 3 years ago

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 commented 3 years ago

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

rotrials commented 3 years ago

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

michaeltryl commented 3 years ago

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

strandaster commented 3 years ago

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 commented 3 years ago

Following the issues so I will get update when its fixed

michaeltryl commented 3 years ago

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 commented 3 years ago

Also having this issue, following for a fix

kireque commented 3 years ago

Following the issues so I will get update when its fixed

Maaxion commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

Same issue in 2021.4.1

michaeltryl commented 3 years ago

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 https://github.com/fondberg/spotcast/commit/c6b29531fb0836c7665a020c18fc33a99fba9dc3

reboot your system and it should work again

pergolafabio commented 3 years ago

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 commented 3 years ago

if i do replace the complte folder, without this : https://github.com/fondberg/spotcast/commit/c6b29531fb0836c7665a020c18fc33a99fba9dc3

then seems HA to hangup on restart on a second time

Electronlibre2012 commented 3 years ago

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 commented 3 years ago

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

WirelessMind commented 3 years ago

Integration disabled

derandiunddasbo commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

fondberg commented 3 years ago

I'm going to release a new version when https://github.com/home-assistant/core/pull/49045 is merged (should be today or tomorrow)

johnjoemorgan commented 3 years ago

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

Very much appreciated

fondberg commented 3 years ago

Fixed together with core PRs. Help me upvote them (links in this PR) https://github.com/fondberg/spotcast/pull/176

hmmbob commented 3 years ago

To all users: saying thanks for fixing this issue is obviously nice, but buying Niklas a coffee for his efforts is even better!

See https://github.com/fondberg/spotcast#donate

Remember: even if you buy him just a few cups of coffee, all together it is a great amount of appreciation!

frenck commented 3 years ago

Fixed together with core PRs. Help me upvote them

That won't make a difference (the upvoting that is).

At this point, the upstream PR is unneeded IMHO. Just dive into the entity/device registry of Home Assistant, get the instance of the entity and access the property directly.

That way:

fondberg commented 3 years ago

@french i am sorry. I this is generally the way in other open source projects but i hear you in HA. Again sorry and people stop upvote!

zhdenny commented 3 years ago

Sooooo....."Just dive into the entity/device registry of Home Assistant, get the instance of the entity and access the property directly."

That isn't really useful for someone who uses this simple integration. Can you explain to a simpleton like me....a lot of people use this integration and would love for it to work. I tried to read your comment but that doesn't really help me

frenck commented 3 years ago

That isn't really useful for someone who uses this simple integration.

It wasn't directed at the "user", it was directed at developers working on the issue.

kongo09 commented 3 years ago

That won't make a difference (the upvoting that is).

What should make a difference are the new analytics. To quote the release notes:

So why do we do this? Well, it helps the project and all contributors to see things like: Most used integrations. This can significantly help with improving project priorities.

Right now, spotcast seems to have dropped from the list, as everyone has disabled it. I don't know, where it was before, but maybe the internal data of the project team can show this?

@frenck The release notes don't even mention that 2021.4.0 is breaking spotcast. So how exactly do the improved project priorities help now?

@fondberg Unfortunately, I'm not a developer and cannot help. Are you seriously intending to drop development of spotcast if you don't get your fixes approved? What kind of help and priorities from the project would you need to get this back working?

frenck commented 3 years ago

What should make a difference are the new analytics.

Those measure core integration, not custom ones.

The release notes don't even mention that 2021.4.0 is breaking spotcast.

Correct, its not a core integration, its custom, which is not supported by the Home Assistant project.

kongo09 commented 3 years ago

@frenck apologies, I wasn't aware of that distinction. But then, I'm just a user and shouldn't have to.

update: this is really getting off-topic, but just to be clear, the official analytics documentation talks about all integrations, not just core ones:

https://www.home-assistant.io/integrations/analytics/

Electronlibre2012 commented 3 years ago

If Spotcast still custom, is that just mean the HA Team doesnt find interesting to include it as an integration?

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

Seems not.

fondberg commented 3 years ago

I understand them. I'm working on a solution which doesn't reguire a new HA. Hang in there and give them a break

frenck commented 3 years ago

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.

frenck commented 3 years ago

@frenck apologies, I wasn't aware of that distinction. But then, I'm just a user and shouldn't have to.

As a user, you definitely should know the difference. If you are using HACS, you have been warned multiple times. Home Assistant will place warnings in the logs each time you start as well.

Electronlibre2012 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

fondberg commented 3 years ago

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

MagicMicky commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

Working, thank you!