I use the Expire Binding for Repeat anything …
val java.util.Map<String, org.eclipse.smarthome.model.script.actions.Timer> tfkWarnTimers = newHashMap
val Functions$Function6<ContactItem,StringItem,RollershutterItem,java.util.HashMap<String,Timer>,String,Integer,Boolean> fsWarnLogic = [
fsTFK_Item,fsTFK_Status_Item,RL_Item,
java.util.Map<String, org.eclipse.smarthome.model.script.actions.Timer> timers,
String fsTFK_name, int timeout |
if (fsTFK_Item.state == OPEN){
if (fsTFK_Status_Item.state != "Geöffnet > " + timeout + " Minuten"){
fsTFK_Status_Item.postUpdate("Geöffnet")
}
timers.get(fsTFK_name)?.cancel
timers.put(fsTFK_name, createTimer(now.plusMinutes(timeout)) [|
if (fsTFK_Status_Item.state != "Geöffnet > " + timeout + " Minuten"){
sendTelegram("gBot", fsTFK_name + " ist länger als " + timeout + " Minuten geöffnet\nBitte schliessen!!!")
fsTFK_Status_Item.postUpdate("Geöffnet > " + timeout + " Minuten")
}
//Akustische Warnung, wenn der Gefrierschrank länger als "timeout" geöffnet ist!
if (fsTFK_Item.name.toString.equals("TFK_Gefrierschrank")){
if (Presence_Start_Up.state == ON || Presence.state == ON && Presence_Start_Up.state == OFF) {
//Timer (Expire Binding) starten, damit die Warnung wiederholt wird, bis der Gefrierschrank geschlossen ist!
//Wiederholung der Warnung errechnet sich aus Timeout + Expire
Gefrierschrank_Warn_Timer.sendCommand(ON)
//Akustische / Optische Warnung
Funkgong_LS_Kanalaktion.sendCommand("1,1,108000,010")
Thread::sleep(1000)
Funkgong_LED_Kanalaktion.sendCommand("1,20,108000,17,18,17,18,17,18,17,18,0,0")
}
}
timers.remove(fsTFK_name)
])
//Prüfen ob Rolladen übergeben wurde
if (RL_Item !== null){
if (RL_Item.state > 80) RL_Item.sendCommand(80)
}
}
else{
if (fsTFK_Item.state == CLOSED){
timers.get(fsTFK_name)?.cancel
timers.remove(fsTFK_name)
fsTFK_Status_Item.postUpdate("Geschlossen")
//Prüfen ob Rolladen übergeben wurde
if (RL_Item !== null){
if (Nacht_Modus.state == ON){
if (RL_Item.state < 100) RL_Item.sendCommand(DOWN)
}
}
if (fsTFK_Item.name.toString.equals("TFK_Gefrierschrank")){
Gefrierschrank_Warn_Timer.postUpdate(OFF)
}
}
}
true
]
when
Item TFK_Gefrierschrank changed from CLOSED to OPEN or
Item TFK_Gefrierschrank changed from OPEN to CLOSED or
Item Gefrierschrank_Warn_Timer changed from ON to OFF
then
fsWarnLogic.apply(TFK_Gefrierschrank, FS_Gefrierschrank_Status, null, tfkWarnTimers, "Gefrierschrank", 2)
end