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).

Hi Justin. This is really a very nice work you have done here. I am surprise it didn’t catch more attention.

I’ve been playing with it and after some time spent struggling, i found the problem : there is a compatibility issue with latest stable release of Openhab (3.4) and the modification rule.

Apparently, the parameters of “items.addItem()” have changed and the rule cannot create items anymores. It need an ItemConfig object as parameter

I have been able to work around it by editing code this way :

          name: modifyItem,
          type: 'Group',
          label: modifySetting || 'New Bayesian Group'

and later in the same function :

          name: 'Rule_BayesianModify',
          type: 'String',
          label: modifySetting || 'Modify Bayesian Item'});


1 Like

Thank you, you are correct, I haven’t updated this since the itemConfig object was added to the JSscripting. I’ll try to get to this update when I get back home in a few days.