Reuseable functions -> Error while using postUpdate

I have a problem while using postUpdate in reuseable function.
Log file shows following
[ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘DB Test’: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.postUpdate(java.lang.String,java.lang.String) on instance: null

code snipped

val org.eclipse.xtext.xbase.lib.Functions$Function6 DB_CheckTrain = [

var String trainNumber = "0"
var Number found = 0
var Number nodata = 0
var Number i = 0
var Timer f_timer_repeat = null
var String f_data = sendHttpGetRequest(f_str_URL)
while (found != 1 && nodata != 1 && i <= 20) {
	trainNumber = transform("JSONPATH", "$.departures["+i+"].trainNumber", f_data)
	if (f_str_TrainID == trainNumber) {
		found = 1
		f_timer_repeat = createTimer(now.plusSeconds(59), [|
		var String delayDep = transform("JSONPATH", "$.departures["+i+"].delayDeparture", f_data)
		var String scheduledPlatform = transform("JSONPATH", "$.departures["+i+"].scheduledPlatform", f_data)
		var String platform = transform("JSONPATH", "$.departures["+i+"].platform", f_data)

		var String f_message = ""
		if (scheduledPlatform != platform){
			f_message = "Heute Gleis " + platform
	i = i + 1
if (found == 0) {


function call in rule “DB_Test”

Everything works well if I use code
instead of

As far as I understood sendCommand should be used if it is required to update a variable which will be used in sitemaps, but “f_str_Delay” is only use in the function.

Using postUpdate with other variables in the function causes no problems.
Hope someone can explain

  • Platform information:
    • Hardware: Raspberry Pi
    • OS: Jessie
    • Java Runtime Environment: 1.8.0_171_b11
    • openHAB version: 2.2.0

thanks, Markus

I think, sendCommand and postUpdate are both commands to change items.
If delayDep is a item, use delayDep.state.

This is incorrect.

Use sendCommand when you want that new state to go out through the binding to cause the Device to take some action. For example, to turn on a light you use sendCommand.

Use postUpdate when you only want to update the state within OH for that Item. When you use postUpdate only the Item state changes and the new value does not get sent out through the binding to the device. You usually use postUpdate for Items used as internal values to OH or to update an Item based on feedback from the device (e.g. a light is manually turned on, that gets reported to OH so we use postUpdate to change the state of the Item representing that light without sending the ON command back to the light).

In both cases, postUpdate and sendCommand are only valid for Items, not variables. You do not show what gets passed to this lambda and you do not specify the types of the arguments so I can’t say whether postUpdate or sendCommand apply to all of these arguments.

That is indeed odd behavior. What type of Item is f_str_Delay and what is the format of delayDep?

delayDep ist defined AS String in items File
f_str_Delay was also defined AS String in the header of function during first tests. I checked some other lambda description and they did not define those variable.

function call in rule “DB_Test”

That still doesn’t tell me what type URL, Zugnummer, DB_request, DB_Delay, DB_CheckDelay, Notify are.

And yet you are getting warnings in VSCode and in openhab.log over the fact that you are not defining the types of the arguments to the lambda.

See Reusable Functions: A simple lambda example with copious notes