Bayesian Group Suite - Modification Rule


This rule is one part of a bundle designed to allow the creation, configuration, and utilization of Bayesian probability calculations for some item states using the MainUI. The three parts are:

Credit: This is an OH3-ready implementation of @cweitkamp’s awesome Bayesian aggregation design pattern. So, much of the credit goes to him and you will want to read through his post for a more detailed explanation of the underlying concepts and very clear description and example of probability selection.

This rule is intended for use only with the Bayesian Group Control Widget (see link above). It provides much of the functionality for that widget and will not offer much functionality without it.

Installation and Use

After downloading this rule from the marketplace you only need to create one instance of the rule and there are no required parameters. The rule is usually triggered by an item but that item will be automatically created the first time the rule is run or when the widget is initialized, so there is no need to create the item or input the item name into the rule.

Use without the widget

This rule does have one use indepenent of the widget. If this rule is run manually (press the Run Now button or ctrl + r from the rules detail page) then it will run a check of the metadata for all Bayesian groups and print any errors or warnings to the log as well as adding those errors and warnings to the metadata for each item as necessary.


  • JSscripting ECMAScript 2021+


  • JSscripting Add-on


Version 0.2

  • Fixed template formatting issue

Version 0.1

  • initial release



Hello started playing with this but found got stuck directly with eror[ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'Rule_BayesianModify' failed: org.graalvm.polyglot.PolyglotException: SyntaxError: <eval>:6:11 Expected ; but found : β”‚β”‚ trueState: 'ON', β”‚β”‚ ^ β”‚β”‚<eval>:8:7 Expected ; but found : β”‚β”‚ prior: 0.5, β”‚β”‚ ^ β”‚β”‚<eval>:10:9 Expected ; but found : β”‚β”‚ sensors: { β”‚β”‚ ^ β”‚β”‚<eval>:13:11 Expected ; but found : β”‚β”‚ pTrue: 0.75, β”‚β”‚ ^ β”‚β”‚<eval>:15:4 Expected eof but found } β”‚β”‚ } β”‚β”‚ ^ β”‚β””

Sorry about that, for some reason the template installation was completely mis-formatting any lines that followed comments which started at the beginning of a line. Not sure what was causing that. I’ve reloaded the script to git-hub and tested, it now downloads a properly formatted script file and runs.

There isn’t yet any way to directly update a rule template. You’ll need to go back to the automation settings and uninstall the version you have now and then reinstall. That should get you the version 0.2 which I can verify works. If you also have already installed the Activation Rule, then you’ll need to do the same thing to get the corrected version (it suffered the same issue).