Run_in, run_at & run_daily never running

I’ve had this problem for a long time, but have avoided it like the plague just using create_task & sleep(), but is now becoming too much hassle to avoid just using the features AppDaemon already has. My callbacks are structured accordingly to the scheduler callbacks, but the mentioned methods in the title never actually execute the callbacks.

class Tod(hass.Hass):

    def initialize(self):
        self.log("initializing ...")
            self.log(f'args: {self.args}')
            # required args
            self._night_input = self.args['night_input']
            self._mode = self.args['mode_input']
            # optional args
            self._evening_start = self.args.get('evening_start', self.rpltime(hour=20, minute=30))
            self._morning_start = self.args.get('morning_start', self.rpltime(hour=4))
            self._day_start = self.args.get('day_start', self.rpltime(hour=8))
            # handlers
            h = self.run_in(self.mode_cb, 5) # this is merely for testing, but as with run_daily, 
            # it's never run. The log call is never called, and alas here I am.
            self._tod_handle = self.run_daily(self.mode_cb, "00:00:01")
            self._night_handle = self.listen_state(self.night_cb, self._night_input, new='on')
            self._morning_handle = None
            self._day_handle = None
            self._evening_handle = None
            # last registered goodnight
            self._night_trigger_time = None
            self.log(f'handle: {self.info_timer(h)}')
        except (TypeError, ValueError) as e:
            self.log('Incomplete configuration', level="ERROR")
            raise e

    def mode_cb(self, kwargs):
        self.create_task(self.mode_cb_run(tod=self._morning_start, mode='morning'))
        self.create_task(self.mode_cb_run(tod=self._day_start, mode='day'))
        self.create_task(self.mode_cb_run(tod=self._evening_start, mode='evening'))

The reason for this is that my modes change depending on a lot of factors, such as sunset/sunrise with limits, if I have work to do etc.
Ive tried all kinds of setups, giving run_at specific datetime, run_in with seconds till the callback is supposed to be called and much more.
I cant even get run_daily to work. Ive resorted to HomeAssistant flipping an input_boolean once a day, which will then create the tasks, but I dont think I should have to resort to this.

Any errors in the logs?

No, not at all… Just nothing in the log. It never even enters the callback.

Does the log show initialize running? Could you post the log please?

I’ve changed a lot on my code to avoid the problem, I’ll see what I can do when I have the time to change it back.

I would take the try block out of the initialize statement or at least only make parts of the initialize statement a try except block. If your app doesn’t initialize at all it won’t run so better to let it crash and give you the error report.

You might also try adding

except Exception as Error:
  self.log(f'__function__: {Error}', level='ERROR')


except Exception as e:
  self.error(f'{e}', level='WARNING')

After your first except catch if you really want it to keep going. I use this alot for critical apps.

Sorry, let me paraphrase. The app is/was initializing, without errors. Sometimes the callback will run, but it will only happen when I restart AD completely. It will then enter the callback, but after soft reloads or scheduler callbacks, it wont (at least not displayed in the logs, and yes I have log_threads: 1). I’ve monitored the run_daily callbacks as well, after multiple days it has fired a total of 0 times. I’ll try and recreate my code once I have the time.