Error: Cannot assign a value in null context

Hey all,

I just installed a new Schlage lock that is zwave compatible. I’ve got it paired up and can lock/unlock via openhab. There is also an alarm_raw channel that provides a JSON with some extra info like when the lock is operated manually or via keypad informs you via this item.

Examples of this output are as follows:

{"notification":"ACCESS_CONTROL__MANUAL_LOCK", "level":"1"	"type":"ACCESS_CONTROL","event":"1","status":"255"}
{"notification":"ACCESS_CONTROL__KEYPAD_LOCK", "level":"0"	"type":"ACCESS_CONTROL","event":"5","status":"255"}
{"notification":"ACCESS_CONTROL__MANUAL_UNLOCK", "level":"1"	"type":"ACCESS_CONTROL","event":"2","status":"255"}
{"notification":"ACCESS_CONTROL__KEYPAD_UNLOCK", "code":"3", "level":"3", "type":"ACCESS_CONTROL","event":"6","status":"255"}

The “event” item in this JSON is unique to the event happening so I can determine if the lock was manually or keypad operated to lock or unlock.

So, I’m trying to use JSONPATH transformation in a rule to get this bit out to do stuff with and I’m having issues:

From my .items file:

String  sidedoorlockAlarm       "Side Door Lock Alarm [%s]"                             <soundvolume-0> {channel="zwave:device:ddbf0ba4:node22:alarm_raw"}
String  sidedoorlockStatus      "Side Door Lock [%s]" 

Then my rule:

rule "sidedoor-lock"
                Item sidedoorlock changed or
                Item sidedoorlockAlarm changed
                sidedoorlockStatus = transform("JSONPATH", "$.event", sidedoorlockAlarm.state.toString)

I get the following error when I make the rule run:

2019-11-01 15:21:25.345 [vent.ItemStateChangedEvent] - sidedoorlockAlarm changed from {"notification":"ACCESS_CONTROL__MANUAL_UNLOCK","level":"1","type":"ACCESS_CONTROL","event":"2","status":"255"} to {"notification":"ACCESS_CONTROL__MANUAL_LOCK","level":"1","type":"ACCESS_CONTROL","event":"1","status":"255"}

==> /var/log/openhab2/openhab.log <==

2019-11-01 15:21:25.372 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'sidedoor-lock': An error occurred during the script execution: Cannot assign a value in null context.

Does anyone have any idea whats going on here?

That’s an Item, isn’t it?
I would guess that you are not really trying to replace your Item with something else, or otherwise destroy it.
Perhaps you are trying to set the Item’s state?


You might want to look at this post from @5iver:

Awesome! I don’t need to invent the wheel! Appreciate the pointer.