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.
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.
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.