Failed: 'getMinuteOfDay'

Dear all,
I need an advice.
I have just moved from OH 2.5 to OH3.

The following rule doesn’t work anymore:

Item Ingresso_IR changed from OFF to ON
if (now.getMinuteOfDay > 1380 || now.getMinuteOfDay < 360 + 45 ) {
createTimer (now.plusMinutes(5), [ | Tasmota_02.sendCommand(OFF) ] )

and the below error messages is in the log:

… failed: ‘getMinuteOfDay’ is not a member of ‘java.time.ZonedDateTime’…

Can you suggest how to fix it?


Check this. Should help DateTime Conversion (openHAB 3.x)

Add this to the top of your rule file

import org.openhab.core.model.script.ScriptServiceUtil

val getMinuteOfDay= [ZonedDateTime x |
    val int minutesOfDay= (x.getHour() * 60) + x.getMinute()

and your item code changes to

            var curTime = new DateTimeType(BlindsClosedBy.state.toString("yyyy-MM-dd'T'HH:mm:00.000Z")).zonedDateTime
            blindsClosedBy = getMinuteOfDay.apply(curTime)

I don’t understand your currTime line. BlindsClosedBy is already a DateTimeType. So why create a new DateTimeType by forcing it to parse the DateTimeType you already have? Why not

var currTime = (BlindsClosedBy.state as DateTimeType).getZonedDateTime