But a Script is one of the supported Actions.
Yes, but, at least using the terminology used in PaperUI, a Script is a bit of custom code you write (currently only JavaScript is supported) to be an Action or the “but only if…” part of a Rule. The code gets encoded and saved as part of the JSON entry. For example:
{
"7a6ebf3b-6f0c-4a82-b582-5e7ded2dae42": {
"class": "org.eclipse.smarthome.automation.dto.RuleDTO",
"value": {
"triggers": [
{
"id": "1",
"label": "an item receives a command",
"description": "This triggers the rule if an item receives a command.",
"configuration": {
"itemName": "Test",
"command": "ON"
},
"type": "core.ItemCommandTrigger"
}
],
"conditions": [],
"actions": [
{
"inputs": {},
"id": "2",
"label": "execute a given script",
"description": "Allows the execution of a user-defined script.",
"configuration": {
"type": "application/javascript",
"script": "\u0027use strict\u0027;\n\nload(\u0027./../conf/automation/jsr223/jslib/JSRule.js\u0027);\n\nlogInfo(\"Using the library!\");\n\n//var myLog \u003d Java.type(\"org.slf4j.LoggerFactory\").getLogger(\"org.eclipse.smarthome.model.script.Rules\");\n//myLog.info(\"createTimer---------------------------\");\n//var ScriptExecution \u003d Java.type(\"org.eclipse.smarthome.model.script.actions.ScriptExecution\");\n//var LocalDateTime \u003d Java.type(\"java.time.LocalDateTime\");\n//var DateTime \u003d Java.type(\"org.joda.time.DateTime\");\n//var fnc \u003d function(){\n// myLog.info(\"Timer completed\");\n//}\n//myLog.info(\"Creating timer...\");\n//ScriptExecution.createTimer(LocalDateTime.now().plusSeconds(5), fnc);"
},
"type": "script.ScriptAction"
}
],
"configuration": {},
"configDescriptions": [],
"uid": "7a6ebf3b-6f0c-4a82-b582-5e7ded2dae42",
"name": "Test4",
"tags": [],
"visibility": "VISIBLE"
}
}
}
As you can see, the Action of this rule is called a Script and it includes a bit of JavaScript (with all the spaces replaced with \u0027
for some reason.
In fact, the bulk of the time and effort I’ve spent on Experimental Next-Gen Rules Engine Documentation 1 of : Introduction has been documenting exactly how to write these Scripts (postings 3-5 and counting).
The example you have would be how I would create a completely independent Rule using JSR223. That code would not be saved in the JSONDB.
I’ve been using “Scripts” to denote these self implemented Actions and “JSR223 Rules” to denote whole Rules written in one of the JSR223 languages.
I’ve not seen any official glossary of what we are supposed to call all of this stuff so I’ve been treating PaperUI as the “truth” when it comes for what these various things are supposed to be called.