I have been using OH2.0 for some time and recently moved to 2.1
I get this weird behavior that I don’t remember I saw before - the state of an item is updated after the rule started running:
Number boiler_p "Power" (Boiler)
rule "Boiler settings update"
when
Item boiler_p received command
then
logInfo("Boiler", receivedCommand.toString + " " + boiler_p.state);
Thread::sleep(500);
logInfo("Boiler", receivedCommand.toString + " " + boiler_p.state);
end
When I change the item’s state through the UI, the log output is usually:
To add a bit of explanation, sending an Item a Command does not automatically or immediately change its state.
Most items have the autoupdate feature left on by default, which you can think of like another binding. Eventually, autoupdate receives the Command and creates a state change for the Item. That might be before or after other bindings have dealt with the command (some bindings will update the Item then, some will wait for a response from an end device, some do nothing), and before or after rules have been triggered by the command etc.
You can have rules behaving more predictably by careful decisions about triggering on command, or on update, or on change.
You can make the Item behaviour different by turning autoupdate off for that Item.