Hi J Wee,
as example for window contact in my bathroom:
items file
Group:Contact:OR(OPEN, CLOSED) gContact “Tür-/ Fensterkontakt” (Home)
String OS_Bridgesensor “Bridgestatus [%s]” (gContact, gwContact) { channel=“mqtt:topic:OH:GF_Bridgesensor_status:RF_Sensor” }
String GF_Bathroom_Window “Fensterkontakt Bad EG [%s]” (GF_Bathroom, gContact)
and the rule is:
//This is Alarmsensor_GF_Bathroom_Window.rules
var Timer SLEEP_TIME_Sirene
var Sirenenzeit = 120
rule “Alarmsensor_GF_Bathroom_Window”
when
Item OS_Bridgesensor received update or
Item OS_Bridgesensor changed
then
if (OS_Bridgesensor.state == "01DEE7" && MA_Houseoccupied.state == ON) { GF_Bathroom_Window.postUpdate("CLOSED")
val String Current_DateTime = String::format( "%1$tl:%1$tM%1$tp on %1$tA, %1$tB %1$te, %1$tY", new java.util.Date)
sendBroadcastNotification("Alarm - Fenster Bad EG geschlossen " + Current_DateTime)
sendTelegram("bot1", "Alarm - Fenster Bad EG geschlossen " + Current_DateTime)
MA_Alert.postUpdate("Fenster Bad EG")
MA_Alerttrigger.postUpdate("CLOSED")
MA_Alerttime.postUpdate(Current_DateTime)
BM_LaundryRoom_Siren.sendCommand(ON)
SLEEP_TIME_Sirene = createTimer(now.plusSeconds(Sirenenzeit)) [|
BM_LaundryRoom_Siren.sendCommand(OFF)]
}
if (OS_Bridgesensor.state == "01DEE7" && MA_Houseoccupied.state == OFF) { GF_Bathroom_Window.postUpdate("CLOSED") }
if (OS_Bridgesensor.state == "01DEEE" && MA_Houseoccupied.state == ON) { GF_Bathroom_Window.postUpdate("OPEN")
val String Current_DateTime2 = String::format( "%1$tl:%1$tM%1$tp on %1$tA, %1$tB %1$te, %1$tY", new java.util.Date)
sendBroadcastNotification("Alarm - Fenster Bad EG Offen " + Current_DateTime2)
sendTelegram("bot1", "Alarm - Fenster Bad EG Offen " + Current_DateTime2)
MA_Alert.postUpdate("Fenster Bad EG")
MA_Alerttrigger.postUpdate("OPEN")
MA_Alerttime.postUpdate(Current_DateTime2)
BM_LaundryRoom_Siren.sendCommand(ON)
SLEEP_TIME_Sirene = createTimer(now.plusSeconds(Sirenenzeit)) [|
BM_LaundryRoom_Siren.sendCommand(OFF)]
}
if (OS_Bridgesensor.state == "01DEEE" && MA_Houseoccupied.state == OFF) { GF_Bathroom_Window.postUpdate("OPEN") }
if (OS_Bridgesensor.state == "01DEEB" && MA_Houseoccupied.state == ON) { GF_Bathroom_Window.postUpdate("TAMPER")
val String Current_DateTime3 = String::format( "%1$tl:%1$tM%1$tp on %1$tA, %1$tB %1$te, %1$tY", new java.util.Date)
sendBroadcastNotification( "Alarm - Fenster Bad EG-Sensor manipuliert - Alarm was Armed " + Current_DateTime3)
sendTelegram("bot1", "Alarm - Fenster Bad EG-Sensor manipuliert - Alarm was Armed " + Current_DateTime3)
MA_Alert.postUpdate("Fenster Bad EG")
MA_Alerttrigger.postUpdate("TAMPER")
MA_Alerttime.postUpdate(Current_DateTime3)
BM_LaundryRoom_Siren.sendCommand(ON)
SLEEP_TIME_Sirene = createTimer(now.plusSeconds(Sirenenzeit)) [|
BM_LaundryRoom_Siren.sendCommand(OFF)]
}
if (OS_Bridgesensor.state == "01DEEB" && MA_Houseoccupied.state == OFF) { GF_Bathroom_Window.postUpdate("TAMPER")
val String Current_DateTime4 = String::format( "%1$tl:%1$tM%1$tp on %1$tA, %1$tB %1$te, %1$tY", new java.util.Date)
sendBroadcastNotification("Alarm - Fenster Bad EG-Sensor manipuliert - Alarm was Disarmed " + Current_DateTime4)
sendTelegram("bot1", "Alarm - Fenster Bad EG-Sensor manipuliert - Alarm was Disarmed " + Current_DateTime4)
}
end
//01DEEE open
//01DEE7 closed
//01DEEB tamper
You have to figure out wich value is wich state for your contact. After this you write the different values in your rule.
I know that the rule is not that clean and that I can reduce it with the “case” function, but it woks for me.
For sure you can delete the parts of the rule, that were not necessary for you like MA_Alert, MA_Alerttrigger… so that you don’t got any error notification in your Log Viewer.
Good luck