Mohlsson / ReplayLightsHistory

AppDaemon App for Home Assistant to replay light switch history when no one is home.
Apache License 2.0
29 stars 5 forks source link

Unexpected error loading module #14

Closed duckbert closed 4 years ago

duckbert commented 4 years ago

Hi, I love the idea of this app. Unfortunately, I am getting the following error message:

[cont-init.d] 00-banner.sh: exited 0. [cont-init.d] 01-log-level.sh: executing... [cont-init.d] 01-log-level.sh: exited 0. [cont-init.d] appdaemon.sh: executing... [cont-init.d] appdaemon.sh: exited 0. [cont-init.d] done. [services.d] starting services [services.d] done. [10:48:33] INFO: Starting AppDaemon... 2020-07-22 10:48:35.196105 INFO AppDaemon: AppDaemon Version 4.0.3 starting 2020-07-22 10:48:35.196556 INFO AppDaemon: Python version is 3.8.2 2020-07-22 10:48:35.197255 INFO AppDaemon: Configuration read from: /config/appdaemon/appdaemon.yaml 2020-07-22 10:48:35.197650 INFO AppDaemon: Added log: AppDaemon 2020-07-22 10:48:35.198434 INFO AppDaemon: Added log: Error 2020-07-22 10:48:35.199002 INFO AppDaemon: Added log: Access 2020-07-22 10:48:35.199654 INFO AppDaemon: Added log: Diag 2020-07-22 10:48:35.237130 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin 2020-07-22 10:48:35.278888 INFO HASS: HASS Plugin Initializing 2020-07-22 10:48:35.279491 INFO HASS: HASS Plugin initialization complete 2020-07-22 10:48:35.280744 INFO AppDaemon: Initializing HTTP 2020-07-22 10:48:35.281618 INFO AppDaemon: Using 'ws' for event stream 2020-07-22 10:48:35.306501 INFO AppDaemon: Starting API 2020-07-22 10:48:35.317222 INFO AppDaemon: Starting Admin Interface 2020-07-22 10:48:35.318121 INFO AppDaemon: Starting Dashboards 2020-07-22 10:48:35.361869 INFO HASS: Connected to Home Assistant 0.111.4 2020-07-22 10:48:35.393582 INFO AppDaemon: App 'hello_world' added 2020-07-22 10:48:35.394503 INFO AppDaemon: App 'replay_lights' added 2020-07-22 10:48:35.396178 INFO AppDaemon: Found 2 total apps 2020-07-22 10:48:35.397534 INFO AppDaemon: Starting Apps with 2 workers and 2 pins 2020-07-22 10:48:35.400464 INFO AppDaemon: Running on port 5050 2020-07-22 10:48:35.484919 INFO HASS: Evaluating startup conditions 2020-07-22 10:48:35.593965 INFO AppDaemon: Got initial state from namespace default 2020-07-22 10:48:37.412483 INFO AppDaemon: Scheduler running in realtime 2020-07-22 10:48:37.422165 INFO AppDaemon: Adding /config/appdaemon/apps to module import path 2020-07-22 10:48:37.424309 INFO AppDaemon: Adding /config/appdaemon/apps/ReplayLightsHistory to module import path 2020-07-22 10:48:37.432912 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/hello.py 2020-07-22 10:48:37.445561 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/ReplayLightsHistory/replay_lights.py 2020-07-22 10:48:37.449252 WARNING Error: ------------------------------------------------------------ 2020-07-22 10:48:37.450036 WARNING Error: Unexpected error loading module: /config/appdaemon/apps/ReplayLightsHistory/replay_lights.py: 2020-07-22 10:48:37.450718 WARNING Error: ------------------------------------------------------------ 2020-07-22 10:48:37.454897 WARNING Error: Traceback (most recent call last): File "/usr/lib/python3.8/site-packages/appdaemon/app_management.py", line 788, 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 276, 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 580, 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 "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 975, in _find_and_load_unlocked File "", line 671, in _load_unlocked File "", line 783, in exec_module File "", line 219, in _call_with_frames_removed File "/config/appdaemon/apps/ReplayLightsHistory/replay_lights.py", line 2, in import pymysql.cursors ModuleNotFoundError: No module named 'pymysql' 2020-07-22 10:48:37.455653 WARNING Error: ------------------------------------------------------------ 2020-07-22 10:48:37.456434 WARNING AppDaemon: Removing associated apps: 2020-07-22 10:48:37.457236 WARNING AppDaemon: replay_lights 2020-07-22 10:48:37.459037 INFO AppDaemon: Initializing app hello_world using class HelloWorld from module hello 2020-07-22 10:48:37.665768 INFO hello_world: Hello from AppDaemon 2020-07-22 10:48:37.668199 INFO hello_world: You are now ready to run Apps! 2020-07-22 10:48:37.671634 INFO AppDaemon: App initialization complete

