Allerdings ist die Prüfung in der Rule falsch, denn heute ist der erste Advent und da ist now.getDayOfYear = intStAdvent. Korrekt wäre also
Code: Alles auswählen
var Integer intStAdvent = 0
rule "Berechnung nach Mitternacht"
when
Time cron "5 0 0 * * ?" or
System started
then
val firstAdvent = LocalDate.of(now.getYear,12,25).minusDays(LocalDate.of(now.getYear,12,25).getDayOfWeek.getValue + 21)
intStAdvent = firstAdvent.getDayOfYear
logInfo("holiday","Der erste Advent ist am {}", firstAdvent)
end
rule "Weihnachtslicht ein"
when
Time cron "0 0 6 * * ?" or // morgens 6 Uhr
Time cron "0 30 16 * * ?" // nachmittags 16:30 Uhr
then
if (now.getDayOfYear < 7 || now.getDayOfYear >= intStAdvent) { // ab 1. Advent, inclusive
logDebug("x-mas","Weihnachtsbeleuchtung ein.")
Swi_Weihnachtsbaum.sendCommand(ON)
}
end
rule "Weihnachtslicht aus"
when
Time cron "0 0 8 * * ?" or // morgens 8 Uhr
Time cron "0 45 23 * * ?" // abends 23:45 Uhr
then
if (now.getDayOfYear < 7 || now.getDayOfYear >= intStAdvent) { // ab 1. Advent, inclusive
logDebug("x-mas","Weihnachtsbeleuchtung aus.")
Swi_Weihnachtsbaum.sendCommand(OFF)
}
end