NiklasReiche / ad-spotify-mood-lights-sync

AppDaemon app that synchronizes rgb lights to the mood of the currently playing spotify song in Home Assistant.
MIT License
35 stars 5 forks source link

Cant find it in HACS. #15

Closed imMrRAW closed 6 months ago

imMrRAW commented 6 months ago

Cant find it in HACS.

Running latest version of HA/HACS. Tried adding this as Custom Repo, didn't work either.

NiklasReiche commented 6 months ago

Are you looking in the right place? It should be under Automation in HACS. I just tried it out and it shows up for me: image

imMrRAW commented 6 months ago

I got that sorted, i didnt have Discovery for AppDaemon in HACS. However, followed this: https://github.com/joBr99/nspanel-lovelace-ui/issues/1029

In my appdaemon.yaml i now have: app_dir: /homeassistant/appdaemon/apps/

I now get: 2024-02-25 18:38:49.703970 WARNING AppDaemon: appdir: /config/apps does not exist exist

  1. I installed AppDaemon
  2. In configuration i have "spotipy" under Python package"
  3. Downloaded ad-spotify-mood-lights-sync from HACS
  4. Did this: https://github.com/joBr99/nspanel-lovelace-ui/issues/1029
  5. In apps.yaml i have:
    spotify_mood_lights_sync:
    module: spotify_mood_lights_sync
    class: SpotifyMoodLightsSync
    client_id: !secret spotify_client_id
    client_secret: !secret spotify_client_secret
    media_player:
    - media_player.kok
    - media_player.vardagsrum
    - media_player.allrum
    light: light.vardagsrum

If i check in the WebGUI for AppDaemon there's no Apps; No data available

Logs:

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service base-addon-banner: starting

-----------------------------------------------------------
 Add-on: AppDaemon
 Python Apps and Dashboard using AppDaemon 4.x for Home Assistant
-----------------------------------------------------------
 Add-on version: 0.16.4
 You are running the latest version of this add-on.
 System: Home Assistant OS 11.5  (amd64 / qemux86-64)
 Home Assistant Core: 2024.2.3
 Home Assistant Supervisor: 2024.02.0
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
s6-rc: info: service base-addon-banner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service base-addon-log-level: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service base-addon-log-level successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service init-appdaemon: starting
Looking in indexes: https://pypi.org/simple, https://wheels.home-assistant.io/musllinux-index/
Collecting spotipy
  Downloading https://wheels.home-assistant.io/musllinux-index/spotipy-2.23.0-py3-none-any.whl.metadata (3.3 kB)
Collecting redis>=3.5.3 (from spotipy)
  Downloading https://wheels.home-assistant.io/musllinux-index/redis-5.0.1-py3-none-any.whl (250 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 250.3/250.3 kB 4.8 MB/s eta 0:00:00
