Rule error after openhab update

Since I updated to the last snapshot yesterday I get this error message:

8:34:10.302 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'leds01_trigger_rule': An error occured during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.sendCommand(org.eclipse.smarthome.core.items.Item,org.eclipse.smarthome.core.types.Command) on instance: null

The following lines from the rule cause the problem. They send the the color (color/saturation/brightness) values (c_csb0x) to my led controllers (c_led0x). I’m using the wifi-led binding.

c_csb01 = c_col01 + "," + c_sat01 + "," + c_bri01
c_csb02 = c_col02 + "," + c_sat02 + "," + c_bri02
c_csb03 = c_col03 + "," + c_sat03 + "," + c_bri03    
sendCommand(c_led01, c_csb01)
sendCommand(c_led02, c_csb02)
sendCommand(c_led03, c_csb03)

I changed nothing in the rule so normally it should work but after the update it’s broken and I don’t know why.
Does anyone have an idea?

Check the actual states, values of your itmes, variables by using logInfo like:

logInfo(“MyRuleName”, “c_led01: {}” ,c_led01.state)
logInfo(“MyRuleName”, “c_csb01: {}” ,c_csb01)

That way you will see which item/variable is Null!

I get this result:

21:06:11.240 [INFO ] [eclipse.smarthome.model.script.DEBUG] - c_led01: {}0,0,0
21:06:11.243 [INFO ] [eclipse.smarthome.model.script.DEBUG] - c_csb01: {}15,100,55

My item:

Color c_led01 “LEDs Fenster” (c_LEDS) {channel=“wifiled:wifiled:ACCF23xxxxxx:color”}

So my item is null and it’s an problem with the binding?! :confused:

In my understanding the color-state of your c_led01 is 0,0,0 and not NULL!
Check all items and variables!

Now I shortened my rule to just this:

rule “c_leds01_trigger_rule”

when
Item c_led01_trigger received command
then

c_csb01 = c_col01 + “,” + c_sat01 + “,” + c_bri01

logInfo(“DEBUG”, "c_led01: {}: " + c_led01.state)
logInfo(“DEBUG”, "c_csb01: {}: " + c_csb01)

sendCommand(c_led01, c_csb01)

end

But I still get this output:

16:27:50.294 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'c_led01_trigger' received command 1
16:27:50.302 [INFO ] [eclipse.smarthome.model.script.DEBUG] - c_led01: {}: 0,0,0
16:27:50.306 [INFO ] [eclipse.smarthome.model.script.DEBUG] - c_csb01: {}: 15,100,55
16:27:50.310 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'c_leds01_trigger_rule': An error occured during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.sendCommand(org.eclipse.smarthome.core.items.Item,org.eclipse.smarthome.core.types.Command) on instance: null

I don’t see anything which could be null :sob:

Is c_led01 a StringItem? You may want to declare c_csb01 as

Var String c_csb01 

as the sendCommand error says that it is typing it as a State, or use c_csb01.toString to ensure the type is right
Also, have you tried

c_led01.sendCommand(c_csb01)

I believe that is the recommended method

c_csb01 is declared as a string and initialized.

c_led01 is a color item from my *.items file:

Color c_led01 “LEDs Fenster” (c_LEDS) {channel=“wifiled:wifiled:ACCF23xxxxxx:color”}

That leads to the same error.

I tried to send the command manually via the console with the command:

smarthome:send c_led01 "15,100,55"

this just works fine!

ahh, I haven’t worked with color items before. have you tried:

c_led01.sendCommand(c_csb01.toString) 

to ensure the item is typed as a string?

with that I get this error:

19:09:55.465 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'c_leds01_trigger_rule': An error occured during the script execution: The name '<XFeatureCallImplCustom>.toString' cannot be resolved to an item or type.

this language is frustrating… try declaring the type of c_csb01:

var String c_csb01
1 Like

:grinning:

Thanks, that’s it! :smile::blush:

And guess what worked fine before I made the update two days ago:

var string c_csb01

So it has to be something of openhab that caused the error. :smirk:

I think the error checking in the more recent releases is more strict (exists) I found a lot of my rules and even my sitemap had errors in them that were previously ignored. I had to work through them. Fortunately if you look in /var/log/openhab2/openhab.log it tells what line the error is on in the file. :slight_smile: