[SOLVED] [Newbie] Call script file from rule

  • Platform information:
    • Hardware: Raspberry Pi 2
    • OS: OpenHAB easy setup
    • openHAB version: 2.4.0-1

Is it possible to call a *.script file from a rule?

I have some rules which will perform the same actions but on different triggers. To make my life easier I would like to extract the script part into a *.script file and call it from the different rules. For example the following

action.script
MyItem.sendCommand("Foo")

myRules.rules

rule "FirstAction"
when
    TriggerA
then
    action.script
end

rule "SecondtAction"
when
    TriggerB
then
    action.script
end

rule "ThiredAction"
when
    TriggerC
then
    action.script
end

What must I do to call action.script within my rules?

Thx for hte help!
Christoph

See: https://www.openhab.org/docs/configuration/actions.html#openhab-subsystem-actions

As far s as I know there is a EXEC binding exactly for the purpose of executing scripts :thinking:

Thank you, I knew I have overlooked it :slight_smile: