Weihnachtsmodus mit OH3

Einrichtung der openHAB Umgebung und allgemeine Konfigurationsthemen.

Moderatoren: seppy, udo1toni

Antworten
Benutzeravatar
djuscha
Beiträge: 130
Registriert: 14. Mai 2016 00:12
Answers: 0

Weihnachtsmodus mit OH3

Beitrag von djuscha »

Ich hatte Weihnachtsmodus Schalter in OH 2.5 mit dem ich Weihnachtsbeleuchtung schalte vom 1 Advend bis Silvester
Umstieg auf OH3 gibt es wieder Fehler, das war meine rule

Code: Alles auswählen

rule "Weihnachtsmodus an"
when
    Time cron "0 0 0 * * ?" or
    System started
then
    val year = now.getYear
    val month = now.getMonth //OfYear
    val day = now.getDayOfMonth
    val sdatum = year+"-"+month+"-"+day
    val DateTime datum = parse(sdatum)
    val DateTime stAdvent = parse(year + "-12-25").minusDays(((parse(year + "-12-25").getDayOfWeek) + 21))
    val DateTime endWeih = parse(year + "-1-1")    // parse(year + "-1-6") 
    logInfo("RULE", "--> Weihnachtsmodus. Datum: " + datum.toString + ". 1. Advent: " + stAdvent.toString + ". Silvester: " + endWeih.toString) 
    if ( stAdvent <= datum || datum <= endWeih ) {
        Weihnachtsbeleuchtung.sendCommand(ON)
        }
    else
       { Weihnachtsbeleuchtung.sendCommand(OFF)
        logInfo("RULE", "--> Weihnachtsmodus OFF")
       }
end
DateTime gibt es ja nicht mehr wenn ich das richtig verstanden hab . jetzt gibt es ZonedDateTime
also hab ich die Zeilen so geändert

Code: Alles auswählen

 
 
 val ZonedDateTime datum = parse(sdatum)
 val ZonedDateTime stAdvent = parse(year + "-12-25").minusDays(((parse(year + "-12-25").getDayOfWeek) + 21))
 val ZonedDateTime endWeih = parse(year + "-1-1")    // parse(year + "-1-6") 
jetz hab ich noch Fehlermeldungen mit parse

Code: Alles auswählen

Ambiguous feature call.
The methods
	parse(CharSequence) in Duration and
	parse(CharSequence) in ZonedDateTime
both match.
Type mismatch: cannot convert from Duration to ZonedDateTime
The method or field getDayOfWeek is undefined for the type Duration

Wie kann ich das jetzt anpassen?

Antworten