Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Map
- var file = "windows.rules"
- val Map<String, Timer> timers = newHashMap
- rule "Notify if window is open too long"
- when
- Member of gWarnIfOpen changed
- then
- // Always cancel the existing Timer
- val timer = timers.get(triggeringItem.name)
- logInfo(file, "cancelling timer for " + triggeringItem.name)
- timer?.cancel
- timers.put(triggeringItem.name, null)
- // Create a Timer if the door opened
- if(triggeringItem.state == OPEN) {
- var timerTime = (WindowWarningTime.state as DecimalType).intValue
- logInfo(file, "Setting " + timerTime + " minute timer for " + triggeringItem.name)
- timers.put(triggeringItem.name, createTimer(now.plusMinutes(timerTime), [ |
- logInfo(file, "Sending: " + triggeringItem.label + " ist offen")
- val telegramAction = getActions("telegram","telegram:telegramBot:XXXX")
- telegramAction.sendTelegram("%s ist offen", triggeringItem.label)
- ]))
- }
- end
Add Comment
Please, Sign In to add comment