Issue with assigning a value to a String Item: Cannot assign a value in null context

Hi guys,

I got a strange behaviour with a String-Item in a file-based rule, and its driving me nuts.
Every time I try to assign a value to this Item, I get a Error-message, which says, that the item is NULL, and I cannot assign a value to it.

Item Definition

String securityTriggerItem "State [%s]"  {expire= "120m, command=NONE"}

Rule definition

sendCommand(securityTriggerItem, “trigger”)

The result is a NullPointerException.

When trying to create a new String-Object, the Error is the following:

securityTriggerItem = new String ()

results in:

An error occurred during the script execution: Cannot assign a value in null context.

There are no overlapping events, and it is also not during startup of OH, as suggested in other posts.

If anyone has an idea, I would be really grateful.

  • Platform information: Openhab 3.3.0 (Dockerized)
  • openHAB version: 3.3.0

I think the problem is in the


Instead try e.g.
String securityTriggerItem "State [%s]" {expire= "120m, state=''"}

As per my understanding the send ommand function is expecting the item name as string:


The approach to pass a String as first parameter actually worked.
A quick check in my other code revealed, that I always used the Item-name itself as parameter, which also worked fine.
Not sure why a String-Item requires special treatment here.

Thank you for your support, I thought I’m going crazy.

Within a DSL rule you should also be able to do


If that’s more convenient for you

1 Like