Rules: postupdate/sendcommand are empty?

I’m using a ECMA-rule to fetch a JSON (from my Nuki) and want to use the results to update my items.
So, basically the rule is:

var logger = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID);
var client =;

function httpGet(uri) {
  try {
    var request =
      var response = client.send(request,;
      return response;
  } catch (e) {

var result = JSON.parse(httpGet("http://192.168.xx.yy:8080/list?token=xxxxx&nukiid=xxxxx").body());

// Infos rausziehen"nuki: " + result[0].lastKnownState.state);"nuki: " + result[0].lastKnownState.state.toString());

events.postUpdate("NukiSmartLock_LockState", result[0].lastKnownState.state.toString());

The JSON looks like this

[{"deviceType": 0, "nukiId": xxx, "name": "BinderTür", "firmwareVersion": "2.9.10", "lastKnownState": {"mode": 2, "state": 1, "stateName": "locked", "batteryCritical": false, "batteryCharging": false, "batteryChargeState": 86, "doorsensorState": 2, "doorsensorStateName": "door closed", "timestamp": "2021-01-25T09:26:58+00:00"}}]

what I get in the logs is a bit strange, even after I added “.toString()” to it:

2021-01-25 10:56:25.424 [INFO ] [org.openhab.rule.NukiStatusPoll     ] - nuki: 1
2021-01-25 10:56:25.434 [INFO ] [org.openhab.rule.NukiStatusPoll     ] - nuki: 1
2021-01-25 10:56:25.528 [WARN ] [e.automation.internal.RuleEngineImpl] - Fail to execute action: 2
java.lang.IllegalArgumentException: The argument 'state' must not be null.
	at ~[?:?]
	at ~[?:?]

so, what do I miss?

I was getting this same error at one point when the string command I was sending could not be cast to the correct type for the item state. What type of item is NukiSmartLock_LockState, are you expecting it to be able to cast “1” to an open/closed or on/off state?

1 Like

NukiSmartLock_LockState is a Number, so I changed it to “parseInt(result[0].lastKnownState.state)” and now it works…
So, the error is misleading and not the correct description of the error… :wink:

all in all, that’s a bit of a backlash against the DSL rules, which (mostly) allowed not only “String”-variables, but also did the correct casting for you (and also “false” to “OFF” etc…).