Debugging (again)

Debugging rules is a pain!

We don’t have a debugger => OK,
We need to debug using the log mechanisms => OK,
but why can’t the log not tell us WHERE the hell the error occured???

All I get is:
Error during the execution of rule ‘HeatUpWhenEnoughPower’: An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.lib.NumberExtensions.operator_greaterThan(org.eclipse.smarthome.core.types.Type,java.lang.Number) on instance: null

Any chance to get a line number or any other option to point to the line where it fails?

Not from that.

The error points to a comparison involving >
And from experience, it’s most likely about typing of your variables.
You might have something like
if ( fred > mary )
where fred is an integer and mary is a number/decimal

Thanks for that hint.

I am a developer for 30 years now. I know WHAT is going wrong, that is not the problem.

the rule has several hundred lines with several comparisons.
It would still be of great help to know in which line the problem exists. All other is trial and error, not debugging!

Yes. It’s not likely to change at this point in DSL Rules lifecycle, but volunteer developers are always welcomed to add and improve features of this open source system.

Rules with several hundred lines are a bit suspect in concept, best use of DSL is made with short snappy event driven rules rather than long procedures.

The old rules DSL is a joke. Scripted automation with Jython and helper libraries provides much more detail when there are errors and is much easier to debug.

Well, as long as I cannot define functions/procedures/methods to call from a rule, all discussion about lengthy rules are useless.

the rules file consists of 13 event driven rules, but to decide if you should switch on the tub or not, based on several parameters, just needs a lot of comparisons.

Here the individual items to be taken into account:

PV_Meter.state (to know how much energy is currently on the way to or from the grid into the home)
KebaPlugLocked (to know if the electrical car is plugged in or not)
BALBOA_SET_TEMP (current set temp from tub)
BALBOA_MANUAL (Switch to heat up once only, but leave operation mode AUTO)

Would love to, but unfortunately no time for it.
I even do not know what Jython is, so would not be of great help either.