appdaemon
appdaemon copied to clipboard
Docs for run_at say it needs a datetime.time object for start but code requires a datetime.datetime object
Current docs state that the start should be either a time or parse_time object.
Code:
start_time = self.get_state('input_datetime.test_entity')
start_time = self.parse_time(start_time)
self.log(f'Start time: {start_time}; type {type(start_time)}')
caller = self.run_at(self.Callback, start_time)
Logs:
today at 8:05:24 AM 2022-05-04 08:05:24.795167 INFO NewLock: Start time: 15:30:00, type of start: <class 'datetime.time'>
today at 8:05:24 AM 2022-05-04 08:05:24.797528 WARNING NewLock: ------------------------------------------------------------
today at 8:05:24 AM 2022-05-04 08:05:24.797613 WARNING NewLock: Unexpected error running initialize() for NewLock
today at 8:05:24 AM 2022-05-04 08:05:24.797675 WARNING NewLock: ------------------------------------------------------------
today at 8:05:24 AM 2022-05-04 08:05:24.797847 WARNING NewLock: Traceback (most recent call last):
today at 8:05:24 AM File "/usr/local/lib/python3.9/site-packages/appdaemon/app_management.py", line 165, in initialize_app
today at 8:05:24 AM await utils.run_in_executor(self, init)
today at 8:05:24 AM File "/usr/local/lib/python3.9/site-packages/appdaemon/utils.py", line 337, in run_in_executor
today at 8:05:24 AM response = future.result()
today at 8:05:24 AM File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run
today at 8:05:24 AM result = self.fn(*self.args, **self.kwargs)
today at 8:05:24 AM File "/conf/apps/lock/newlock.py", line 64, in initialize
today at 8:05:24 AM self.InitialGenerator()
today at 8:05:24 AM File "/conf/apps/lock/newlock.py", line 76, in InitialGenerator
today at 8:05:24 AM self.GenerateInitialCallers()
today at 8:05:24 AM File "/conf/apps/lock/newlock.py", line 241, in GenerateInitialCallers
today at 8:05:24 AM self.GenerateDailyCallers()
today at 8:05:24 AM File "/conf/apps/lock/newlock.py", line 258, in GenerateDailyCallers
today at 8:05:24 AM self.GenerateWeekdayCallers(item)
today at 8:05:24 AM File "/conf/apps/lock/newlock.py", line 295, in GenerateWeekdayCallers
today at 8:05:24 AM start_caller = self.run_at(self.EvaluateEnableCodeWrapper, i_start, code_slot = code_slot)
today at 8:05:24 AM File "/usr/local/lib/python3.9/site-packages/appdaemon/utils.py", line 226, in inner_sync_wrapper
today at 8:05:24 AM f = run_coroutine_threadsafe(self, coro(self, *args, **kwargs))
today at 8:05:24 AM File "/usr/local/lib/python3.9/site-packages/appdaemon/utils.py", line 346, in run_coroutine_threadsafe
today at 8:05:24 AM result = future.result(self.AD.internal_function_timeout)
today at 8:05:24 AM File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 445, in result
today at 8:05:24 AM return self.__get_result()
today at 8:05:24 AM File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 390, in __get_result
today at 8:05:24 AM raise self._exception
today at 8:05:24 AM File "/usr/local/lib/python3.9/site-packages/appdaemon/adapi.py", line 2510, in run_at
today at 8:05:24 AM raise ValueError("Invalid type for start")
today at 8:05:24 AM ValueError: Invalid type for start
today at 8:05:24 AM
today at 8:05:24 AM 2022-05-04 08:05:24.797928 WARNING NewLock: ------------------------------------------------------------
If I change start_time to a datetime.datetime object it will create the caller just fine.
The examples provided also seems to suggest that the object needs to be a datetime.datetime object, so it appears that only the parameters in the docs and in the code here need updating.