Requirement already satisfied: requests>=2.25.0 in /usr/lib/python3.11/site-packages (from spotipy) (2.28.2)
Requirement already satisfied: six>=1.15.0 in /usr/lib/python3.11/site-packages (from spotipy) (1.16.0)
Requirement already satisfied: urllib3>=1.26.0 in /usr/lib/python3.11/site-packages (from spotipy) (1.26.18)
Requirement already satisfied: charset-normalizer<4,>=2 in /usr/lib/python3.11/site-packages (from requests>=2.25.0->spotipy) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in /usr/lib/python3.11/site-packages (from requests>=2.25.0->spotipy) (3.6)
Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python3.11/site-packages (from requests>=2.25.0->spotipy) (2023.11.17)
Downloading https://wheels.home-assistant.io/musllinux-index/spotipy-2.23.0-py3-none-any.whl (29 kB)
Installing collected packages: redis, spotipy
Successfully installed redis-5.0.1 spotipy-2.23.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
s6-rc: info: service init-appdaemon successfully started
s6-rc: info: service appdaemon: starting
s6-rc: info: service appdaemon successfully started
s6-rc: info: service legacy-services: starting
[18:42:52] INFO: Starting AppDaemon...
s6-rc: info: service legacy-services successfully started
2024-02-25 18:42:56.522122 INFO AppDaemon: AppDaemon Version 4.4.2 starting
2024-02-25 18:42:56.522310 INFO AppDaemon: Python version is 3.11.6
2024-02-25 18:42:56.522485 INFO AppDaemon: Configuration read from: /config/appdaemon.yaml
2024-02-25 18:42:56.522656 INFO AppDaemon: Added log: AppDaemon
2024-02-25 18:42:56.522926 INFO AppDaemon: Added log: Error
2024-02-25 18:42:56.523092 INFO AppDaemon: Added log: Access
2024-02-25 18:42:56.523257 INFO AppDaemon: Added log: Diag
2024-02-25 18:42:56.732477 WARNING AppDaemon: appdir: /config/apps does not exist exist
2024-02-25 18:42:56.733351 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2024-02-25 18:42:56.904801 INFO HASS: HASS Plugin Initializing
2024-02-25 18:42:56.905043 WARNING HASS: ha_url not found in HASS configuration - module not initialized
2024-02-25 18:42:56.905203 INFO HASS: HASS Plugin initialization complete
2024-02-25 18:42:56.905532 INFO AppDaemon: Initializing HTTP
2024-02-25 18:42:56.905900 INFO AppDaemon: Using 'ws' for event stream
2024-02-25 18:42:56.909227 INFO AppDaemon: Starting API
2024-02-25 18:42:56.911633 INFO AppDaemon: Starting Admin Interface
2024-02-25 18:42:56.911996 INFO AppDaemon: Starting Dashboards
2024-02-25 18:42:56.924762 INFO HASS: Connected to Home Assistant 2024.2.3
2024-02-25 18:42:56.926235 INFO AppDaemon: Starting Apps with 0 workers and 0 pins
2024-02-25 18:42:56.926506 INFO AppDaemon: Running on port 5050
2024-02-25 18:42:56.963295 INFO HASS: Evaluating startup conditions
2024-02-25 18:42:56.969668 INFO HASS: Startup condition met: hass state=RUNNING
2024-02-25 18:42:56.970039 INFO HASS: All startup conditions met
2024-02-25 18:42:57.003369 INFO AppDaemon: Got initial state from namespace default
2024-02-25 18:42:58.929985 INFO AppDaemon: Scheduler running in realtime
2024-02-25 18:42:58.936661 INFO AppDaemon: App initialization complete
2024-02-25 18:43:09.031962 INFO AppDaemon: New client Admin Client connected
imMrRAW commented 6 months ago

Alright, so now i got it to not throw errors, however - lights in that group isn't changed at all.

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service base-addon-banner: starting

-----------------------------------------------------------
 Add-on: AppDaemon
 Python Apps and Dashboard using AppDaemon 4.x for Home Assistant
-----------------------------------------------------------
 Add-on version: 0.16.4
 You are running the latest version of this add-on.
 System: Home Assistant OS 11.5  (amd64 / qemux86-64)
 Home Assistant Core: 2024.2.3
 Home Assistant Supervisor: 2024.02.0
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
s6-rc: info: service base-addon-banner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service base-addon-log-level: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service base-addon-log-level successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service init-appdaemon: starting
Looking in indexes: https://pypi.org/simple, https://wheels.home-assistant.io/musllinux-index/
Collecting spotipy
  Downloading https://wheels.home-assistant.io/musllinux-index/spotipy-2.23.0-py3-none-any.whl.metadata (3.3 kB)
Collecting redis>=3.5.3 (from spotipy)
  Downloading https://wheels.home-assistant.io/musllinux-index/redis-5.0.1-py3-none-any.whl (250 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 250.3/250.3 kB 3.6 MB/s eta 0:00:00
