AppDaemon / appdaemon

:page_facing_up: Python Apps for Home Automation
Other
849 stars 418 forks source link

Priority issue - Apps not respecting priority #561

Closed ConnorGriffin closed 5 years ago

ConnorGriffin commented 5 years ago

I am having an issue where my app priority doesn't seem to be respected.

I have two apps, one that installs prerequisite python packages (install_dependencies), and one that imports one of those packages (cox_usage).

The apps are configured as follows:

install_dependencies:
  module: install_deps
  class: InstallDeps
  priority: 0
  packages:
    - lxml
    - responses
    - mechanicalsoup

cox_usage:
  module: cox_usage
  class: CoxUsage
  priority: 99

Every time I recreate my docker container I have to comment out the cox_usage module, allow install_dependencies to complete, and then uncomment cox_usage. If i don't do this, AppDaemon gets stuck in a constant boot loop because cox_usage fails to load due to a ModuleNotFoundError. I have the exact same problem if I add install_dependencies as a dependency to the cox_usage app, so that's not a solution either.

My understanding is that install_dependencies should run first, but it does not.

I was able to remedy this in my testing by renaming install_dependencies to aaa_install_dependencies so that it runs first.

Odianosen25 commented 5 years ago

Hello @ConnorGriffin,

Can you post your AD startup logs please?

Regards

ConnorGriffin commented 5 years ago

appdaemon.log

