What is the difference between postUpdate and sendCommand in openHAB

In the 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 changes, no action is taken - the light remains dark. sendCommand(zwaveLamp1, ON) will perform the associated action and turn on the light, and the item will be updated.

What is the use postUpdate ? What is this good for?

+6
source share
3 answers

Yes, correct from my point of view. postUpdate works "internally" on the element, sendCommand executes the "command" with respect to the peripheral / interface. marco

0
source

Commands are discrete, while states seem more fleeting. That is, if you run a rule called by the “received Item X command”, you can use the “receivedCommand” variable in the rule to execute something, and the rule runs for each command. However, you must read the current state from the element or use the previous state for the previous state.

I found for an element that updates its state a lot, it works for one change, but by the time you read the state of the element, it may change again; the current value is always returned. This is how it should be. If, however, you use the state as a pseudo-inbound queue from MQTT or some external source, you will lose messages. If they come in as teams, you will not.

+1
source

You can make the switch element snap to zero; let's say you want to make an EmailToggle switch element. If you set the switch on the map of your site, you can enable and disable email; then, at startup, you can publish it and set it from unified to OFF or ON. You can then use the switch to determine if you want the emails to run based on the rule.

I saw this work, and I saw that it does not work. It seems to be buggy.

0
source

Source: https://habr.com/ru/post/983631/


All Articles