Time conversion OH3

Hello everyone,
Unfortunately, I can’t handle a simple rule that worked for OH 2.5.

if (now.toLocalTime().isAfter(10, 0) && now.toLocalTime().isBefore(10,5))
logInfo(“rules”, “OK”)

Script execution of rule with UID ‘ontozorendszer-1’ failed: An error occurred during the script execution: Could not invoke method: java.time.LocalTime.isAfter(java.time.LocalTime) on instance: 15:34:00.583734 in ontozorendszer

Can you help me?


don’t post into others’ threads let alone ‘solution’ threads.
Mind the rules please. Thank you.

How to ask a good question / Help Us Help You - Tutorials & Examples - openHAB Community

Tested, working

var on_hours  = 10
var on_mins   = 55
var off_hours = 11
var off_mins  = 55
var starTimer = ZonedDateTime.now().with(LocalTime.MIDNIGHT).plusHours(on_hours).plusMinutes(on_mins)

var stopTimer = ZonedDateTime.now().with(LocalTime.MIDNIGHT).plusHours(off_hours).plusMinutes(off_mins)

if(now.isAfter(starTimer) && now.isBefore(stopTimer))
    logInfo("rules", "Test Entering OK")
1 Like