I have never seen nor heard of this happening or being reported on the log. It makes me think that either there is something else going on or this is a very new bug.
Are you on the snapshot?
Does it consistently get the wrong state or only sometimes?
What happens when you put a Thread::sleep for 20 msec or so in your alerting rule, does that fix it?
When using received command (which IMHO is the correct trigger in this case) what is the value of the implicit variable receivedCommand?
All things considered, were I to write Example 1 again today I would have:
rule "Dispatch Info Notification"
when
Item Notification_Proxy_Info received command
then
val String msg = receivedCommand.toString
logInfo("InfoNotif", msg)
if(TimeOfDay.state != "Night") notifyMyAndroid(msg)
end
rule "Dispatch Alarm Notification"
when
Item Notification_Proxy_Alarm received command
then
val String msg = receivedCommand.toString
logError("AlarmNotif", msg)
if(TimeOfDay.state == "Night") notifyMyAndroid(msg) else sendNotification("email", msg)
end
rule "Some random rule"
when
// something happens
then
// do some stuff
Notification_Proxy_Alarm.sendCommand("I have a serious alert!")
end
If there is a timing problem that should fix it because receivedCommand gets populated before the Rule itself gets triggered. Calling Notification.state would fail sometimes as populating the Item state happens in parallel with the Rule triggering and apparently in this case the Rule runs before the Item gets populated (again, assuming the problem really is one of timing).