[SOLVED] On/off command line switch

Hello,

I am brand new to openHab, and I’m simply trying to create a switch that will issue one command when switched on, and another when switched off.

is there any way to do this in Paper UI?

Thanks!

As far as i know this is not in the stable branch yet, and i wouldn’t suggest running unstable to a newcomer.

You can set up a switch named “mySwitch” in PaperUI and put a .rules file into your rules configuration folder.
The rule is quite simple. I guess you want to execute a script or similar.

rule "switch on"
when
    Item mySwitch received command ON
then
    executeCommandLine("myscript.sh")
end    

rule "switch off"
when
    Item mySwitch received command OFF
then
    executeCommandLine("myscript.sh")
end

Alright, I’ll give 'er a go. Thanks!
I’ll update this as soon as I get it working.

That is exactly what I needed. THANKS!

1 Like