Thanks ![]()
That leaded me to the correct way of using the .state and now().minusHours(1)
I used the solution from this thread.
To verify the other method i also tried to use the compare with .calendar.timeInMillis and it´s not working.
Rule 1 (working):
rule "Test"
when
Item itmTestSwitch changed
then
val lastUpdate = new DateTime(iPMichael_LastUpdate.state.toString)
val timeCheck = new DateTime(now().minusHours(1).toString)
val test = (lastUpdate.isBefore(timeCheck))
logInfo("Test", "Test: " + test)
end
Rule 2 (not working):
rule "Test"
when
Item itmTestSwitch changed
then
val lastUpdate = new DateTime((iPMichael_LastUpdate.state as DateTimeType).calender.timeInMillis)
val timeCheck = new DateTime((now().minusHours(1) as DateTimeType).calender.timeInMillis)
val test = (lastUpdate.isBefore(timeCheck))
logInfo("Test", "Test: " + test)
end
Error:
2019-09-15 12:41:04.868 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Test': 'calender' is not a member of 'org.eclipse.smarthome.core.library.types.DateTimeType'; line 9, column 39, length 53