I have what I feel must be an easy questions. I am using a very simple rule to turn my espresso machine on in the early morning and off again after a few hours. I included the actual rule below for clarity. I would like to be able to turn off this rule at will with a switch in in the site map. With this if I do not want the machine to turn on the next morning or in near future the entire rule will be disabled.
Can a rule be referred to as a binding or some other method on a switch item? After thinking more on this I am pretty sure that the answer here will lie in a nested if/then or when/then but I am not coming up with too many examples of something that might work for the issue.
Any help is greatly appreciated!
rule "Coffee on 630am"
when
Time cron "00 30 06 * * ?"
then
sendCommand(plug5, ON)
end
rule "Coffee off 1130"
when
Time cron "00 30 11 * * ?"
then
sendCommand(plug5, OFF)
end
Thanks for the response! I know this is probably obvious but at least at first glance I cant figure out how to integrate this suggestion. I included my updated code with the other suggestions. I did notice that the timer did flip back to off and between the on and off times I was not able to set it to on. Is that what the unintialized item takes care of? Thanks all in advance.
rule "Coffee on 630am"
when
Time cron "00 30 06 * * ?"
then
if (coffeetimer.state == ON) {
sendCommand(plug5, ON)
}
end
rule "Coffee off 1130"
when
Time cron "00 30 11 * * ?"
then
sendCommand(plug5, OFF)
end