postUpdate vs sendCommand (and use in rules changed vs update)

2,395 views
Skip to first unread message

Shawn Mix

unread,
Oct 4, 2014, 4:19:23 PM10/4/14
to ope...@googlegroups.com
I apologize for the amount of new posts I've been putting in as a new user but this seems the best front to get answers!! :)

I'm getting through some pretty advanced configs (in my mind at least) for temperatures, sunsets for lighting, automated alarming, etc. I've gone through and for the most part chose to work mostly with sendCommand arguments, and for rulers checking if an item changed from x to y or changed in general. Now the question I have (that I think I've finally come to identify) but want to validate:

What is the difference between the 2 and why use one over the other?

I think the answer is as follows, but looking for some validation:

sendCommand or use of Item received command
Used for actually sending a command to a device. In case of a physical device connected to something like a switch, this will actually issue the command to the device for ON or OFF. In cases of rule triggering, this is looking to validate that a device has actually received a Command as well (i.e. through an OpenHAB item switch being toggled in an app or browser, or a device in real world receiving an actual toggle of the light switch).

postUpdate or use of Item received update
Used for avoiding the need to send a Command to a device and change a physical state, it will just tell OpenHAB to update the value it has currently stored? I can postUpdate for a (Item LightSwitch) to OFF for example, and this will not actually change the light switch physical device to an OFF state. So this could be used to alter states in OpenHAB, but not affect the actual state of a device?

On the second explanation, I'm not exactly certain I can understand the specific use cases that could arise for this, but that's what I've been able to come up with as the differences for these 2 options. Someone please clarify if I'm off base, or if I'm correct help solidify my understanding.

Thomas E.-E.

unread,
Oct 6, 2014, 5:00:47 AM10/6/14
to ope...@googlegroups.com
Hi Shawn,

not quite correct. As described in the Wiki (see https://github.com/openhab/openhab/wiki#the-event-bus):

  1. Commands which trigger an action or a state change of some item/device.
  2. Status updates which inform about a status change of some item/device (often as a response to a command)
Think of a garage door as an example. You will send the "OPEN" command to the Door-Item which then will trigger the door to be opened and it will last at least 30 seconds to be opened. The state of the item should only be switched to OPEN once the door is REALLY open. So the command and the state must fell apart. 

Hope this helps,

Thomas E.-E.

Shawn Mix

unread,
Oct 6, 2014, 3:03:24 PM10/6/14
to ope...@googlegroups.com
Thomas,

Ok I think that helps a little better. Not sure why I didn't just understand from the wiki. :)

So if I'm looking at sending my own commands as part of a rule (i.e. turn a switch on) I would want to use sendCommand. But if perhaps I want to know when a rule has finished running and update a string item for example that highlights when my "bedtime" scene has been run, I would use postUpdate. And in reverse, if I'm looking to watch for something to happen in a rule, looking for the command is just when the initial command was received vs the state update is when the command completed, and the action has actually finished (like your garage door example). 

Thomas E.-E.

unread,
Oct 8, 2014, 4:14:10 AM10/8/14
to ope...@googlegroups.com
correct!
Reply all
Reply to author
Forward
0 new messages