My config is as follows: replay_lights: databaseType: MariaDB databaseUser: "homeassistant" databasePassword: "C4=yntAx" module: replay_lights class: ReplayLights numberOfDaysBack: 7 deviceType: "light" enableTag: "input_boolean.light_replay_enabled" enableVal: "on" smartControlledByDumb: "light.bad_spot_1_2,light.bad_spot_2_2,light.bad_spot_3_2,light.buro_spot_1_2,light.buro_spot_2_2,light.buro_spot_3_2,light.buro_spot_4_2,light.elternlicht_2,light.esstischlampe_2,light.flur_spot_1_2,light.flur_spot_2_2,light.flur_spot_3_2,light.flur_spot_4_2,light.flur_spot_5_2,light.hue_ambiance_panel_1_2,light.hue_lightstrip_outdoor_1_2,light.hue_outdoor_spot_1_2,light.hue_outdoor_spot_2_2,light.insel_spot_1_2,light.insel_spot_2_2,light.kinderzimmerlampe_2,light.kinderzimmerlicht,light.kuchen_spot_1_2,light.kuchen_spot_2_2,light.kuchen_spot_3_2,light.kuchen_spot_4_2,light.kuchen_spot_5_2,light.stehlampe_2,light.treppenlicht_2,light.vorplatzlicht_1_2,light.vorplatzlicht_2_2,light.vorplatzlicht_3_2,light.wohnzimmerlampe_2" excludeList: "light.aussen,light.badezimmer,light.buero,light.carport,light.dachgeschoss,light.deck,light.elternschlafzimmer,light.entree,light.entree_spot_1_2,light.entree_spot_2_2,light.erdgeschoss,light.esszimmer,light.haus,light.kellerflur,light.kellertreppe,light.kinderschlafzimmer,light.kuche"

0n3man commented 4 years ago

The application by default assumes you're using sqlite3 as your database. Someone added code to include support for MariaDB however they didn't include instructions on how to add the additional modules into appdaemon. As it turns out the home assistant team moved the the location of the history data in the database so the application is broke. I just made some changes that pull the information from the new location. When I did this I got the same error you received about the missing module. While I don't use MariaDB I'm trying to see if I can figure out where to include the required modules in the Home Assistant configuration. If I figure it out I'll post you an update. If I don't figure it out I'll just submit the change with the MariaDB code commented out. At which point hopefully whoever added the MariaDB change will provide the additional details.

0n3man commented 4 years ago

So to address the issue you need to modify your addons.json file that's in the base directory for home assistant. On my supervised install of home assistant this is /use/share/hassio/addons.json. If you search for packages you should find this section:

''' "options": { "system_packages": [], "python_packages": [], "init_commands": [] },

''' You need to add in PyMySQL as shown below ''' "options": { "system_packages": [], "python_packages": [ "PyMySQL" ], "init_commands": [] },

''' At which point I rebooted to get HA to update the appdaemon docker container and include the PyMySQL package.

duckbert commented 4 years ago

Thank you for taking care of this so quickly. Adding PyMySQL fixed the issues that I had. I am currently testing the replay with my lights and everything seems to run smoothly. Great work and fantastic add-on