Requirement already satisfied: requests>=2.25.0 in /usr/lib/python3.11/site-packages (from spotipy) (2.28.2)
Requirement already satisfied: six>=1.15.0 in /usr/lib/python3.11/site-packages (from spotipy) (1.16.0)
Requirement already satisfied: urllib3>=1.26.0 in /usr/lib/python3.11/site-packages (from spotipy) (1.26.18)
Requirement already satisfied: charset-normalizer<4,>=2 in /usr/lib/python3.11/site-packages (from requests>=2.25.0->spotipy) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in /usr/lib/python3.11/site-packages (from requests>=2.25.0->spotipy) (3.6)
Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python3.11/site-packages (from requests>=2.25.0->spotipy) (2023.11.17)
Downloading https://wheels.home-assistant.io/musllinux-index/spotipy-2.23.0-py3-none-any.whl (29 kB)
Installing collected packages: redis, spotipy
Successfully installed redis-5.0.1 spotipy-2.23.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
s6-rc: info: service init-appdaemon successfully started
s6-rc: info: service appdaemon: starting
s6-rc: info: service appdaemon successfully started
s6-rc: info: service legacy-services: starting
[19:17:38] INFO: Starting AppDaemon...
s6-rc: info: service legacy-services successfully started
2024-02-25 19:17:42.322005 INFO AppDaemon: AppDaemon Version 4.4.2 starting
2024-02-25 19:17:42.322475 INFO AppDaemon: Python version is 3.11.6
2024-02-25 19:17:42.322646 INFO AppDaemon: Configuration read from: /config/appdaemon.yaml
2024-02-25 19:17:42.322852 INFO AppDaemon: Added log: AppDaemon
2024-02-25 19:17:42.323169 INFO AppDaemon: Added log: Error
2024-02-25 19:17:42.323518 INFO AppDaemon: Added log: Access
2024-02-25 19:17:42.323892 INFO AppDaemon: Added log: Diag
2024-02-25 19:17:42.539852 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2024-02-25 19:17:42.723660 INFO HASS: HASS Plugin Initializing
2024-02-25 19:17:42.723965 WARNING HASS: ha_url not found in HASS configuration - module not initialized
2024-02-25 19:17:42.724200 INFO HASS: HASS Plugin initialization complete
2024-02-25 19:17:42.724617 INFO AppDaemon: Initializing HTTP
2024-02-25 19:17:42.724949 INFO AppDaemon: Using 'ws' for event stream
2024-02-25 19:17:42.728900 INFO AppDaemon: Starting API
2024-02-25 19:17:42.731522 INFO AppDaemon: Starting Admin Interface
2024-02-25 19:17:42.732014 INFO AppDaemon: Starting Dashboards
2024-02-25 19:17:42.744685 INFO HASS: Connected to Home Assistant 2024.2.3
2024-02-25 19:17:42.760234 INFO AppDaemon: App 'spotify_mood_lights_sync' added
2024-02-25 19:17:42.762154 INFO AppDaemon: App 'spotify_lights_sync' added
2024-02-25 19:17:42.763726 INFO AppDaemon: Found 2 active apps
2024-02-25 19:17:42.764079 INFO AppDaemon: Found 0 inactive apps
2024-02-25 19:17:42.764732 INFO AppDaemon: Found 0 global libraries
2024-02-25 19:17:42.765269 INFO AppDaemon: Starting Apps with 2 workers and 2 pins
2024-02-25 19:17:42.768719 INFO AppDaemon: Running on port 5050
2024-02-25 19:17:42.803890 INFO HASS: Evaluating startup conditions
2024-02-25 19:17:42.811903 INFO HASS: Startup condition met: hass state=RUNNING
2024-02-25 19:17:42.812704 INFO HASS: All startup conditions met
2024-02-25 19:17:42.841529 INFO AppDaemon: Got initial state from namespace default
2024-02-25 19:17:44.776596 INFO AppDaemon: Scheduler running in realtime
2024-02-25 19:17:44.779303 INFO AppDaemon: Adding /config/apps to module import path
2024-02-25 19:17:44.780750 WARNING AppDaemon: No app description found for: /config/apps/hello.py - ignoring
2024-02-25 19:17:44.781455 INFO AppDaemon: App initialization complete
2024-02-25 19:17:49.052448 INFO AppDaemon: New client Admin Client connected

image

My apps.yaml now says:

spotify_mood_lights_sync:
  module: spotify_mood_lights_sync
  class: SpotifyMoodLightsSync
  client_id: !secret spotify_client_id
  client_secret: !secret spotify_client_secret
  mode: search
  media_player:
    - media_player.kok
    - media_player.vardagsrum
    - media_player.allrum
  light: light.vardagsrum

