How to find position of null in rule?

Hello,

sorry if I ask a rather stupid question, but my logs are full of lines like this

[ERROR] [.script.engine.ScriptExecutionThread] - Rule 'Light on PIR': null

and I have no idea, where in the script the null occurs, neither what the reason is for it. Is it possible to somehow find out where exactly in the script the “null” has been, similar to the NullPointerException in Java, where it’s pretty easy to figure out the reason?

maybe we can combine it with this topic:

Not really the same but goes in the same direction.

How to debug rules?
How to identify exceptions?

I’m interesting is this too.

Some guidance here


In essence, add logInfo lines to Rules to record progress and values of interest, and find out how to view the logs

Hello @rossko57

thanks for your reply. Oh - okay, so I really have to do logging before each statement, which is, however when using multiple statements in a line not possible, so I have to split up a line like

val pir = gPIRLight.allMembers.filter[s|s!=null].sortBy[lastUpdate].last

to see what’s happening (I currently suspect this line to produce a null as the next line is just a log output and sending a email with pir.label).