[ERROR] [.script.engine.ScriptExecutionThread]

Seeing the following not very descriptive errors:

2017-06-28 19:22:31.221 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'Outside_Air_Sensor': 234
2017-06-28 19:22:33.740 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'Outside_Air_Sensor': 230
2017-06-28 19:22:36.256 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'Outside_Air_Sensor': 240
2017-06-28 19:22:38.773 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'Outside_Air_Sensor': 255
2017-06-28 19:22:41.291 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'Outside_Air_Sensor': 207

My rule:

import javax.xml.bind.DatatypeConverter
import java.nio.ByteBuffer

rule "Outside_Air_Sensor"
when
  Item Outside_Air_Sensor changed
then
  val to64 = DatatypeConverter::parseBase64Binary(Outside_Air_Sensor.state.toString)
  val ByteBuffer bb = ByteBuffer::wrap(to64)
  val short start = bb.getShort
  val short length = bb.getShort
  if (start==16973 && length==28) {
    val short pm1 = bb.getShort
    if (pm1>0) {
      postUpdate(Outside_PM1, pm1.toString) 
    }
    val short pm25 = bb.getShort
    if (pm25>0) {
      postUpdate(Outside_PM25, pm25.toString) 
    }
    val short pm10 = bb.getShort
    if (pm10>0) {
      postUpdate(Outside_PM10, pm10.toString)
    }
  } 
end

The issue is with:

val to64 = DatatypeConverter::parseBase64Binary(Outside_Air_Sensor.state.toString)

I am just not sure why it stopped working with latest release.

Anyone know why this stopped working or how to get more debug info?

First thing I would check is what Outside_Air_Sensor.state.toString is returning and making sure it continues to be what is expected. There might have been a change in the binding that populates it that changed making it not Base64 anymore.

Second, you can wrap the rule in a try/catch and print out any exceptions which might be thrown which the terse error logs you are getting are hiding.

when
    try {
        // your rule code
    }
    catch(Exception e) {
        logError("outside air", "Exception in rule 'Outside_Air_Sensor': " + e.toString)
    }
end

If that doesn’t catch anything change “Exception” to “Throwable” and see if that catches something.

Hopefully seeing what the exception is will be informative.

Often times when I’ve encoutered unexpected errors like these it is because an Item went to NULL unexpectedly (e.g. forgot to add it to restoreOnStartup, state lost during the upgrade, etc) and the Rule wasn’t written to handle that case.

Thanks! Looks like your first thought was correct, it looks like something broke in the serial binding. I downgraded it and now things work great.

2017-06-29 12:49:32.657 [ERROR] [e.smarthome.model.script.outside air] - Exception in rule 'Outside_Air_Sensor': java.lang.ArrayIndexOutOfBoundsException: 219
2017-06-29 12:49:35.178 [ERROR] [e.smarthome.model.script.outside air] - Exception in rule 'Outside_Air_Sensor': java.lang.ArrayIndexOutOfBoundsException: 185
2017-06-29 12:49:37.693 [ERROR] [e.smarthome.model.script.outside air] - Exception in rule 'Outside_Air_Sensor': java.lang.ArrayIndexOutOfBoundsException: 155
2017-06-29 12:49:40.210 [ERROR] [e.smarthome.model.script.outside air] - Exception in rule 'Outside_Air_Sensor': java.lang.ArrayIndexOutOfBoundsException: 143
2017-06-29 12:49:42.730 [ERROR] [e.smarthome.model.script.outside air] - Exception in rule 'Outside_Air_Sensor': java.lang.ArrayIndexOutOfBoundsException: 247
2017-06-29 12:49:45.247 [ERROR] [e.smarthome.model.script.outside air] - Exception in rule 'Outside_Air_Sensor': java.lang.ArrayIndexOutOfBoundsException: 248

It would be great if you extract a little bit more information maybe setting the log leve to debug helps otherwise. We should extend the log statement to include more information maybe the e.getMessage is enough but the stacktrace would also help, see for example some ideas here

I looked through the changes and I don’t not immediately spot a red flag.

Maybe @mhalmo can spot the problem, as far as I can see he did all the changes to the serial binding.