Hi,
Trying to set this code up but having an issue it seems with a connection? I am using the MariaDB addon, have the MySql listing the in the appdaemon config of the addon, default homeassistant. I am not sure if I have the right syntax for the hassDir of the yaml file, and /or do I use localhost as the databaseHost: or the docker ip?
Thanks
Appdeamon Config:
system_packages: []
python_packages:
- PyMySQL
init_commands: []
MariDB config:
databases:
- homeassistant
logins:
- username: homeassistant
password: xxxx
rights:
- username: homeassistant
database: homeassistant
Yaml for replay_lights:
replay_lights:
hassDir: ‘mysql://homeassistant:xxxx@core-mariadb/homeassistant?charset=utf8mb4’
databaseType: MariaDB
databaseHost: “172.30.33.7”
databaseUser: “homeassistant”
databasePassword: “xxxx”
databaseSchema: “homeassistant”
module: replay_lights
class: ReplayLights
numberOfDaysBack: 7
deviceType: “light”
enableTag: “input_boolean.holidays_ad”
enableVal: “on”
excludeList: “switch.garage_door_223,switch.coffee_745”
constrain_input_boolean: input_boolean.holidays_ad
Appdaemon Error Log:
> 2021-03-12 16:28:59.067772 WARNING replay_lights: ------------------------------------------------------------
> 2021-03-12 17:28:59.064922 WARNING replay_lights: ------------------------------------------------------------
> 2021-03-12 17:28:59.065061 WARNING replay_lights: Unexpected error in worker for App replay_lights:
> 2021-03-12 17:28:59.065203 WARNING replay_lights: Worker Ags: {'id': '3015ba52469846a3b0db4033592a8e2a', 'name': 'replay_lights', 'objectid': '273e7dd8ae054f7e93db53c25337a483', 'type': 'scheduler', 'function': <bound method ReplayLights.scheduleNextEventBatch of <replay_lights.ReplayLights object at 0x7fdb4117a8e0>>, 'pin_app': True, 'pin_thread': 61, 'kwargs': {'interval': 3600, '__thread_id': 'thread-61'}}
> 2021-03-12 17:28:59.065337 WARNING replay_lights: ------------------------------------------------------------
> 2021-03-12 17:28:59.065581 WARNING replay_lights: Traceback (most recent call last):
> File "/usr/lib/python3.8/site-packages/pymysql/connections.py", line 613, in connect
> sock = socket.create_connection(
> File "/usr/lib/python3.8/socket.py", line 808, in create_connection
> raise err
> File "/usr/lib/python3.8/socket.py", line 796, in create_connection
> sock.connect(sa)
> ConnectionRefusedError: [Errno 111] Connection refused
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
> File "/usr/lib/python3.8/site-packages/appdaemon/threading.py", line 887, in worker
> funcref(self.AD.sched.sanitize_timer_kwargs(app, args["kwargs"]))
> File "/config/appdaemon/apps/house_mode/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.8/site-packages/pymysql/connections.py", line 353, in __init__
> self.connect()
> File "/usr/lib/python3.8/site-packages/pymysql/connections.py", line 664, in connect
> raise exc
> pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on '172.30.33.7' ([Errno 111] Connection refused)")
>
> 2021-03-12 17:28:59.065715 WARNING replay_lights: ------------------------------------------------------------
> 2021-03-12 18:28:59.158521 WARNING replay_lights: ------------------------------------------------------------
> 2021-03-12 18:28:59.158716 WARNING replay_lights: Unexpected error in worker for App replay_lights:
> 2021-03-12 18:28:59.158937 WARNING replay_lights: Worker Ags: {'id': '3015ba52469846a3b0db4033592a8e2a', 'name': 'replay_lights', 'objectid': '273e7dd8ae054f7e93db53c25337a483', 'type': 'scheduler', 'function': <bound method ReplayLights.scheduleNextEventBatch of <replay_lights.ReplayLights object at 0x7fdb4117a8e0>>, 'pin_app': True, 'pin_thread': 61, 'kwargs': {'interval': 3600, '__thread_id': 'thread-61'}}
> 2021-03-12 18:28:59.159074 WARNING replay_lights: ------------------------------------------------------------
> 2021-03-12 18:28:59.160612 WARNING replay_lights: Traceback (most recent call last):
> File "/usr/lib/python3.8/site-packages/pymysql/connections.py", line 613, in connect
> sock = socket.create_connection(
> File "/usr/lib/python3.8/socket.py", line 808, in create_connection
> raise err
> File "/usr/lib/python3.8/socket.py", line 796, in create_connection
> sock.connect(sa)
> ConnectionRefusedError: [Errno 111] Connection refused
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
> File "/usr/lib/python3.8/site-packages/appdaemon/threading.py", line 887, in worker
> funcref(self.AD.sched.sanitize_timer_kwargs(app, args["kwargs"]))
> File "/config/appdaemon/apps/house_mode/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.8/site-packages/pymysql/connections.py", line 353, in __init__
> self.connect()
> File "/usr/lib/python3.8/site-packages/pymysql/connections.py", line 664, in connect
> raise exc
> pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on '172.30.33.7' ([Errno 111] Connection refused)")