Check System Start Level (System-based Triggers) in Javascript Rules as part of "if-condition"

Platform information:

  • Hardware: Raspi 3 B+ (Raspian OS 10)
  • Attached Hardware: Amber Wireless AMB8465 stick to read out Wireless M-Bus from water & heat meter
  • Docker / Portainer 2.11.0
  • openHAB Software: 3.2.0 Release Build
  • openHAB Bindings: Homematic Binding (logging the heating, controlling lights and blinds), Gardena Binding for Gardena Gateway / smart irrigation control (logging soil humidity), Alexa Binding (controlling the Homematic lights)
  • Homematic IP Hardware: CCU2 (2.59.7), multiple Homematic IP devices

I’m using a couple of rules to convert strings (e.g. status messages from my irrigation system) into numbers, to facilitate analyzing and storing them). Most of them are triggered by “when a member of a group changes”, see below:

The problem of that approach however is that, during startup, since the status of items changes a lot as part of the initialization process, the rule fires a lot, which floods the log.

In this thread I learned how to apply the “start level” trigger, which allows to trigger a rule based on when the system has started.

Now, combining those two, is it possible to trigger a rule “when a member of a group changes” with “only execute part of the Javascript code if system start level 100 has been reached”? Or, in other words, is there a way to check the system start level in Javascript with an if-condition?

Not that I’m aware of. You could fake it by triggering a rule as early in the start levels as possible and setting a Switch Item to OFF. I think 40 is the earliest but 60 is when the rule engine starts so that should eliminate most of the problems. Then another rule triggered at runlevel 100 to set the Item to ON. Add conditions to the rules you care about to check the switch.

Another alternative that might work would be to create the two rules but instead of using an Item, disable and enable the rules themselves.

Thanks for the hint, this did the job (despite the problems of this approach reported here).

In fact I did have two rules for this in place already, so I just added a couple of more rules to keep the log clean: One rule at start level 70 (to deactivate a couple of rules during startup), and one at start level 100 (re-activating these rules).