Code: Alles auswählen
import java.time.ZoneId
import java.time.Instant
import java.time.ZonedDateTime
import java.util.Map
rule "Test Zeit Schalter"
when
Time cron "0 0/1 * 1/1 * ? *" // Jede Minute
then
var ZoneId z = ZoneId.of ( "Europe/Vienna" );
var ZonedDateTime now = ZonedDateTime.now( z );
var ZonedDateTime startOfDay = now.toLocalDate().atStartOfDay( z );
var Duration duration = Duration.between( startOfDay , now );
var long minutesIntoTheDay = duration.toMinutes();
var stunde = 13
var minute = 25
var minutenges = stunde * 60 + minute
logInfo("Test Zeit Schalter", "z : {}, now : {}, startOfDay : {}, duration : {}, minuteIntoTheDay : {}", z, now, startOfDay, duration, minutesIntoTheDay)
logInfo("Test Zeit Schalter", "Zielzeit : {} , Istzeit : {}", minutenges, minutesIntoTheDay)
if(minutenges < minutesIntoTheDay){
logInfo("Test Zeit Schalter", "Zielzeit kleiner Istzeit : Schalter EIN")
TestSchalter.sendCommand(ON)
}
else
{
TestSchalter.sendCommand(OFF)
logInfo("Test Zeit Schalter", "Zielzeit größer Istzeit : Schalter AUS")
}
end