I’ve a switch that I would like to monitor, how can I configure a rule to receive an email when this switch is on for longer than 30 minutes?
I guess the Low Battery warning is similar, https://github.com/openhab/openhab/wiki/Samples-Rules#get-an-email-when-battery-powered-devices-are-running-low-on-power…
import org.openhab.core.library.types.DecimalType
val String mailTo = "you@example.com"
val int lowBatteryThreshold = 10
rule "Battery Monitor"
when Time cron "0 0 19 * * ?"
then
if (! Battery.allMembers.filter([state < lowBatteryThreshold]).empty) {
val report = Battery.allMembers.filter([state instanceof DecimalType]).sortBy([state]).map[
name + ": " + state.format("%d%%")
].join("\n")
val message = "Battery levels:\n\n" + report + "\n\nRegards,\n\nopenHab"
sendMail(mailTo, "Low battery alert", message)
}
end
But I can’t work out how to tailor it to my needs.