Difference between postupdates?

I’m wondering … what’s the difference between




honestly have no idea what’s the difference

It’s different programming paradigms.
See sendCommand() Documentation which applies likewise.

thanks, my search was probably broken :wink:

The big challenge with searching is knowing the terms to search for.
It may be possible of you knew what to search for you would not need to search. :thinking::crazy_face:

If you know what item you are sending the update to then use .postUpdate(xxx)
But if you don’t know what item it is and the item name is generated in the rule then you need to use the action postUpdate("ItemName", "xxx")

Does that make sense?

that makes perfect sense, thanks
simple explanations are always the best ones

That does not strictly fit, as it’s possible to use group functions to create an item, like this:

rule "Betriebsart RTR"
	Member of GHeat_Mode changed
	var Integer newMode 
	val mode = (triggeringItem.state as DecimalType).toBigDecimal.toBigInteger
	val iName = triggeringItem.name.split("_").get(0).toString
	logDebug("rtr","Name is: {}, Mode is: {}",iName,mode)
	switch (mode) {
		case mode.testBit(0) : newMode = 1
		case mode.testBit(2) : newMode = 3
		case mode.testBit(3) : newMode = 4
		default : newMode = 2
	var myItem = GHeat_Set.members.filter[ f | f.name.startsWith(iName) ].head
	var Integer oldMode = 0
	if(myItem.state instanceof Number) oldMode = (myItem.state as Number).intValue
	if(oldMode != newMode) {
		logDebug("rtr","Name is: {}, oldMode is: {}, newMode is: {}",myItem.name,oldMode,newMode)

This rule will trigger from a changed item in one group and will change another item in another group accordingly. Name from the other item can be deduced from the one item.

The main difference is, that the action postUpdate(Item,Value) is defined as postUpdate(<String>,<String>) while the Method Item.postUpdate(Value) is not restricted to StringType for <Value>. Does that make sense? You will hit problems if using Primitives for <Value>, as there is no .toString method for primitives, so openHAB is not able to change the input to String on the fly. Please read

for details.

1 Like