Rule with Cron timer for a specified duration

Hello, I search a possibility to run a cron timer for a specified duration e.g 10min.

e.g.

rule “Pump time duration”
when
Time cron “0 0/15 18-19 * * * ?”
then
Pump_outlet.sendCommand(ON)
logInfo(“Pump ON”,“Pump ON”)
sendBroadcastNotification(“Pump ON”)
end

This is the trigger for On.

Should I use a several rule to trigger for pump off or how can I control this?

You can use a timer to turn the Switch OFF after 10 minutes:

rule “Pump time duration”
when
Time cron “0 0/15 18-19 * * * ?”
then
Pump_outlet.sendCommand(ON)
logInfo(“Pump ON”,“Pump ON”)
sendBroadcastNotification(“Pump ON”)
createTimer(now.plusMinutes(10), [|
    Pump_outlet.sendCommand(OFF)
])
end

The pump turns on when the rule is triggered, and a timer is started that turns it off when the timer has run out (after 10 minutes).

1 Like