Rule Designer: Example 1 - openhab/org.openhab.ui.habmin GitHub Wiki
This rule will simply update an item RainGauge_Change24hr
from the value of difference of the item Outside_RainGauge_Counter
now, and 24 hours ago.
// This rule file is autogenerated by HABmin.
// Any changes made manually to this file will be overwritten next time HABmin rules are saved.
// Imports
import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import org.java.math.*
rule "Rain in past 24 hours"
when
Time cron "0 */2 * * * ?"
or
Item RainGauge_Change24Hour changed
then
postUpdate(RainGauge_Change24Hour, (RainGauge_Change24Hour.state as DecimalType - RainGauge_Change24Hour.historicState(now.minusHours(24)).state as DecimalType))
end