spotify_lights_sync:
  module: spotify_mood_lights_sync
  class: SpotifyMoodLightsSync
  client_id: !secret spotify_client_id
  client_secret: !secret spotify_client_secret
  constrain_input_boolean: input_boolean.spotify_lights_sync_toggle
  media_player:
    - media_player.kok
    - media_player.vardagsrum
    - media_player.allrum
  light: light.vardagsrum
NiklasReiche commented 6 months ago

You have to specify a single media player per configuration. Currently you have given a list.

I should probably add some more configuration validation on app startup.

imMrRAW commented 6 months ago

I have now changed some stuff, but can't seem to get the Hue Lights to switch color at all by playing music through spotify on my media_player.vardagsrum

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service base-addon-banner: starting

-----------------------------------------------------------
 Add-on: AppDaemon
 Python Apps and Dashboard using AppDaemon 4.x for Home Assistant
-----------------------------------------------------------
 Add-on version: 0.16.4
 You are running the latest version of this add-on.
 System: Home Assistant OS 11.5  (amd64 / qemux86-64)
 Home Assistant Core: 2024.2.3
 Home Assistant Supervisor: 2024.02.0
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
s6-rc: info: service base-addon-banner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service base-addon-log-level: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service base-addon-log-level successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service init-appdaemon: starting
Looking in indexes: https://pypi.org/simple, https://wheels.home-assistant.io/musllinux-index/
Collecting spotipy
  Downloading https://wheels.home-assistant.io/musllinux-index/spotipy-2.23.0-py3-none-any.whl.metadata (3.3 kB)
Collecting redis>=3.5.3 (from spotipy)
  Downloading https://wheels.home-assistant.io/musllinux-index/redis-5.0.1-py3-none-any.whl (250 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 250.3/250.3 kB 5.5 MB/s eta 0:00:00
