hilfe bei openHAB 3 astro
Verfasst: 2. Jan 2021 23:01
Nabend,
bin aktuell dabei rules auf OH3 anzupassen
es geht um diese .rule
habe den zweiten teil der rule schonmal probiert und diese geht auch soweit
weiß aber nicht genau wie ich die anderen beiden machen könnte.
wenn ich die astro.rule so 1 zu 1 auf OH3 ziehe funktioniert diese nicht
deswegen ist der plan es neu zumachen
LG
Florian
bin aktuell dabei rules auf OH3 anzupassen
es geht um diese .rule
Code: Alles auswählen
val String filename = "astro.rules"
rule "OpenHAB system started - astro"
when
System started
then
createTimer(now.plusSeconds(180)) [|
logInfo(filename, "--> astro init")
if (now.isAfter((Sunset_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli) ||
now.isBefore((Sunrise_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli)
) {
Night_State.postUpdate(ON)
} else {
Night_State.postUpdate(OFF)
}
]
end
rule "Update Night_State"
when
Item Sun_Elevation changed
then
if (Sun_Elevation.state > 0) {
if (Night_State.state != OFF) Night_State.postUpdate(OFF)
} else {
if (Night_State.state != ON) Night_State.postUpdate(ON)
}
end
rule "Calculate time of day state"
when
System started or
Channel 'astro:sun:home:rise#event' triggered START or
Channel 'astro:sun:home:set#event' triggered START or
Channel 'astro:sun:minus90:set#event' triggered START or
Time cron "0 0 6,23,0 * * ? *"
then
//Thread::sleep(1000) // make sure we are a tad past midnight to give Astro a chance to recalculate DateTimes for today
val long morning_start = now.withTimeAtStartOfDay.plusHours(6).millis
val long day_start = (Sunrise_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli
val long afternoon_start = (Evening_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli
val long evening_start = (Sunset_Time.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli
val long night_start = now.withTimeAtStartOfDay.plusHours(23).millis
val long bed_start = now.withTimeAtStartOfDay.millis
var curr = switch now {
case now.isAfter(morning_start) && now.isBefore(day_start): "MORNING"
case now.isAfter(day_start) && now.isBefore(afternoon_start): "DAY"
case now.isAfter(afternoon_start) && now.isBefore(evening_start): "AFTERNOON"
case now.isAfter(evening_start) && now.isBefore(night_start): "EVENING"
case now.isAfter(night_start): "NIGHT"
case now.isAfter(bed_start) && now.isBefore(morning_start): "BED"
}
if (Time_Of_Day.state.toString != curr) {
logInfo(filename, "Current time of day is now " + curr)
Time_Of_Day.postUpdate(curr)
}
end
weiß aber nicht genau wie ich die anderen beiden machen könnte.
wenn ich die astro.rule so 1 zu 1 auf OH3 ziehe funktioniert diese nicht
deswegen ist der plan es neu zumachen
LG
Florian