2019-05-08 09:52:36.673804 INFO AppDaemon Version 3.0.5 starting
2019-05-08 09:52:36.674090 INFO Configuration read from: /conf/appdaemon.yaml
2019-05-08 09:52:36.675913 INFO AppDaemon: Starting Apps
2019-05-08 09:52:36.681838 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2019-05-08 09:52:36.738531 INFO AppDaemon: HASS: HASS Plugin Initializing
2019-05-08 09:52:36.738917 INFO AppDaemon: HASS: HASS Plugin initialization complete
2019-05-08 09:52:36.739119 INFO Starting Dashboards
2019-05-08 09:52:36.743615 INFO Starting API
2019-05-08 09:52:36.851021 INFO AppDaemon: HASS: Connected to Home Assistant 0.92.2
2019-05-08 09:52:36.922944 INFO AppDaemon: Got initial state from namespace default
2019-05-08 09:52:38.866190 INFO AppDaemon: Reading config
2019-05-08 09:52:38.902231 WARNING AppDaemon: File '/conf/apps/template_sensors/template_sensors.yaml' invalid structure - ignoring
2019-05-08 09:52:38.910086 INFO AppDaemon: /conf/apps/apps.yaml added or modified
2019-05-08 09:52:38.910213 INFO AppDaemon: /conf/apps/lighting/lighting.yaml added or modified
2019-05-08 09:52:38.910297 INFO AppDaemon: /conf/apps/climate/climate.yaml added or modified
2019-05-08 09:52:38.910373 INFO AppDaemon: /conf/apps/utility/utility.yaml added or modified
2019-05-08 09:52:38.910448 INFO AppDaemon: /conf/apps/media/media.yaml added or modified
2019-05-08 09:52:38.910522 INFO AppDaemon: /conf/apps/template_sensors/template_sensors.yaml added or modified
2019-05-08 09:52:38.910594 INFO AppDaemon: /conf/apps/cox_usage/cox_usage.yaml added or modified
2019-05-08 09:52:38.910667 INFO AppDaemon: /conf/apps/security/security.yaml added or modified
2019-05-08 09:52:38.910750 INFO AppDaemon: /conf/apps/apps.yaml added or modified
2019-05-08 09:52:38.910827 INFO AppDaemon: /conf/apps/lighting/lighting.yaml added or modified
2019-05-08 09:52:38.910907 INFO AppDaemon: /conf/apps/climate/climate.yaml added or modified
2019-05-08 09:52:38.910983 INFO AppDaemon: /conf/apps/utility/utility.yaml added or modified
2019-05-08 09:52:38.911065 INFO AppDaemon: /conf/apps/media/media.yaml added or modified
2019-05-08 09:52:38.911139 INFO AppDaemon: /conf/apps/template_sensors/template_sensors.yaml added or modified
2019-05-08 09:52:38.911212 INFO AppDaemon: /conf/apps/cox_usage/cox_usage.yaml added or modified
2019-05-08 09:52:38.911284 INFO AppDaemon: /conf/apps/security/security.yaml added or modified
2019-05-08 09:52:38.911358 INFO AppDaemon: App 'lights' added
2019-05-08 09:52:38.911432 INFO AppDaemon: App 'welcome_home_lighting' added
2019-05-08 09:52:38.911506 INFO AppDaemon: App 'alarm_clock' added
2019-05-08 09:52:38.911579 INFO AppDaemon: App 'christmas_tree_lights' added
2019-05-08 09:52:38.911682 INFO AppDaemon: App 'ecobee' added
2019-05-08 09:52:38.911772 INFO AppDaemon: App 'door_window_climate' added
2019-05-08 09:52:38.911850 INFO AppDaemon: App 'bathroom_vent' added
2019-05-08 09:52:38.911935 INFO AppDaemon: App 'space_heaters' added
2019-05-08 09:52:38.912010 INFO AppDaemon: App 'install_dependencies' added
2019-05-08 09:52:38.912083 INFO AppDaemon: App 'low_battery_alert' added
2019-05-08 09:52:38.912157 INFO AppDaemon: App 'roku_power_control' added
2019-05-08 09:52:38.912230 INFO AppDaemon: App 'projector_switch' added
2019-05-08 09:52:38.912304 INFO AppDaemon: App 'receiver_volume' added
2019-05-08 09:52:38.912377 INFO AppDaemon: App 'nhl_autoplay' added
2019-05-08 09:52:38.912450 INFO AppDaemon: App 'cox_usage' added
2019-05-08 09:52:38.912523 INFO AppDaemon: App 'door_auto_lock' added
2019-05-08 09:52:38.912596 INFO AppDaemon: App 'home_security' added
2019-05-08 09:52:38.912669 INFO AppDaemon: App 'door_auto_unlock' added
2019-05-08 09:52:38.912824 INFO AppDaemon: Adding /conf/apps to module import path
2019-05-08 09:52:38.912989 INFO AppDaemon: Adding /conf/apps/lighting to module import path
2019-05-08 09:52:38.913136 INFO AppDaemon: Adding /conf/apps/climate to module import path
2019-05-08 09:52:38.913277 INFO AppDaemon: Adding /conf/apps/utility to module import path
2019-05-08 09:52:38.913413 INFO AppDaemon: Adding /conf/apps/media to module import path
2019-05-08 09:52:38.913634 INFO AppDaemon: Adding /conf/apps/template_sensors to module import path
2019-05-08 09:52:38.913791 INFO AppDaemon: Adding /conf/apps/cox_usage to module import path
2019-05-08 09:52:38.913935 INFO AppDaemon: Adding /conf/apps/security to module import path
2019-05-08 09:52:38.915926 INFO AppDaemon: Loading Global Module: /conf/apps/helpers.py
2019-05-08 09:52:38.920857 INFO AppDaemon: Loading App Module: /conf/apps/lighting/christmas_lights.py
2019-05-08 09:52:38.921410 INFO AppDaemon: Loading App Module: /conf/apps/lighting/alarm_clock.py
2019-05-08 09:52:38.921888 INFO AppDaemon: Loading App Module: /conf/apps/lighting/lights.py
2019-05-08 09:52:38.922435 INFO AppDaemon: Loading App Module: /conf/apps/lighting/welcome_home_lighting.py
2019-05-08 09:52:38.922899 WARNING AppDaemon: No app description found for: /conf/apps/lighting/light_flash.py - ignoring
2019-05-08 09:52:38.923014 INFO AppDaemon: Loading App Module: /conf/apps/climate/ecobee.py
2019-05-08 09:52:38.923433 INFO AppDaemon: Loading App Module: /conf/apps/climate/space_heaters.py
2019-05-08 09:52:38.923873 INFO AppDaemon: Loading App Module: /conf/apps/climate/bathroom_vent.py
2019-05-08 09:52:38.924312 WARNING AppDaemon: No app description found for: /conf/apps/climate/space_heater.py - ignoring
2019-05-08 09:52:38.924429 INFO AppDaemon: Loading App Module: /conf/apps/climate/door_window_climate.py
2019-05-08 09:52:38.924843 INFO AppDaemon: Loading App Module: /conf/apps/utility/install_deps.py
2019-05-08 09:52:38.925237 INFO AppDaemon: Loading App Module: /conf/apps/utility/battery.py
2019-05-08 09:52:38.925668 WARNING AppDaemon: No app description found for: /conf/apps/media/media_power.py - ignoring
2019-05-08 09:52:38.925776 INFO AppDaemon: Loading App Module: /conf/apps/media/nhl_autoplay.py
2019-05-08 09:52:38.926209 INFO AppDaemon: Loading App Module: /conf/apps/media/hdmi_control.py
2019-05-08 09:52:38.926693 WARNING AppDaemon: No app description found for: /conf/apps/template_sensors/template_sensor.py - ignoring
2019-05-08 09:52:38.926801 INFO AppDaemon: Loading App Module: /conf/apps/cox_usage/cox_usage.py
2019-05-08 09:52:38.929071 WARNING AppDaemon: Removing associated apps:
2019-05-08 09:52:38.929482 WARNING ------------------------------------------------------------
2019-05-08 09:52:38.929590 WARNING Unexpected error during run()
2019-05-08 09:52:38.929670 WARNING ------------------------------------------------------------
2019-05-08 09:52:38.930892 WARNING Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 2026, in check_app_updates
    self.read_app(mod["name"], mod["reload"])
  File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1809, in read_app
    self.modules[module_name] = importlib.import_module(module_name)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/conf/apps/cox_usage/cox_usage.py", line 14, in <module>
    import mechanicalsoup
