Closed DrJohnT closed 3 years ago
Also, is it feasible to have two or more configs?
For example, in my apps.yaml I added the following. Will this work?
spotify_upstairs_light_sync:
module: spotify_mood_lights_sync
class: SpotifyMoodLightsSync
client_id: !secret spotify_client_id
client_secret: !secret spotify_client_secret
media_player: media_player.spotify_john_tunnicliffe
light: light.upstairs_led
color_profile: default
mode: direct
max_retries: 4
constrain_input_boolean: input_boolean.spotify_upstairs_lights_sync_toggle
spotify_lounge_light_sync:
module: spotify_mood_lights_sync
class: SpotifyMoodLightsSync
client_id: !secret spotify_client_id
client_secret: !secret spotify_client_secret
media_player: media_player.spotify_john_tunnicliffe
light: light.led_lights
color_profile: default
mode: direct
max_retries: 1
constrain_input_boolean: input_boolean.spotify_lounge_lights_sync_toggle
Found a closed issue which mentioned appdeamon.yaml, so I added those lines to that file so it now looks like this:
---
secrets: /config/secrets.yaml
appdaemon:
latitude: xxx
longitude: -xxx
elevation: 4
time_zone: Europe/London
plugins:
HASS:
type: hass
http:
url: http://127.0.0.1:5050
admin:
api:
hadashboard:
python_packages:
- spotipy
- numpy
system_packages:
- jpeg
- tiff
Restarted the AppDeamon plug-in and see this in the logs. Also see "compile error " against the module as shown below.
2021-04-06 23:30:42.386502 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/ha_upgraded.py
2021-04-06 23:30:42.406372 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/ad-spotify-mood-lights-sync/spotify_mood_lights_sync.py
2021-04-06 23:30:42.412576 WARNING Error: ------------------------------------------------------------
2021-04-06 23:30:42.413299 WARNING Error: Unexpected error loading module: /config/appdaemon/apps/ad-spotify-mood-lights-sync/spotify_mood_lights_sync.py:
2021-04-06 23:30:42.414059 WARNING Error: ------------------------------------------------------------
2021-04-06 23:30:42.420400 WARNING Error: Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/appdaemon/app_management.py", line 963, in check_app_updates
await utils.run_in_executor(self, self.read_app, mod["name"], mod["reload"])
File "/usr/lib/python3.8/site-packages/appdaemon/utils.py", line 299, in run_in_executor
response = future.result()
File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/lib/python3.8/site-packages/appdaemon/app_management.py", line 755, in read_app
self.modules[module_name] = importlib.import_module(module_name)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/config/appdaemon/apps/ad-spotify-mood-lights-sync/spotify_mood_lights_sync.py", line 5, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
2021-04-06 23:30:42.421075 WARNING Error: ------------------------------------------------------------
2021-04-06 23:30:42.422106 WARNING AppDaemon: Removing associated apps:
2021-04-06 23:30:42.423010 WARNING AppDaemon: spotify_upstairs_light_sync
However, I have no idea how to add the python packages to the AppDaemon environment and probably others do not know either. What is the mechanism?
If you are running the appdaemon supervisor add-on, the python and system packages can be configured on the add-on configuration page, like so:
The add-on will then automatically install them in its docker container when it is restarted.
I don't think that adding them to the appdaemon.yaml
does anything.
Now, I'm not familiar with all the installation options for Home Assistant and Appdaemon, but if you are running appdaemon without the add-on you will have to install the packages manually (e.g. if appdaemon is running as a python app in a virtualenv, then the python packages must be installed in the same virtualenv)
Also, is it feasible to have two or more configs?
Yes, currently you need an instance of the app for each media_player you want to listen to and also for each light or light group you want to control separately, e.g. if you want separate on/off switches for upstairs and downstairs. It also doesn't matter if a media player or light is used in multiple configs.
Hey @DrJohnT, did you manage to get it to work?
@NiklasReiche oh yes indeed. I was simply confused as to where the libraries were added/defined. I also added the optional input_boolean so I could turn the feature on/off.
Actually, the input_boolean is an absolute must as I found that simply playing music would turn on the lights, even if they were off. Perhaps a bug???
oh yes indeed
@DrJohnT glad to hear that. I will add a link to the addon docs in the readme.
Perhaps a bug???
No, that is working as intended (at least for now). You should be able to model more complex constraints (e.g. prevent running when the lights are off) with Home Assistant automations, e.g. by toggling the input_boolean based on additional conditions.
Under Prerequisites, you state
"For this app to work, the following python packages must be installed in the AppDaemon environment:"
However, I have no idea how to add the python packages to the AppDaemon environment and probably others do not know either. What is the mechanism? Could you please update the documentation?
I am running Home Assistant Supervised on Debian 10 as per below info
System Health
Home Assistant Community Store
GitHub API | ok -- | -- Github API Calls Remaining | 4818 Installed Version | 1.11.3 Stage | running Available Repositories | 851 Installed Repositories | 29AccuWeather
can_reach_server | ok -- | -- remaining_requests | 11Home Assistant Cloud
logged_in | true -- | -- subscription_expiration | 19 April 2021, 1:00 relayer_connected | true remote_enabled | true remote_connected | true alexa_enabled | false google_enabled | true can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | okHome Assistant Supervisor
host_os | Debian GNU/Linux 10 (buster) -- | -- update_channel | stable supervisor_version | supervisor-2021.03.9 docker_version | 20.10.5 disk_total | 458.6 GB disk_used | 113.9 GB healthy | true supported | true supervisor_api | ok version_api | ok installed_addons | AppDaemon 4 (0.5.1), File editor (5.2.0), Home Assistant Google Drive Backup (0.103.1), Mosquitto broker (5.1.1), RPC Shutdown (2.2), deCONZ (6.8.0), Node-RED (8.2.1)Lovelace
dashboards | 3 -- | -- resources | 18 views | 22 mode | storageSpotify
api_endpoint_reachable | ok -- | --