Open milandzuris opened 2 days 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
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'