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

Error #28

Open Axydas opened 1 year ago

Axydas commented 1 year ago

Somebody can help me please? I am getting the below error when i start the AppDeamon:

2023-01-05 14:49:48.246531 INFO replay_lights: started 2023-01-05 14:49:48.247819 INFO replay_lights: Defaulting Home Assistant config directory to /config 2023-01-05 14:49:48.250710 INFO AppDaemon: App initialization complete 2023-01-05 14:49:53.004592 INFO replay_lights: Scheduling Replaying 7 day[s] back 2023-01-05 14:49:53.004849 WARNING replay_lights: ------------------------------------------------------------ 2023-01-05 14:49:53.005069 WARNING replay_lights: Unexpected error in worker for App replay_lights: 2023-01-05 14:49:53.005288 WARNING replay_lights: Worker Ags: {'id': '48ab0c12ac2b4fa194a248c1c9b4f5bc', 'name': 'replay_lights', 'objectid': '002323eb3a384000ac83a6d57d6750dd', 'type': 'scheduler', 'function': <bound method ReplayLights.scheduleNextEventBatch of <replay_lights.ReplayLights object at 0x7f777cfcf610>>, 'pin_app': True, 'pin_thread': 5, 'kwargs': {'interval': 3600, '__thread_id': 'thread-5'}} 2023-01-05 14:49:53.005537 WARNING replay_lights: ------------------------------------------------------------ 2023-01-05 14:49:53.006016 WARNING replay_lights: Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/appdaemon/threading.py", line 904, in worker funcref(self.AD.sched.sanitize_timer_kwargs(app, args["kwargs"])) File "/config/appdaemon/apps/ReplayLightsHistory/replay_lights.py", line 108, in scheduleNextEventBatch for entity_id, event_new_state, c_date in result: UnboundLocalError: local variable 'result' referenced before assignment 2023-01-05 14:49:53.006220 WARNING replay_lights: ------------------------------------------------------------

Mohlsson commented 1 year ago

Sorry about the delay. The error indicates that replay lights cant find your database type or has an error when reading the database. Have you configured replay_lights correctly in appdaemon/apps/apps.yaml. The log should include "Defaulting Database...". Check that databaseType is sqlite3 or MariaDB.

Axydas commented 1 year ago

Yes i am using mariaDB

Here is my configuration:

replay_lights:

hassDir: '/home/jondoe/.homeassistant'

databaseType: mariadb databaseHost: "localhost" databaseUser: "xxxxxx" databasePassword: "xxxxxx" databaseSchema: "xxx***xxx" module: replay_lights class: ReplayLights numberOfDaysBack: 7 deviceType: "light" enableTag: "binary_sensor.alarm_status" enableVal: "on"

smartControlledByDumb: "switch.master_bed,switch.living_room_lamp"

excludeList: "light.office_light_lt,light.second_room_lamp_lt,light.third_room_lamp_lt"

Axydas commented 1 year ago

Update after a small change. I change the databaseType to MariaDB (case sensitive) and now i am getting a different error:

