openHAB 5.0 Release Discussion

It’s likely disabeling and reenabling the rule would be sufficient. You could use the following JS code to do them all in one go.

const { ruleRegistry } = require('@runtime/RuleSupport');
utils.javaSetToJsArray(ruleRegistry.getAll()).map(r => r.getUID().toString())
                                             .filter(id => id != ruleUID && rules.isEnabled(id))
                                             .forEach( id => {
                                                console.info('Disabling ' + id);
                                                rules.setEnabled(id, false);
                                                Java.type('java.lang.Thread').sleep(500);
                                                console.info('Enabling ' + id);
                                                rules.setEnabled(id, true);
                                              });

I ran this from -Scratchpad-.

Note that the above code skips rules that are already disabled and ti skips the rule it’s running from. Rules that are triggered by a system started/start level reached trigger will be triggered again when the rule is reenabled.

I only minimally tested the above code. There may be edge cases I’ve not thought of.

2 Likes