Interacting with scripts and or rules via API

I could not find any information about it. But is there are way to interact with scripts or rules via the REST API ?
For example: change the value of a variable or enable/disable a script or rule ?

1 Like

You can do something similar to this by using items for “variables” you’d like to control through REST. To enable or disable a rule you could use a switch item that is checked within the body of the rule to conditionally control its execution.

Thanks for your reply Steve,

This means that I would be able to create an item which is not a “physical” item ? Most examples I have seen an item is always use for some “device” on the network.

Do you have any example how to to this ?

Yes, just define an item with no binding. Something like…

Switch MyRuleEnabled
Number MyRuleVariable

I use Jython (JSR223) for rules so I can’t given an example of an XText rule, but you would use the state of MyRuleEnabled and MyRuleVariable items in the body of your rule like any other item.

You could display the MyRuleEnabled switch in your sitemap if you want to interactively enable or disable the rule. You could also display MyRuleVariable in the sitemap (readonly). Both items can be updated using the REST API.