Timer 5mins every hour

Dear all,
I need a rule that turns on a wall plug every hour for 5mins.
My naive approach would be to have rule that starts every hour an ON and another that is delayed for 5mins to STOP the wall plug again.

Is this the best way to do so, or an even better approach to have some timer (however this would have to be implemented) and after 4mins it goes OFF.

Thanks Norbert

perhaps use a rule triggered by cron expression and the expire binding

I would suggest using two cron based rules, one to turn the plug on at the top of the hour and the other to turn the plug off five minutes later. Something like the following.

rule PlugOn
when Time cron "0 0 * * * ? *" 
then sendCommand(MyPlugItem, ON)
     logInfo("PlugOn", "MyPlugItem set {}", MyPlugItem.state.toString)
end

rule PlugOff
when Time cron "0 5 * * * ? *" 
then sendCommand(MyPlugItem, OFF)
     logInfo("PlugOff", "MyPlugItem set {}", MyPlugItem.state.toString)
end
1 Like

Thanks, i now did add two cron timer based on what you posted above. Thanks a lot for your input!