HABApp: Events vs. job control

Many of my rules are executed regularly @ 1 minute. So i created a number item “Time”, which has the current time (hhmm) and is changed every minute by job control (timer).
The rules depending on time can now register the “on change event” of this “Time” item. This works. However, I some times get warnings like this:

[2025-10-19 09:41:03,306] [            HABApp.Worker]  WARNING | Starting of WindMax._OnUpdateTime took too long: 0.05s. Maybe there are not enough threads?[2025-10-19 09:41:03,308] [            HABApp.Worker]  WARNING | Starting of MultiSwitchFlag._OnUpdateTime took too long: 0.05s. Maybe there are not enough threads?[2025-10-19 09:41:03,309] [            HABApp.Worker]  WARNING | Starting of OverrideSwitches._OnUpdateTime took too long: 0.05s. Maybe there are not enough threads?[2025-10-19 09:41:03,313] [            HABApp.Worker]  WARNING | Starting of TaBlindSwitchHandler._OnUpdateTime took too long: 0.06s. Maybe there are not enough threads?[2025-10-19 09:41:03,313] [            HABApp.Worker]  WARNING | Starting of Breakfast._RunEveryMinute took too long: 0.06s. Maybe there are not enough threads?[2025-10-19 09:41:03,313] [            HABApp.Worker]  WARNING | Starting of EntranceLight._OnChangeTime took too long: 0.06s. Maybe there are not enough threads?[2025-10-19 09:41:03,313] [            HABApp.Worker]  WARNING | Starting of Presence._RunEveryMinute took too long: 0.06s. Maybe there are not enough threads?[2025-10-19 09:41:03,320] [            HABApp.Worker]  WARNING | Starting of BurglarLight._RunEveryMinute took too long: 0.06s. Maybe there are not enough threads?[2025-10-19 09:41:03,322] [            HABApp.Worker]  WARNING | Starting of StairsUpperFloor._OnChangeTime took too long: 0.07s. Maybe there are not enough threads?[2025-10-19 09:41:03,323] [            HABApp.Worker]  WARNING | Starting of StairsLowerFloor._OnChangeTime took too long: 0.07s. Maybe there are not enough threads? 

The other implementation i could imagine is, that every time depending rule gets its own 1 minute job control. Of some rules, i create multiple instances (up to a dozen). So I guess, this would need more resources.

What is the preferred way?

Use the scheduler in every rule instance, e.g.

class MyRule(Rule):
    def __init__(self):
        super().__init__()
        self.run.at(self.run.trigger.interval(None, 60), self.my_func)
    def my_func(self):
        ....

It’s all pretty lightweight, it doesn’t really matter. The scheduling happens in the event loop which is quite optimized.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.