Hi All,
I’ve taken the below snippet found from the rules example on http://docs.openhab.org/configuration/rules-dsl.html
// increase the counter at midnight
rule "Increase counter"
when
Time cron "0 0 0 * * ?"
then
counter = counter + 1
end
What I’d like to do is the opposite and actually subtract one from the counter instead so that it can be used as a “days until” counter.
Can anyone help?
Thanks
jeffsf
(Jeff)
2
Umm, counter = counter - 1
isn’t working?
1 Like
Hmm that’s really weird, I had tried that several times and couldn’t get a success with it so I assumed there was an error with the syntax…
I’ve tried it once again before responding and it has worked?!
Whilst you are here, would you know how to reset the counter once it has reached 0?
rossko57
(Rossko57)
4
I would think something along the lines of if (counter == 0) { do whatever you want …?