What is the best method to start executing the rules when all bindings are loaded

I have different rules which sync switch states from one binding (Nikobus) with switch states of another binding (MIOS). At startup this gives issues. II have already used delayed _start and similar kinds of delay timers, but this dioes not work optimal.
What is the best method to only start processing rules once all bindings have been fully loaded after a system restart?

Use cron in the rule to execute The commands after à minute. After 1minute all bindings should be loaded

I really hate polling rules so instead of @bajan’s suggestion, which I don’t think would work in all cases, I would do the following:

  • Create a Switch Item which will act as a flag indicating that the system is starting
  • In all of your rule that you want to prevent from running until your bindings have finished loading add a check to make sure that Item’s state is OFF
  • Create a system started triggered rule that sets the Item to ON, then sets a timer for however long you need to ensure that all the bindings have loaded that turns the Item back OFF.


Switch SystemStarting


var Timer startedTimer = null

rule "System Started"
    System started
    startedTimer = createTimer(now.plusMinutes(1), [| SystemStarting.sendCommand(OFF)])

rule "Rule that should not run until bindings are loaded"
   Item RuleTriggerItem received upadte
    if(SystemStarting.state == OFF) {
        // rule logic

If you have persistence make sure to exclude SystemStarted from being restored on startup or else there can be a brief time where Nikobus or MIOS events are coming in but the system started rule has not yet executed and if the value is restored on startup it will have an OFF state. By excluding it it will have an Undefined state instead and your checked rules will not execute, preventing this little race condition.

Hi Rich,
I used something similar but by reviewing with your approach I found some minor errors in my rules.
Rules are now fired xhen everything is loaded.
Thanks a lot!
Now up to the other ‘bugs’ to smash :smile: