Howto Compare 2 Dates in a rule?

I am a newbie and my english is … 20 years old :slight_smile:

i got a problem with a (for you simple) openhab2 rule.
what i want is : if Current_Date = iTrashBrown then Alex should remind me

Switch UpdateTrash
String Alexa_Remind "Remind" {channel="amazon....:remind"} 
DateTime iTrashBrown "Braune Tonne [%1$td.%1$tm.%1$tY]"
DateTime Current_DateTime "Today [%1$td.%1$tm.%1$tY]"  {channel="ntp:ntp:local:dateTime"}

BasicUI shows : iTrashBrown 14.03.2018, Current_Datetime 07.03.2018

Alexa_Remind is ok, i have tried it with a switch changed to ON rule.

rule "comparedates"
     	Item UpdateTrash changed to ON
	Alex_Remind.sendCommand("the brown trashcan")
	Current_Date = iTrashBrown

Thanks for your help!

Might you try to use a cron trigger instead to determine the date? Here’s how I remind myself that the trash needs to go out. I use this notification item with the informational-header widget in HABPanel.

rule "Setting Trash Day State"

//  Run this rule at 9am on Wed and Thur
       Time cron "0 0 9 ? * WED,THU"
//       Time cron "0 10 18 ? * *"

// What day of the week is it
    val dow = now.getDayOfWeek
    logInfo("HouseStates", "Today is :" + dow)

// Trash day is on Thursday (4), set reminder a day early Wednesday (3)
    if(dow == 3) {

       logInfo("HouseStates", "Setting Trash Day State ON")

    } else {

// When day of week is != 3 it must be Thursday. Trash is picked up by 9am so turn off Notification
       logInfo("HouseStates", "Setting Trash Day State OFF")



You can’t compare dates with an = sign. The datetime object also includes the time down to the millisecond, I believe. You would have to be incredibly lucky to get them equal.
You could try to extract the date and a string for each object in 2 string variable and compare those.
In my case, I use the caldav binding with google calendar.
Scheduling for openHAB is a hot topic and is planned for a future update.
The devs are aware that this is a very often requested feature.