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