Openhab logs not being very helpful

Hello,

I’m currently trying to migrate from OH 1.x to OH 3.4
I’m running into problems executing my rules. Also the logs are quite cryptic.
What I’m getting in the logs is:

2023-01-16 17:53:41.458 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘default-4’ failed: An error occurred during the script execution: index=0, size=0 in default

Tried putting some logs in the coding, and it seems execution stops at this point:

if( Check_Shutters_Up_Close == true &&
(new LocalTime().getLocalMillis() >= new LocalTime(19,40,0,0).getLocalMillis() ||
Tlight.state < 10
)
)

I’m suspecting something is wrong in the LocalTime part. Probably something has changed since OH1, question is what to use then?

Indeed, almost everything having to do with date times has changed since OH 1.

In your rules you will have access to java.time.ZonedDateTime for all your time based operations. See ZonedDateTime (Java SE 11 & JDK 11 ).

That operation in Rules DSL would look like:

now.isAfter(now.withHour(19).withMinute(40).withSecond(0).withNanos(0))

Of course there are other ways to do it as well. If you want to continue to use LocalTime, you can but you’ll have to import it from java.time.LocalTime. Pay attention though as there are subtle differences between what was available in OH 1 and the Java time libraries.

But in general, you should never need to mess with epoch and milliseconds. The code is longer and harder to read, understand and maintain.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.