Problems with Rule since update to OH3 (DateTime cannot be resolved to a type)

Hello everyone,

i’ve managed to update to OH3 and got it slowly working besides of some RULE errors i got. Here is my example of one RULE

val ruleForLichtDiele = 60 * 5 // 5 minutes
var Timer alarmReminderTimer = null
var DateTime LichtLastON = null
val telegramAction = getActions("telegram","telegram:telegramBot:OpenHAB_Herbert_Bot")



rule "Send Reminder for Licht - An"

when
Item Tasmota_Diele_Switch changed to ON
then

if (alarmReminderTimer === null) {
	LichtLastON = now;
	logInfo("LichtDieleCheck-isOn", "LichtDiele ON @ " + LichtLastON.toString("dd/MM/yy HH:mm:ss") +
			" . Will check if still On in " + ruleForLichtDiele + " seconds."
	);
	
	alarmReminderTimer = createTimer(now.plusSeconds(ruleForLichtDiele), [|
		// Check every X seconds if OPEN
		
		// LichtDiele is still On
		if  (Tasmota_Diele_Switch.state == ON) {
			sendBroadcastNotification("Warning: LichtDiele remained On since " + LichtLastON.toString("dd/MM/yy HH:mm:ss") );
			
			
			alarmReminderTimer.reschedule(now.plusSeconds(ruleForLichtDiele));	
			logInfo("LichtDieleCheck-isOn","LichtDiele still On after " + ruleForLichtDiele + " seconds. Sending reminder.");
            telegramAction.sendTelegram("Herbert","Licht Diele ist an seit " + LichtLastON.toString("dd/MM/yy HH:mm:ss") )


		}
		// LichtDiele is still closed now			
		else {
			if (alarmReminderTimer !== null) {
				alarmReminderTimer.cancel();
			}
				
			alarmReminderTimer = null				
		}
         
	]);
} else {
	alarmReminderTimer.reschedule(now.plusSeconds(ruleForLichtDiele))
}
end

i got this errors in VSCode

and this in log after triggering RULE

2020-12-28 20:19:37.623 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'Alarm_licht.rules', using it anyway:

The field Tmp_Alarm_lichtRules.LichtLastON refers to the missing type Object

The field Tmp_Alarm_lichtRules.LichtLastON refers to the missing type Object

The field Tmp_Alarm_lichtRules.LichtLastON refers to the missing type Object

The field Tmp_Alarm_lichtRules.LichtLastON refers to the missing type Object

it has something to do with

 var DateTime LichtLastON = null

i’ve tried to search for a Solution but got no luck.

I use this version on other rules too and got issues there too.

Please advise.

PS: I’ll run OH3 in Docker on a RPi4 2GB and managing it with Portainer

Did you read DateTime Conversion (openHAB 3.x) ???

1 Like

Read…but cant figure out how to implement it for my example as i dont know coding so well

You set LichtLastOn = now. DateTimeType is not used anymore, so you should have LichtLastOn the same Type like now.

sorry…i’m kinda burned out right now. Can you please make the correction in my code so i can figure it out.

I’m struggeling with the same thing :frowning:

Any update and/or example code for this?

From the op of my head:

Try changing “DateTime” to “DateTimeType”

and

“now” to “now.toInstant()”

Hope this helps!