ModuleNotFoundError: No module named 'mechanicalsoup'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/appdaemon/admain.py", line 105, in run
    loop.run_until_complete(asyncio.gather(*pending))
  File "/usr/local/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1402, in utility
    await utils.run_in_executor(self.loop, self.executor, self.check_app_updates)
  File "/usr/local/lib/python3.6/site-packages/appdaemon/utils.py", line 125, in run_in_executor
    response = list(completed)[0].result()
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 2038, in check_app_updates
    if self.app_config[app]["module"] == module:
TypeError: list indices must be integers or slices, not str

2019-05-08 09:52:38.931001 WARNING ------------------------------------------------------------
2019-05-08 09:52:38.931113 INFO AppDeamon Exited

error.log

2019-05-08 09:41:35.637169 WARNING AppDaemon: ------------------------------------------------------------
2019-05-08 09:41:35.638573 WARNING AppDaemon: Unexpected error loading module: /conf/apps/cox_usage/cox_usage.py:
2019-05-08 09:41:35.638711 WARNING AppDaemon: ------------------------------------------------------------
2019-05-08 09:41:35.654921 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 2026, in check_app_updates
    self.read_app(mod["name"], mod["reload"])
  File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1809, in read_app
    self.modules[module_name] = importlib.import_module(module_name)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/conf/apps/cox_usage/cox_usage.py", line 14, in <module>
    import mechanicalsoup
ModuleNotFoundError: No module named 'mechanicalsoup'

2019-05-08 09:41:35.655135 WARNING AppDaemon: ------------------------------------------------------------
2019-05-08 09:41:44.638520 WARNING AppDaemon: ------------------------------------------------------------
2019-05-08 09:41:44.638648 WARNING AppDaemon: Unexpected error loading module: /conf/apps/cox_usage/cox_usage.py:
2019-05-08 09:41:44.638782 WARNING AppDaemon: ------------------------------------------------------------
2019-05-08 09:41:44.640112 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 2026, in check_app_updates
    self.read_app(mod["name"], mod["reload"])
  File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1809, in read_app
    self.modules[module_name] = importlib.import_module(module_name)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/conf/apps/cox_usage/cox_usage.py", line 14, in <module>
    import mechanicalsoup
ModuleNotFoundError: No module named 'mechanicalsoup'

2019-05-08 09:41:44.640278 WARNING AppDaemon: ------------------------------------------------------------
^C
cgriffin@hass:~$ sudo rm -f/docker/homeassistant/appdaemon/logs/error.log 
[sudo] password for cgriffin: 
cgriffin@hass:~$ sudo rm -f /docker/homeassistant/appdaemon/logs/error.log 
[sudo] password for cgriffin: 
cgriffin@hass:~$ tail -f /docker/homeassistant/appdaemon/logs/error.log -n 0
tail: cannot open '/docker/homeassistant/appdaemon/logs/error.log' for reading: No such file or directory
tail: no files remaining
cgriffin@hass:~$ tail -f /docker/homeassistant/appdaemon/logs/error.log 
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/conf/apps/cox_usage/cox_usage.py", line 14, in <module>
    import mechanicalsoup
ModuleNotFoundError: No module named 'mechanicalsoup'

2019-05-08 09:52:38.928974 WARNING AppDaemon: ------------------------------------------------------------
^C
cgriffin@hass:~$ cat /docker/homeassistant/appdaemon/logs/error.log 
2019-05-08 09:52:38.927453 WARNING AppDaemon: ------------------------------------------------------------
2019-05-08 09:52:38.927576 WARNING AppDaemon: Unexpected error loading module: /conf/apps/cox_usage/cox_usage.py:
2019-05-08 09:52:38.927687 WARNING AppDaemon: ------------------------------------------------------------
2019-05-08 09:52:38.928871 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 2026, in check_app_updates
    self.read_app(mod["name"], mod["reload"])
  File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1809, in read_app
    self.modules[module_name] = importlib.import_module(module_name)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/conf/apps/cox_usage/cox_usage.py", line 14, in <module>
    import mechanicalsoup
ModuleNotFoundError: No module named 'mechanicalsoup'

2019-05-08 09:52:38.928974 WARNING AppDaemon: ------------------------------------------------------------
2019-05-08 09:52:44.405961 WARNING AppDaemon: ------------------------------------------------------------
2019-05-08 09:52:44.406063 WARNING AppDaemon: Unexpected error loading module: /conf/apps/cox_usage/cox_usage.py:
2019-05-08 09:52:44.406150 WARNING AppDaemon: ------------------------------------------------------------
2019-05-08 09:52:44.407341 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 2026, in check_app_updates
    self.read_app(mod["name"], mod["reload"])
  File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1809, in read_app
    self.modules[module_name] = importlib.import_module(module_name)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/conf/apps/cox_usage/cox_usage.py", line 14, in <module>
    import mechanicalsoup
ModuleNotFoundError: No module named 'mechanicalsoup'

2019-05-08 09:52:44.407443 WARNING AppDaemon: ------------------------------------------------------------
ConnorGriffin commented 5 years ago

I had duplicate config files declaring the same apps, and one of them did not have the priority data. Cleared that up, everything is good now. Sorry for the trouble guys!