OH3 - Calender Rule Questions

Hello,

i used a rule in Openhab 2.5 to get message for Trash pickup.(ICalender Binding with Google Calendar?

Binding is working, Items showing correct content.

The rule was (Send at 7 p.m. the pickup for next day, Appointment is for whole day in calendar):

rule "Meldung Müll"
when
    Time cron "0 0 19 1/1 * ? *"
then
    if (now.isAfter(new DateTime((Naechste_Abholung_Muell_Datum.state as DateTimeType).getCalendar().getTime()).minusHours(24))) {//&&
        sendBroadcastNotification("Abholung morgen: " + Naechste_Abholung_Muell_Name.state.toString)
        }
        else sendNotification("XXX@XXX.de", "Morgen keine Abolung")
end

Now, i know on Openhab 3 i need to create new, but I don’t know how (I still dont understand my old rule :wink:

I would be happy for some hints.

Greetings
Sebastian

I found the solution.

This code is working, if someone need it:

rule "Müll Kalender"
when
    Time cron "0 0 19 1/1 * ? *"
then
    val JD_nAM = (Naechste_Abholung_Muell_Datum.state as DateTimeType).getZonedDateTime()
    if (now.isAfter(JD_nAM.minusHours(24))) {
    sendBroadcastNotification("Abholung morgen: " + Naechste_Abholung_Muell_Name.state.toString)
    }
    else
    sendNotification("XXX@XXX.de", "Morgen keine Abholung")
end

Please let me know, if there are better solutions.

1 Like