OH3: Issues with lightrule and switch light depending on the position of the sun

Hi All,

I updated von 2.5 to 3.0. Within 2.5 I have following rule in place, which worked liked charme:

rule "Light - Eg_kue_Küchendeckenlicht zeitabhängig dimmen"

when

        Item EG_kue_li_decke changed to ON

then 

        logInfo("Info", "Light - Eg_kue_Küchendeckenlicht zeitabhängig dimmen rule Start")

        if ( now.isAfter((Sunrise_Time.state as DateTimeType).zonedDateTime.toInstant().toEpochMilli) || now.isBefore((Sunset_Time.state as DateTimeType).zonedDateTime.toInstant().toEpochMilli)) {

            logInfo("Info", "Es ist Tag")

            gEG_kue_ZigbeeBulb.members.forEach [ zigkue | sendCommand(zigkue,100) ]  

        }

After updating to OH3, I get the following error in the log:

 [ERROR] [.internal.handler.ScriptActionHandler] - Script execution of rule with UID 'Licht-25' failed: An error occurred during the script execution: Could not invoke method: java.time.chrono.ChronoZonedDateTime.isAfter(java.time.chrono.ChronoZonedDateTime) on instance: 2021-01-30T20:03:16.019011+01:00[Europe/Berlin] in Licht

I have no clue, what is wrong, but I think it could be related to the timezone, which wasn’t included in OH2.5.

Could someone help me here?

Thanks in advance.

1 Like

No one, who could give me some advises? I have no clue, what happened here.

Thx.

Yes you do. You updated OH 2.5 to 3, and your rule problem is something to do with datetimes.
Example of working with isAfter here

2 Likes

Thanks @rossko57, this was exactly the thread I was looking for. Helped a lot!

1 Like

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