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 = [
f_str_URL,
f_str_TrainID,
f_sw_Trigger,
f_str_Delay,
f_sw_CheckDelay,
f_sw_Notficiation|
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)
f_sw_CheckDelay.postUpdate(OFF)
while (found != 1 && nodata != 1 && i <= 20) {
trainNumber = transform("JSONPATH", "$.departures["+i+"].trainNumber", f_data)
if (f_str_TrainID == trainNumber) {
found = 1
f_sw_CheckDelay.postUpdate(ON)
f_timer_repeat = createTimer(now.plusSeconds(59), [|
f_sw_Trigger.postUpdate(ON)
])
var String delayDep = transform("JSONPATH", "$.departures["+i+"].delayDeparture", f_data)
f_str_Delay.postUpdate(delayDep)
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
f_sw_Notficiation.postUpdate(ON)
}
DB_NotiPlatform.postUpdate(f_message)
}
i = i + 1
}
if (found == 0) {
}
]
function call in rule “DB_Test”
DB_CheckTrain.apply(URL,Zugnummer,DB_request,DB_Delay,DB_CheckDelay,Notify)
Everything works well if I use code
f_str_Delay.sendCommand(delayDep)
instead of
f_str_Delay.postUpdate(delayDep)
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