One of the many issues I’m having switching to OH2. Without the delay below, the rule sees the previous value of “Alarm_Mode”. I spent a lot of time debugging this and now it concerns me that this could potentially impact most of my other rules. Apparently, the rule gets triggered before the new item value is available.
Is this a known bug? Do I need to put a timer in all rules to prevent this from happening?
Without the timer delay, the wrong audio file was played about 75% of the time. I’ve made the rule more complex during debugging.
rule "Alarm Mode Notify"
when
Item Alarm_Mode received command
then createTimer(now.plusMillis(80)) [
switch(Alarm_Mode.state){
case 0: {Audio_File2= "sysdisarmed.mp3"}
case 1: {Audio_File2= "sysarmaway.mp3"}
SqueezeAudio2.postUpdate(Audio_File2+"")
}
}]
end
rule "Squeeze Notification 2"
when
Item SqueezeAudio2 received update
then SqueezeUSerStrm.sendCommand("openhab/" + SqueezeAudio2.state)
end