Requirement already satisfied: requests>=2.25.0 in /usr/lib/python3.11/site-packages (from spotipy) (2.28.2)
Requirement already satisfied: six>=1.15.0 in /usr/lib/python3.11/site-packages (from spotipy) (1.16.0)
Requirement already satisfied: urllib3>=1.26.0 in /usr/lib/python3.11/site-packages (from spotipy) (1.26.18)
Requirement already satisfied: charset-normalizer<4,>=2 in /usr/lib/python3.11/site-packages (from requests>=2.25.0->spotipy) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in /usr/lib/python3.11/site-packages (from requests>=2.25.0->spotipy) (3.6)
Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python3.11/site-packages (from requests>=2.25.0->spotipy) (2023.11.17)
Downloading https://wheels.home-assistant.io/musllinux-index/spotipy-2.23.0-py3-none-any.whl (29 kB)
Installing collected packages: redis, spotipy
Successfully installed redis-5.0.1 spotipy-2.23.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
s6-rc: info: service init-appdaemon successfully started
s6-rc: info: service appdaemon: starting
s6-rc: info: service appdaemon successfully started
s6-rc: info: service legacy-services: starting
[19:45:30] INFO: Starting AppDaemon...
s6-rc: info: service legacy-services successfully started
2024-02-25 19:45:33.788029 INFO AppDaemon: AppDaemon Version 4.4.2 starting
2024-02-25 19:45:33.788785 INFO AppDaemon: Python version is 3.11.6
2024-02-25 19:45:33.789043 INFO AppDaemon: Configuration read from: /config/appdaemon.yaml
2024-02-25 19:45:33.789693 INFO AppDaemon: Added log: AppDaemon
2024-02-25 19:45:33.789952 INFO AppDaemon: Added log: Error
2024-02-25 19:45:33.790449 INFO AppDaemon: Added log: Access
2024-02-25 19:45:33.790670 INFO AppDaemon: Added log: Diag
2024-02-25 19:45:34.007294 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2024-02-25 19:45:34.192201 INFO HASS: HASS Plugin Initializing
2024-02-25 19:45:34.193043 WARNING HASS: ha_url not found in HASS configuration - module not initialized
2024-02-25 19:45:34.193514 INFO HASS: HASS Plugin initialization complete
2024-02-25 19:45:34.194241 INFO AppDaemon: Initializing HTTP
2024-02-25 19:45:34.194948 INFO AppDaemon: Using 'ws' for event stream
2024-02-25 19:45:34.198960 INFO AppDaemon: Starting API
2024-02-25 19:45:34.202198 INFO AppDaemon: Starting Admin Interface
2024-02-25 19:45:34.203114 INFO AppDaemon: Starting Dashboards
2024-02-25 19:45:34.216565 INFO HASS: Connected to Home Assistant 2024.2.3
2024-02-25 19:45:34.228136 INFO AppDaemon: App 'spotify_mood_lights_sync' added
2024-02-25 19:45:34.230263 INFO AppDaemon: App 'spotify_lights_sync' added
2024-02-25 19:45:34.231246 INFO AppDaemon: Found 2 active apps
2024-02-25 19:45:34.231711 INFO AppDaemon: Found 0 inactive apps
2024-02-25 19:45:34.232223 INFO AppDaemon: Found 0 global libraries
2024-02-25 19:45:34.232704 INFO AppDaemon: Starting Apps with 2 workers and 2 pins
2024-02-25 19:45:34.236097 INFO AppDaemon: Running on port 5050
2024-02-25 19:45:34.277559 INFO HASS: Evaluating startup conditions
2024-02-25 19:45:34.287747 INFO HASS: Startup condition met: hass state=RUNNING
2024-02-25 19:45:34.288443 INFO HASS: All startup conditions met
2024-02-25 19:45:34.317574 INFO AppDaemon: Got initial state from namespace default
2024-02-25 19:45:34.994996 INFO AppDaemon: New client Admin Client connected
2024-02-25 19:45:36.242332 INFO AppDaemon: Scheduler running in realtime
2024-02-25 19:45:36.248853 INFO AppDaemon: Adding /config/apps to module import path
2024-02-25 19:45:36.252427 INFO AppDaemon: Loading App Module: /config/apps/spotify_mood_lights_sync.py
2024-02-25 19:45:36.317499 WARNING AppDaemon: No app description found for: /config/apps/hello.py - ignoring
2024-02-25 19:45:36.318571 INFO AppDaemon: Loading app spotify_mood_lights_sync using class SpotifyMoodLightsSync from module spotify_mood_lights_sync
2024-02-25 19:45:36.323398 INFO AppDaemon: Loading app spotify_lights_sync using class SpotifyMoodLightsSync from module spotify_mood_lights_sync
2024-02-25 19:45:36.326570 INFO AppDaemon: Calling initialize() for spotify_mood_lights_sync
2024-02-25 19:45:36.435365 INFO spotify_mood_lights_sync: App started. Listening on media_player.vardagsrum
2024-02-25 19:45:36.436510 INFO AppDaemon: Calling initialize() for spotify_lights_sync
2024-02-25 19:45:36.442617 INFO spotify_lights_sync: App started. Listening on media_player.vardagsrum
2024-02-25 19:45:36.443762 INFO AppDaemon: App initialization complete
NiklasReiche commented 6 months ago

Have you tried 'search' mode with your newest config? If your media player isn't the one generated by the Spotify integration, the default mode won't work. That's the only thing I can think of right now.

Otherwise you could try setting the log level to debug to see at which point it stops working

imMrRAW commented 6 months ago

Have you tried 'search' mode with your newest config? If your media player isn't the one generated by the Spotify integration, the default mode won't work. That's the only thing I can think of right now.

Otherwise you could try setting the log level to debug to see at which point it stops working

Alright, so now it actually changes color as soon as i switch song - but isn't it supposed to switch during the song also, to follow the audio? Or does it only grab the color once throughout the song?

NiklasReiche commented 6 months ago

Yeah, there's only one color value per song. The way it works is that Spotify attributes a static 'mood value' to each song, which we can represent by a color, but there's no information for anything more fine-grained.

I also don't think that it's possible to build something like that with just HA/AD, since you would need to run some sort of live waveform analysis on the raw audio signal. This would be in the same vein as live syncing e.g. light intensity to the beat. Not to mention having to keep latency extremely low.