2023-01-23 10:36:41.071328 INFO replay_lights: started 2023-01-23 10:36:41.072118 INFO replay_lights: Defaulting Home Assistant config directory to /config 2023-01-23 10:36:41.074051 INFO AppDaemon: App initialization complete 2023-01-23 10:36:46.004967 INFO replay_lights: Scheduling Replaying 7 day[s] back 2023-01-23 10:36:46.006934 WARNING replay_lights: ------------------------------------------------------------ 2023-01-23 10:36:46.007281 WARNING replay_lights: Unexpected error in worker for App replay_lights: 2023-01-23 10:36:46.007618 WARNING replay_lights: Worker Ags: {'id': 'eaef5ac332ad4b0b80f052a744c1f592', 'name': 'replay_lights', 'objectid': '82b2c61c56d441c9bf1cb88b5e269252', 'type': 'scheduler', 'function': <bound method ReplayLights.scheduleNextEventBatch of <replay_lights.ReplayLights object at 0x7efea75be980>>, 'pin_app': True, 'pin_thread': 5, 'kwargs': {'interval': 3600, '__thread_id': 'thread-5'}} 2023-01-23 10:36:46.007929 WARNING replay_lights: ------------------------------------------------------------ 2023-01-23 10:36:46.008431 WARNING replay_lights: Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/pymysql/connections.py", line 613, in connect sock = socket.create_connection( File "/usr/lib/python3.10/socket.py", line 845, in create_connection raise err File "/usr/lib/python3.10/socket.py", line 833, in create_connection sock.connect(sa) OSError: [Errno 99] Address not available During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/appdaemon/threading.py", line 904, in worker funcref(self.AD.sched.sanitize_timer_kwargs(app, args["kwargs"])) File "/config/appdaemon/apps/ReplayLightsHistory/replay_lights.py", line 99, in scheduleNextEventBatch conn = pymysql.connect(host=self.databaseHost, user=self.databaseUser, password=self.databasePassword, db=self.databaseSchema, charset='utf8') File "/usr/lib/python3.10/site-packages/pymysql/connections.py", line 353, in init self.connect() File "/usr/lib/python3.10/site-packages/pymysql/connections.py", line 664, in connect raise exc pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 99] Address not available)") 2023-01-23 10:36:46.008725 WARNING replay_lights: ------------------------------------------------------------

xkill commented 7 months ago

Update after a small change. I change the databaseType to MariaDB (case sensitive) and now i am getting a different error:

2023-01-23 10:36:41.071328 INFO replay_lights: started 2023-01-23 10:36:41.072118 INFO replay_lights: Defaulting Home Assistant config directory to /config 2023-01-23 10:36:41.074051 INFO AppDaemon: App initialization complete 2023-01-23 10:36:46.004967 INFO replay_lights: Scheduling Replaying 7 day[s] back 2023-01-23 10:36:46.006934 WARNING replay_lights: ------------------------------------------------------------ 2023-01-23 10:36:46.007281 WARNING replay_lights: Unexpected error in worker for App replay_lights: 2023-01-23 10:36:46.007618 WARNING replay_lights: Worker Ags: {'id': 'eaef5ac332ad4b0b80f052a744c1f592', 'name': 'replay_lights', 'objectid': '82b2c61c56d441c9bf1cb88b5e269252', 'type': 'scheduler', 'function': <bound method ReplayLights.scheduleNextEventBatch of <replay_lights.ReplayLights object at 0x7efea75be980>>, 'pin_app': True, 'pin_thread': 5, 'kwargs': {'interval': 3600, '__thread_id': 'thread-5'}} 2023-01-23 10:36:46.007929 WARNING replay_lights: ------------------------------------------------------------ 2023-01-23 10:36:46.008431 WARNING replay_lights: Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/pymysql/connections.py", line 613, in connect sock = socket.create_connection( File "/usr/lib/python3.10/socket.py", line 845, in create_connection raise err File "/usr/lib/python3.10/socket.py", line 833, in create_connection sock.connect(sa) OSError: [Errno 99] Address not available During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/appdaemon/threading.py", line 904, in worker funcref(self.AD.sched.sanitize_timer_kwargs(app, args["kwargs"])) File "/config/appdaemon/apps/ReplayLightsHistory/replay_lights.py", line 99, in scheduleNextEventBatch conn = pymysql.connect(host=self.databaseHost, user=self.databaseUser, password=self.databasePassword, db=self.databaseSchema, charset='utf8') File "/usr/lib/python3.10/site-packages/pymysql/connections.py", line 353, in init self.connect() File "/usr/lib/python3.10/site-packages/pymysql/connections.py", line 664, in connect raise exc pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 99] Address not available)") 2023-01-23 10:36:46.008725 WARNING replay_lights: ------------------------------------------------------------

Seems that the appdaemon cannot connect to the MariaDB service.