Files
OpenHAB-FFR/rules/FFRAlarm.rules
2020-11-28 13:07:21 +01:00

142 lines
8.0 KiB
Plaintext

import java.util.concurrent.locks.ReentrantLock
var ReentrantLock lockState = new ReentrantLock()
var Timer FFAlarmTimer = null
rule "Auswertung Alarm JSON"
when
Item FFAlarmJSON changed
then
logInfo("FFAlarmJSON","Vor FFAlarmEinsatznummer")
postUpdate(FFAlarmEinsatznummer,transform("JSONPATH", "$.Einsatznummer", FFAlarmJSON.state.toString))
logInfo("FFAlarmJSON","Vor FFAlarmOrt")
postUpdate(FFAlarmOrt,transform("JSONPATH", "$.Ort", FFAlarmJSON.state.toString))
logInfo("FFAlarmJSON","Vor FFAlarmOrtsteil")
postUpdate(FFAlarmOrtsteil,transform("JSONPATH", "$.Ortsteil", FFAlarmJSON.state.toString))
logInfo("FFAlarmJSON","Vor FFAlarmStrasse")
postUpdate(FFAlarmStrasse,transform("JSONPATH","$.Strasse",FFAlarmJSON.state.toString))
logInfo("FFAlarmJSON","Vor FFAlarmObjekt")
postUpdate(FFAlarmObjekt,transform("JSONPATH","$.Objekt",FFAlarmJSON.state.toString))
logInfo("FFAlarmJSON","Vor FFAlarmEStelleZusatz")
// postUpdate(FFAlarmEStelleZusatz,transform("JSONPATH","$.E-Stelle-Zusatz",FFAlarmJSON.state.toString))
logInfo("FFAlarmJSON","Vor FFAlarmEStelleBem")
postUpdate(FFAlarmEStelleBem,transform("JSONPATH","$.E-Stelle-Bem",FFAlarmJSON.state.toString))
logInfo("FFAlarmJSON","Vor FFAlarmKoordinate")
postUpdate(FFAlarmKoordinate,transform("JSONPATH","$.Koordinate",FFAlarmJSON.state.toString))
logInfo("FFAlarmJSON","Vor FFAlarmStichwort")
postUpdate(FFAlarmStichwort,transform("JSONPATH","$.Stichwort",FFAlarmJSON.state.toString))
logInfo("FFAlarmJSON","Vor FFAlarmMeldebild")
postUpdate(FFAlarmMeldebild,transform("JSONPATH","$.Meldebild",FFAlarmJSON.state.toString))
logInfo("FFAlarmJSON","Vor FFAlarmAlarmierungszeit")
postUpdate(FFAlarmAlarmierungszeit,transform("JSONPATH", "$.Alarmierungszeit", FFAlarmJSON.state.toString))
logInfo("FFAlarmJSON","Vor FFAlarmBemerkung")
postUpdate(FFAlarmBemerkung,transform("JSONPATH","$.Bemerkung",FFAlarmJSON.state.toString))
logInfo("FFAlarmJSON","Vor FFAlarmMeldender")
postUpdate(FFAlarmMeldender,transform("JSONPATH", "$.Meldender", FFAlarmJSON.state.toString))
logInfo("FFAlarmJSON","Vor FFAlarmEinsatzmittel")
postUpdate(FFAlarmEinsatzmittel,transform("JSONPATH","$.Einsatzmittel",FFAlarmJSON.state.toString))
logInfo("FFAlarmJSON","Vor Alarmtrigger")
postUpdate(FFAlarmTrigger,transform("JSONPATH","$.AlarmTrigger",FFAlarmJSON.state.toString))
end
rule "FFR Alarm Logik"
when
Item FFAlarmTrigger changed to ON
then
if (FFAlarmTimer === null) {
postUpdate(FFAlarmView,"ON")
postUpdate(FHZPush,"ON")
REMWEBIO001_Ausgang5.sendCommand(ON)
REMWEBIO001_Ausgang6.sendCommand(ON)
// postUpdate(REMCAM001Record,"ON")
// postUpdate(REMCAM002Record,"ON")
sendHttpGetRequest("http://admin:rt8qff8ppkma82bzxq2vcy3m3@10.112.30.31/control/rcontrol?action=sound&soundfile=q96_feuer2&speakerlevel=30")
sendHttpGetRequest("http://admin:pdgqa62v4f4bd9trmvp7z7t88@10.112.30.32/control/rcontrol?action=sound&soundfile=q96_feuer2&speakerlevel=30")
FFAlarmTimer = createTimer(now.plusMinutes(60)) [|
postUpdate(FFAlarmTrigger,"OFF")
postUpdate(FHZPush,"OFF")
// postUpdate(REMCAM001Record,"OFF")
// postUpdate(REMCAM002Record,"OFF")
FFAlarmTimer.cancel()
FFAlarmTimer = null
]
}
end
rule "FFAlarmTrigger OFF"
when
Item FFAlarmTrigger changed to OFF
then
postUpdate(FHZPush,"OFF")
postUpdate(FFAlarmView,"OFF")
// postUpdate(REMCAM001Record,"OFF")
// postUpdate(REMCAM002Record,"OFF")
end
rule "Alarmschleifen Auswertung"
when
Item FFAlarmSchleife received update
then
// val telegramActionProd = getActions("telegramActionProd","telegram:telegramBot:11a46758")
// val telegramActionDEV = getActions("telegram","telegram:telegramBot:a0986dc8")
logInfo("Alarmschleife", "Alarmschleife wurde aktualisiert")
switch(FFAlarmSchleife.state.toString) {
case "57459": {
logInfo("Alarmschleife", "Vollalarm Rembrücken und Heusenstamm")
postUpdate(FFAlarmTrigger,"ON")
sendPushoverMessage(pushoverBuilder("Vollalarm Rembrücken und Heusenstamm").withSound("siren").withPriority(1).withUser("upgb55kps8rx2xotn7dvdg3w2yjpt6"))
// telegramActionProd.sendTelegram("Alarmschleife hat ausgelöst: Vollalarm Rembrücken und Heusenstamm")
// telegramActionDEV.sendTelegram("Alarmschleife hat ausgelöst: Vollalarm Rembrücken und Heusenstamm")
}
case "57449": {
logInfo("Alarmschleife", "Einsatz für den ELW")
postUpdate(FFAlarmTrigger,"ON")
sendPushoverMessage(pushoverBuilder("Einsatz für den ELW").withSound("siren").withPriority(1).withUser("upgb55kps8rx2xotn7dvdg3w2yjpt6"))
// telegramActionProd.sendTelegram("Alarmschleife hat ausgelöst: Einsatz für den ELW")
// telegramActionDEV.sendTelegram("Alarmschleife hat ausgelöst: Einsatz für den ELW")
}
case "57455": {
logInfo("Alarmschleife", "Vollalarm Rembrücken")
postUpdate(FFAlarmTrigger,"ON")
sendPushoverMessage(pushoverBuilder("Vollalarm Rembrücken").withSound("siren").withPriority(1).withUser("upgb55kps8rx2xotn7dvdg3w2yjpt6"))
// telegramActionProd.sendTelegram("Alarmschleife hat ausgelöst: Vollalarm Rembrücken")
// telegramActionDEV.sendTelegram("Alarmschleife hat ausgelöst: Vollalarm Rembrücken")
}
case "57451": {
logInfo("Alarmschleife", "Vollalarm Heusenstamm")
sendPushoverMessage(pushoverBuilder("Vollalarm Heusenstamm").withSound("siren").withPriority(0).withUser("upgb55kps8rx2xotn7dvdg3w2yjpt6"))
}
}
end
rule "Push Fahrzeugstatus"
when
Member of gFHZ changed
then
Thread::sleep(300)
if (!lockState.isLocked) {
lockState.lock()
try {
logInfo("GroupTest","gFHZ received update")
val member = gFHZ.members.filter[d | d.lastUpdate("jdbc") !== null].sortBy[lastUpdate("jdbc")].last
val name = member.label.toString
if (FFAlarmTrigger.state == ON && member.state.toString == "3") {
logInfo("GroupTest", "Member "+ name +" to " + member.state )
if (FHZPush.state == ON && member.state.toString == "3") {
sendPushoverMessage(pushoverBuilder(name + " ist aus zur E-Stelle").withSound("siren").withUser("upgb55kps8rx2xotn7dvdg3w2yjpt6"))
}
sendPushoverMessage(pushoverBuilder(name + " ist aus zur E-Stelle").withSound("siren").withUser("u8s32g4yym8xbk7yqn66cokjys13mf"))
}
if (FFAlarmTrigger.state == ON && member.state.toString == "4") {
logInfo("GroupTest", "Member "+ name +" to " + member.state )
if (FHZPush.state == ON && member.state.toString == "4") {
sendPushoverMessage(pushoverBuilder(name + " an der E-Stelle angekommen").withSound("siren").withUser("upgb55kps8rx2xotn7dvdg3w2yjpt6"))
}
sendPushoverMessage(pushoverBuilder(name + " an der E-Stelle angekommen").withSound("siren").withUser("u8s32g4yym8xbk7yqn66cokjys13mf"))
}
} finally {
lockState.unlock()
}
} else {
logInfo("Testing","Locked, update ignored")
}
end