Hi everyone,
I’m new into OpenHab (and dev). I’m trying to set up an alarm with a rule but its not working fully.
I’m trying to count each wrong code to run the alarm but it stay at one.
rule “Alarm test”
when
Item Keypad_Alarm received command
then
var Number CountWrongCode = 0
if (Keypad_Alarm.state == 1234 && State_Alarm.state == ARMED){
State_Alarm.sendCommand('DISARMED')
}
else if (Keypad_Alarm.state == 1234 && State_Alarm.state == DISARMED){
State_Alarm.sendCommand('ARMED')
}
else if (Keypad_Alarm.state != 1234 && CountWrongCode != 3) {
CountWrongCode = CountWrongCode + 1
CounterWrongCode.postUpdate(CountWrongCode)
}
else {
State_Alarm.sendCommand('ALARM')
CountWrongCode = 0
CounterWrongCode.postUpdate(CountWrongCode)
}
end
On HabPannel :
I have a string who display the state (armed/disarmed/Alarm) and another one who is the count of wrong code typed.
The count stay at one and it’s updated only once as i can see in the log.