Rule dependency?

I have a dependency on rule (get_rule) that gives an error during start-up/first execution, because the specific Rule has not yet been created. Is there a structure/functionality (wait for rule) intended for this use-case?

I tried putting the “get_rule” inside a try/except (with sleep(0.2) and some allowed attempts) with the intentions of suppressing the HABapp.log, but with same result.

Hmm work around. Think I understand that one should not put any code in the constructor “__init__” that might cause the constructor to no fully execute (like a get_rule that might not have been created). Then its better to let the scheaduler do the work ie a self.run.once(some-seconds, callback)

Not putting any logic in the constructor is very good. Rather schedule with self.run.soon(...).
Check this: Advanced Usage — HABApp beta documentation

1 Like