Closed milandzuris closed 4 weeks ago
@milandzuris spotipy
is a dependancy for more then just Spotcast, it is a requirement for the Spotify Integration and should be preinstalled with Home Assistant.
I see you decided to remove the section that provides detail about your current installation (Type of Home Assistant install, versions of different software) In this case, this is absoutely necessary information. In doubt, don't remove part of a form from a dev, there's a good reason we ask for those.
Please add the following information
just checked and Home Assistant made a change in Spotify integration to remove Spotipy as a dependancy to go toward aiospotify. Adding requirements to the manifest will solve
fix expected from #466
@tsvi
Does spotcast work fine as well with your fix? Did you test if it actually works?
Because in the beta channel of the HA Discord it was expected that Spotcast would break due to the major changes in the main Spotify integration in HA.
(Not able to upgrade to beta myself yet to test)
It loads correctly. There might be some more issues happening. I tried testing more, but then discovered I had issues with the updated Spotify integration as well, so I reverted my install back to 2024.10.
@tsvi @hmmbob almost done with v4 we'll be completely independent from the main spotify integration at this point.
I'll do the integration test tomorrow morning
Whoa, that's some cool news!
Whoa, that's some cool news!
Just not to raise false hope, the integration testing I'm talking about is the spotipy requirements, I'm still a couple of weeks away from being ready to release a beta for Spotcast V4
@tsvi from my side I'm having some major issues, my container is clearly installing the depandencies, but is unable to see them. My deps folder has the spotipy files, but HomeAssistant is still marking it has not being there.
My issue now is that my setup is RHEL based so I'm using podman for containerisation, I don't know if that's what is causing problem right now or if a true docker environment would make it work
Could you confirm what environment you tested in?
I actually used my production environment which is a NUC running HA OS. I manually copied the changed manifest to the custom_components/spot cast directory and restarted my home assistant instance.
Juts had some time to upgrade to beta as well, and adding spotipy
to the dependencies alone does not fix the issue:
2024-11-01 13:05:40.983 ERROR (MainThread) [homeassistant.components.script.start_music_t] Slaaptijd: Error executing script. Unexpected error for call_service at pos 2: 'Device' object is not subscriptable
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 526, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 764, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 727, in _async_run_long_action
return await long_task
^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2802, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2852, 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 267, in start_casting
spotify_device_id = spotcast_controller.get_spotify_device_id(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/spotcast/spotcast_controller.py", line 292, in get_spotify_device_id
spotify_device_id = self._getSpotifyConnectDeviceId(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/spotcast/spotcast_controller.py", line 278, in _getSpotifyConnectDeviceId
if device["name"] == device_name:
~~~~~~^^^^^^^^
TypeError: 'Device' object is not subscriptable
2024-11-01 13:05:40.992 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140547173487456] Unexpected exception
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 245, in handle_call_service
response = await hass.services.async_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2802, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2845, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 722, in _service_handler
response = await self._async_start_run(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 678, in _async_start_run
script_result = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 711, in _async_run
return await self.script.async_run(script_vars, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1801, in async_run
return await asyncio.shield(create_eager_task(run.async_run()))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 464, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 528, in _async_step
self._handle_exception(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 558, in _handle_exception
raise exception
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 526, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 764, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 727, in _async_run_long_action
return await long_task
^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2802, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2852, 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 267, in start_casting
spotify_device_id = spotcast_controller.get_spotify_device_id(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/spotcast/spotcast_controller.py", line 292, in get_spotify_device_id
spotify_device_id = self._getSpotifyConnectDeviceId(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/spotcast/spotcast_controller.py", line 278, in _getSpotifyConnectDeviceId
if device["name"] == device_name:
~~~~~~^^^^^^^^
TypeError: 'Device' object is not subscriptable
The script itself turns off some lights, sets volume and starts Spotcast with:
- action: spotcast.start
data:
account: t
entity_id: media_player.slaapkamer_t
uri: spotify:track:5OoSxUZSbP1p7kb1d0SozG
@hmmbob
TypeError: 'Device' object is not subscriptable
Yeah that's what I feared, the current way spotcast handles finding if a device is available is by checking the devices list from the Spotify Integration, since it changed its core dependencies, getting the list of device will be different
@tsvi
which is a NUC running HA OS
That's what I feared, my issue must be with the container environment. I opened a support ticket on the HA Discord to see if any other dev ever ran into that issue in the past
so this is actually a regression bug that started in 2024.10 to the looks of it #127966
At least there's a quick fix of adding a PYTHONPATH variable to the container. I'll try to fix the device issue during my lunch break
I'm very close to a solution, but saddly, spotifyaio has some issues still. Currently, it fails if it receives a device with a device_type CastAudio
which is every chromecast devices. I'll open a ticket and potentially a pr for the library
edit: This was added an hour ago in v0.8.2, I'll have to wait for it to be available hopefully in next beta build
@milandzuris, @tsvi, @hmmbob
moving to a dependency issue. I was able to fix most problems with the move to spotifyaio
but will need a new build of the container with v0.8.2
to continue. Without that currently, CastAudio
devices (so chromecasts) fail to load in the list of device in the Spotify integration.
It is to note that this bug is not only affecting Spotcast, but the core Spotify integration has well
edit: current changes are in dev under the version v3.9.1-a0
It's been merged into the beta code, next HA beta should include the bump to 0.8.2
And HA 2024.11.0b2 was just released, including the bump to 0.8.2
https://github.com/home-assistant/core/releases/tag/2024.11.0b2
perfect, will test integration testing with my fixes, we will have to fix the new minimal HA release to 2024.11 for sure with the new changes
Logger: homeassistant.components.websocket_api.http.connection Source: components/websocket_api/connection.py:315 integration: Home Assistant WebSocket API (documentation, issues) First occurred: 23:52:19 (2 occurrences) Last logged: 23:52:21
[140349401062208] Error handling message: 'Device' object is not subscriptable (home_assistant_error) Dzuriš Home from 192.168.0.50 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36)
dome with integration testing, spotcast is working as intended now
[140349401062208] Error handling message: 'Device' object is not subscriptable
@milandzuris. This is normal, the issues was bigger than just reintegrating spotipy
as a requirement.
perfect, will test integration testing with my fixes, we will have to fix the new minimal HA release to 2024.11 for sure with the new changes
I see you bumped version to 3.9.1, but there's no release with that version number. Are you aware?
Fyi; HA beta 3 was just released and contains a bump for spotifyaio
to 0.8.3, but from the looks of it it shouldn't impact Spotcast.
https://github.com/joostlek/python-spotify/compare/v0.8.2...v0.8.3
@hmmbob
HA beta 3 was just released and contains a bump for spotifyaio to 0.8.3
thanks for the heads up, shouldn't from what I'm seeing.
I see you bumped version to 3.9.1, but there's no release with that version number. Are you aware?
Yes this is normal, I pushed the change, but realised I forgot 1 integration test I normally run (category) and didn't want a send the new release without confirming its working. Just done with integration testing this morning, I'll start to draft the release.
Confirming the issue is fixed with Spotcast 3.9.1 and HA 2024.11.0b3
Had to manually update the files though, HACS is not allowing to update Spotcast while on beta as you set 2024.11.0 as minimum version (not sure if 2024.11.0b2 is an acceptable format for that check, but stable 2024.11.0 will release in 2 days anyways)
ok, weird, HACS is not very clear on how to mention home assistant beta version gonna dig in there documentation if there is a way to accept beta version of home assistant, but there calver check probably is not able to see the b2
as a subset of the version
just found it, you need to hardcode b0
at the end of the version, going to push as version 3.9.2 to fix.
@hmmbob can you confirm if you are able to install at this point in the beta version. If so, I'll mark the ticket completed
Yes, update now works!
Many thanks for your efforts!
@hmmbob, @tsvi thanks for all the troubleshooting and help. Really glad we could solve it before the official release of 2024.11
@fcusson Please note, that it is currently not possible to install Spotcast at all. I'm currently running HA version 2024.10.4 (no beta channel) and I'm not able to install any version of Spotcast. The latest version (v3.9.2) ~10 min ago release has this issue and older ones have either the same problem or state that they are incompatible.
3.9.0 should be compatible with HA 2024.10.4.
You could download it from the releases section here on github and place the files in your /custom_componens/spotcast/ folder. See: https://github.com/fondberg/spotcast?tab=readme-ov-file#manual-installation
Thanks for the quick help. It worked :-)
Added a banner message in the release for people who missed the information in the changelog
Bug Ticket
Describe the bug
Troubleshooting
Make sure to validate all the elements before submitting the ticket (Exception to the steps marked as optional)
sp_dc
andsp_key
values and restarted Home Assistant (see README)Logs
Logger: homeassistant.setup Source: setup.py:334 First occurred: 20:49:26 (1 occurrences) Last logged: 20:49:26
Setup failed for custom integration 'spotcast': Unable to import component: No module named 'spotipy' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/setup.py", line 334, in _async_setup_component component = await integration.async_get_component() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 1031, in async_get_component self._component_future.result() File "/usr/src/homeassistant/homeassistant/loader.py", line 1011, in async_get_component comp = await self.hass.async_add_import_executor_job( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, *self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 1071, in _get_component ComponentProtocol, importlib.import_module(self.pkg_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/util/loop.py", line 200, in protected_loop_func return func(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/importlib/init.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1331, in _find_and_load_unlocked
File "", line 935, in _load_unlocked
File "", line 995, in exec_module
File "", line 488, in _call_with_frames_removed
File "/config/custom_components/spotcast/init.py", line 55, in
from .helpers import (
File "/config/custom_components/spotcast/helpers.py", line 15, in
import spotipy
ModuleNotFoundError: No module named 'spotipy'