Nice graphic alarm (Pir sensors) visualization in HABPanel

Works perfectly @5iver @rlkoshak! Thanks for great support. I can also confirm that both options of changing the item value = state update as well as sending command works fine and the triggeringItem works correctly. Just to make it fully clear to others, I will put here the complete enhanced and working rule.

rule "Pir on"
when
    Item Pir01_raw received update 1 or
    Item Pir02_raw received update 1
then
    val pir = gPirs.members.findFirst[p| p.name == triggeringItem.name.split("_").get(0)]
    //logInfo("alarm.rules", "triggeringItem.name=[{}]",triggeringItem.name)
    //logInfo("alarm.rules", "pir.name=[{}]",pir.name)
    
    val timer = gPirTimers.members.findFirst[t| t.name == pir.name + "_Timer"]
    //logInfo("alarm.rules", "timer.name=[{}]",timer.name)
    pir.postUpdate("red")
    timer.sendCommand(ON)
end

rule "PIR Timer"
when
    Item Pir01_Timer received command OFF or
    Item Pir02_Timer received command OFF
then
    val pir = gPirs.members.findFirst[p| p.name == triggeringItem.name.split("_").get(0)]

    var color = "off"
    switch(pir.state.toString){
        case "red": color = "orange"
        case "orange": color = "orangelight"
        case "orangelight": color = "yellow"
        case "yellow" : color = "off"
    }

    pir.postUpdate(color)
    if(color != "off") triggeringItem.sendCommand(ON)
end

Items definition:

Group gPirs
Group gPirsOutside
Group gPirsInside
Group gPirTimers
Number Pir01_raw "PIR1 [%s]" <dmotion> (gPirs, gPirsOutside) {mqtt="<[mosquitto:Garden/Alarm/Pir01:state:default]"} //receiving 0 (no motion detected) or 1 (motion detected)
Number Pir02_raw "PIR2 [%s]" <dmotion> (gPirs, gPirsOutside) {mqtt="<[mosquitto:Garden/Alarm/Pir02:state:default]"}

String Pir01 "PIR1 [%s]" <dmotion> (gPirs, gPirsOutside) 
String Pir02 "PIR2 [%s]" <dmotion> (gPirs, gPirsOutside)

Switch Pir01_Timer (gPirTimers) {expire="5s,command=OFF"}
Switch Pir02_Timer (gPirTimers) {expire="5s,command=OFF"}
2 Likes