I want to call an existing blockly script from my Rules.
Whenever I choose “execute a given script” it only let me create a new one but I can’t select from the existing one.
The one I created from the rule does not show up under scripts.
I would very much prefer to have my scripts listed under scripts and just “trigger” it from Rules.
Where do I got the idea wrong?
Background info:
OH 3
Rule set via: When - Then - But Only IF
Script: Blockly script
Edit: my apologies, I did not read your response properly in my first try.
Yes your answer solved my problem and indeed let me select a script under rules.
That is pretty well hidden and I would say quite user-UN- friendly. Anyway I probably will remember it till the end of OH3 after spending hours scratching my head
original response:
Hi Michiel,
Running another Rule works as you described but I’d like to run a script instead of another Rule.
I probably can move it around to a rule actually but that was not what I initially planned to do
If I remember correctly (but I am not an expert) then rules and scripts are basically the same (if you take DSL script language as an example). But rules can respond to tiggers (eg a door opens or a predetermined time is reached) and scripts cannot.
So you can use a rule to run a script.
In Openhab 2.x i used rules like the example below
rule "<RULE_NAME>"
when
<TRIGGER_CONDITION> [or <TRIGGER_CONDITION2> [or ...]]
then
<SCRIPT_BLOCK>
end
Now I can (in Openhab 3) seperate this in to parts: Rule end script
Rule:
rule "<RULE_NAME>"
when
<TRIGGER_CONDITION> [or <TRIGGER_CONDITION2> [or ...]]
then
< SCRIPT YOU WANT TO RUN>
end
Then you create a script that is triggered by the above rule.
Scripts (depending on the scripting language) can perform more complex tasks than simply sending the command ON to a lamp.
But sometimes a rule is more than enough.
Someone will probably correct me if I miss the point completely.
Correct. In MainUI a “Script” is just a special case for a Rule. It is a Rule that consists only of a single Script Action and it is tagged with “Script”. It really isn’t anything more than that. That is why it shows up under “Other Rules”; it is an other rule.