Execute an Item based on other Item

Hi,
I’m running OH2. I have this item, that execute a script every hour:

String ROUTER_SPEEDRESULT "Risultato Test Velocità[%s]" { exec="<[/etc/openhab2/myscript/speed_test.sh:3600000:REGEX((.*))]"}

Sometime, I need to disable this item, and script do not be executed. I would like to setup another Switch Item to toggle execution on and off, but I have no idea on how to make it work as I expect.
It is possible to perform this?

Thanks

Hi,

I don’t think you should define your item with an exec binding if you want to enable/disable the execution of the script!
Best thing to do is using a rule that describes the usage of such an action far more better than a binding linked to an item!

BR,
George

Hi @george.erhan
can you explain better how to perform? Have you some example?

Many Thanks

Marco

rule "Periodically execute a script"
when
    Time cron "0 0 * * * ?"
then
    if(MySwitch.state == ON) {
        val String results = executeCommandLine("/etc/openhab2/myscript/speed_test.sh", 300000) // wait up to five minutes
        ROUTER_SPEEDRESULT.postUpdate(results)
    }
end
1 Like

hi @rlkoshak
so simple :smiley: …many thanks for help.
Kindly Regards

Marco