In a rules file in openHAB I can execute postUpdate
and sendCommand
. What is the difference?
I noticed, that when I use postUpdate(zwaveLamp1, ON)
, only its value is changed, no actions are performed - the light stays dark. sendCommand(zwaveLamp1, ON)
will perform the bound action and switch the light on and the item is updated.
Whats the use case of postUpdate
? What is it good for?
Commands are discrete, whereas states appear to be more fleeting. That is, if you run a rule triggered by "Item X received command", you can use the variable "receivedCommand" in the rule to execute something, and the rule gets triggered for every command. However, you have to read the current state off the Item or use previousState for the previous state.
I found for an item that updates its state a lot, the gets triggered for one change, but by the time you read the item's state it may have changed again; it's always the current value that is returned. That's exactly how it should be. If, however, you're using the state as a pseudo incoming queue from MQTT or some external source, you'll lose messages. If they come in as commands, you won't.