System started UI rule with JSS Addon OH3.2

When using the trigger “system started” in a JS rule (start level is not relevant) in the UI with ECMA11 (JSS Addon) i had the problem that the rule gets fired but it will not get executed, because the addon needs some time to be ready. Instead it gives a error message that the rule can not be interpreted.

My workaround as for now is to add an additional delay to the “system started” rule.
Go to the rule settings: “But only if” → add a dsl script:

1 == 1

For me it works with a 20sec delay.

Are you aware of that problem or do i something wrong?: @digitaldan

1 Like

Woah, that’s a clever/sneaky way to delay rule execution. :slight_smile:

Rule Conditions are super powerful. We are just at the beginning of understanding the sorts of things they can solve.

I’ve used them to override invalid states in Items before (e.g. if an item becomes a state that doesn’t makes sense given other states, change it back to it’s old state instead of running the rule).

But delaying when a runlevel triggered rule runs (or any rule really) is inspired.

Note, Thread.sleep doesn’t work in JSScripting so using Rules DSL is a good choice. It’s a great example of taking advantage of how UI rules can mix different languages in the same rule. This too has powerful uses.

This sounds interesting. Can you give a practical example? (Maybe not in this topic.)

At a high level, HestiaPi is a smart thermostat built on OH. A couple String Items indicates the mode (US/EU, HEAT/AC/FAN/BOOST/HUM). There are only a few valid strings and in some cases a mode is only supposed is circumstances (e.g. HUM is only supported in EU mode). So when the mode changes, the condition checks to see if it’s a valid mode and changes it back if it’s not. This prevents a whole cascade of rules from running unnecessarily.

1 Like