appdaemon icon indicating copy to clipboard operation
appdaemon copied to clipboard

run_daily does not work..

Open hhaim opened this issue 7 months ago • 7 comments

What happened?

does now work in 4.x and works in 3.0.5

        self.run_daily(self._cb_event, 
                       self.parse_time("16:50:00"), 
                       constrain_days=ada.schedule.day_of_week(5),
                       a="1",b="2")

does now work in 4.x and works in 3.0.5

     self.run_daily(self._cb_event, 
                       self.parse_time("16:50:00"), 
                       a="1",b="2")

back to 3.0.5

Version

4.5.11

Installation type

Docker container

Relevant log output


Relevant code in the app or config file that caused the issue


Anything else?

No response

hhaim avatar Jul 03 '25 13:07 hhaim

What happens? I'm using run_daily without problem. The function you have is: def _cb_event(self, a, b): ?

or maybe:

def _cb_event(self, myArgs): 
    a, b = myArgs['a'],  myArgs['b']

?

Idk if it matters, but in appdaemon.yaml I use

appdaemon:
  use_dictionary_unpacking: true

If you can provide errors you have maybe we can find the problem

brazoayeye avatar Jul 09 '25 09:07 brazoayeye

global configuration

  production_mode: true # to solve the very high cpu%% not sure why???
  pin_threads: 1
  threadpool_workers: 1

the apps yaml https://github.com/hhaim/hass/blob/7573ba9afd090bba9656f7bcdd541b10025e5f0f/cfg/hass/apps/apps.yaml#L155

test_days:
  module: heat_app
  class: CTestDays

the code https://github.com/hhaim/hass/blob/7573ba9afd090bba9656f7bcdd541b10025e5f0f/cfg/hass/apps/heat_app.py#L103

I have changed the hours and days to now+2 min, waits 2 min and there is no trigger.


# from another pkgs 
def day_of_week(day:int):
    """day in format of 1-7 1 is sunday to saturday"""
    nums = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]
    if type(day) == int:
        return nums[day-1]
    raise ValueError("Incorrect type for 'day' in day_of_week()'")

class CTestDays(hass.Hass):

    def initialize(self):
        self.log("start CTestDays");
        self.run_daily(self._cb_event, 
                       self.parse_time("16:50:00"), 
                       constrain_days=ada.schedule.day_of_week(5), # 1 is "sun" see the function 
                       a="1",b="2")

        self.run_daily(self._cb_event, 
                       self.parse_time("16:50:00"), 
                       constrain_days=ada.schedule.day_of_week(5),
                       a="3",b="4")

    def _cb_event(self,kwargs):
        """ kwargs include 
           rule=rule
           state=on/off 
        """
        self.log(" event {0} ".format(kwargs))

it works fine with 3.0.5, I don't know if there are more issues

expected result a log with 1,2 in the now+2 min. nothing is trigger. the log time is correct

hhaim avatar Jul 09 '25 11:07 hhaim

one more thing, event when removing constrain_days=ada.schedule.day_of_week(5), # 1 is "sun" see the function I don't get the trigger

hhaim avatar Jul 09 '25 11:07 hhaim

I have another problem: first call is right but others are 1h42m after. Maybe that bug could cause you to delay much more your call?

In the log you see the "start CTestDays" but nothing more? Even after 1 day? Try with run_daily(self._cb_event, datetime.time(16, 50, 0), a="1",b="2") or without parameters a, b

I really don't know how to help

brazoayeye avatar Jul 09 '25 11:07 brazoayeye

@brazoayeye, thanks for looking into it and corroborating that there is an issue in v4.5.11 . In 3.0.5, all events are accurate at the time. 1h42m delay is not acceptable in my case.

hhaim avatar Jul 09 '25 13:07 hhaim

We are tracking this issue and working on some refactoring of the scheduler API along with some automated testing. It will be a short while to get this in place but we are working on it.

acockburn avatar Jul 09 '25 14:07 acockburn

This is likely due to broken timezone handling in how AppDaemon uses pytz. See my comment on #2400.

cederlys avatar Sep 10 '25 13:09 cederlys

Should be fixed by #2515

cebtenzzre avatar Dec 28 '25 20:12 cebtenzzre

Basic tests works .. let's check it in prod for a few weeks

hhaim avatar Dec 31 '25 10:12 hhaim

ok, this issue solved but I still have 3.x->4.x issues I will open as new

hhaim avatar Jan 01 '26 08:01 hhaim