I made a test rule. It is working, but it says, it is deprecated. Can someone tell me, how i can write this rule in the new format?
rule "System Test 1"
when
Item System_Test_1 changed
then
if(now.isBefore((Sonnenaufgang_Start.state as DateTimeType).calendar.timeInMillis)) {
logInfo("System Test 1", "System Test 1: now is before sunrise " + now + " --- sunrise: " + Sonnenaufgang_Start.state)
}
if(now.isAfter((Sonnenaufgang_Start.state as DateTimeType).calendar.timeInMillis)) {
logInfo("System Test 1", "System Test 1: now is after sunrise " + now + " --- sunrise: " + Sonnenaufgang_Start.state)
}
end
Is this the right way to write the rule in the new style? It is working for me without showing any errors in VS Code Editor.
if(now.isBefore((Sonnenaufgang_Start.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)) {
logInfo("System Test 1", "System Test 1: now is before sunrise " + now + " --- sunrise: " + Sonnenaufgang_Start.state)
}
if(now.isAfter((Sonnenaufgang_Start.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)) {
logInfo("System Test 1", "System Test 1: now is after sunrise " + now + " --- sunrise: " + Sonnenaufgang_Start.state)
}