der Sommer naht und auch wenn unsere Sonnenautomatik im großen und ganzen funktioniert, lese ich gerade mit Begeisterung die einzelnen Threads dazu und evtl. schaffen wir ja durch eine geschickte Verquickung der Lösungen eine Forums-Variante zu erstellen.
Ich verzichte mal auf die Items der Rollladen, da diese über UP/DOWN oder auch direkt über einen Position angefahren werden können.
Die später verwendete "SonneS_aus.state == 0" setze beim auffahren der Rollladen, sofern eine gewisse Temperatur erwartet wird
Code: Alles auswählen
rule "Sonnenschutzautomatik"
when
Item SunProtection changed
then
val mailActions = getActions("mail","mail:smtp:xyc")
if (SunProtection.state == ON) {
ManSunProtection.postUpdate(OFF)
mySunProtectionVis.postUpdate(ON)
mailActions.sendMail("abc@api.prowlapp.com", ""+ tempmax + " Grad erwartet.", "Sonnenschutzautomatik EIN: " + OffsetDateTime.now().toString)
SonneS_aus.postUpdate(0)
} else if (SunProtection.state == OFF) {
mySunProtectionVis.postUpdate(OFF)
mailActions.sendMail("abc@api.prowlapp.com", "Info", "Sonnenschutzautomatik AUS: " + OffsetDateTime.now().toString)
SonneS_aus.postUpdate(1)
}
end
Code: Alles auswählen
/* benötgte Variablen */
var int hoehe1 = 0 //wird für die Höhe der Rollos benötigt
var int hoehe2 = 0 //wird für die Höhe der Rollos benötigt
var int hoehe3 = 0 //wird für die Höhe der Rollos benötigt
var int hoehe4 = 0 //wird für die Höhe der Rollos benötigt
var int hoehe5 = 0 //wird für die Höhe der Rollos benötigt
var int tempmax = 0
rule "SunProtection"
when
Item azimuth received update
then
/* Fuellen der Variablen */
val mailActions = getActions("mail","mail:smtp:xyz")
var int azimuth = (azimuth.state as DecimalType).intValue
var int elevation = (elevation.state as DecimalType).intValue
var int min = now.toLocalTime.getHour // es werden die Minuten das Tages gezählt z.b 9:00 Uhr > 540 Min
tempmax = (Weather_Temp_Max_0.state as DecimalType).intValue
switch (tempmax) {
case (tempmax >= 20 && tempmax <=26): {hoehe1 = 85 hoehe2 = 75 hoehe3 = 55 hoehe4 = 45 hoehe5 = 0} // Höhe des Rollos je nach Temperatur
case (tempmax >= 27 && tempmax <=31): {hoehe1 = 90 hoehe2 = 80 hoehe3 = 55 hoehe4 = 50 hoehe5 = 0}
case (tempmax >= 32 && tempmax <=45): {hoehe1 = 100 hoehe2 = 90 hoehe3 = 80 hoehe4 = 70 hoehe5 = 0}
default: {hoehe1 = 0 hoehe2 = 0 hoehe3 = 0 hoehe4 = 0 hoehe5 = 0}
}
logInfo("Sun_Protection","azimuth: {}",azimuth)
logInfo("Sun_Protection","elevation: {}",elevation)
logInfo("Sun_Protection","Minuten heute: {}",min)
logInfo("Sun_Protection","tempmax: {}",tempmax)
logInfo("Sun_Protection","Sonne Ost: {}",sonneost.state)
logInfo("Sun_Protection","Sonne Sued: {}",sonnesued.state)
logInfo("Sun_Protection","Sonne West: {}",sonnewest.state)
logInfo("Sun_Protection","SonneS aus: {}",SonneS_aus.state)
logInfo("Sun_Protection","Hoehe 1: {}",hoehe1)
logInfo("Sun_Protection","Hoehe 2: {}",hoehe2)
logInfo("Sun_Protection","Hoehe 3: {}",hoehe3)
logInfo("Sun_Protection","Hoehe 4: {}",hoehe4)
logInfo("Sun_Protection","Hoehe 5: {}",hoehe5)
logInfo("Weather","Condition: {}",Condition.state)
/* ################################################################# */
/* Sonnenschutz OST */
if (SonneS_aus.state == 0 && sonneost.state == 0 && tempmax >= 20 && azimuth >= 50 && azimuth <= 135 && elevation >=5) {
mailActions.sendMail("abc@api.prowlapp.com", "Information", "Sonnenschutz Ost - Stufe 1")
/* Rollladen Nord */
Kueche_rechts_Rollo.sendCommand(hoehe3)
Flur_Rollo.sendCommand(hoehe3)
/* Rollladen Ost */
Bad_Rollo.sendCommand(hoehe2)
Kind1_Strasse_Rollo.sendCommand(hoehe2)
GaesteWC_Rollo.sendCommand(hoehe2)
/* Rollladen Sued */
Kind1_Widerkehr_Rollo.sendCommand(hoehe5)
Schlaf_Widerkehr_Rollo.sendCommand(hoehe5)
Terrasse_links_Fenster_Rollo.sendCommand(hoehe5)
Terrasse_links_Tuere_Rollo.sendCommand(hoehe5)
Terrasse_rechts_Tuere_Rollo.sendCommand(hoehe5)
Terrasse_rechts_Fenster_Rollo.sendCommand(hoehe5)
/* Rollladen West */
Schlaf_Garten_Rollo.sendCommand(hoehe5)
Lea_Rollo.sendCommand(hoehe5)
Esszimmer_links_Rollo.sendCommand(hoehe5)
Esszimmer_rechts_Rollo.sendCommand(hoehe5)
Kueche_links_Rollo.sendCommand(hoehe5)
sonneost.postUpdate(1)
println("Sonne Ost- ")
logInfo("Sun_Protection","Sonnenschutz Ost - Stufe 1")
} else if (SonneS_aus.state == 0 && sonneost.state == 1 && azimuth >= 128 && elevation >= 10) { // Sonne scheint jetzt von Süd-Ost.
mailActions.sendMail("abc@api.prowlapp.com", "Information", "Sonnenschutz Ost - Stufe 2")
/* Rollladen Nord */
Kueche_rechts_Rollo.sendCommand(hoehe5)
Flur_Rollo.sendCommand(hoehe5)
/* Rollladen Ost */
Bad_Rollo.sendCommand(hoehe2)
Kind1_Strasse_Rollo.sendCommand(hoehe2)
GaesteWC_Rollo.sendCommand(hoehe2)
sonneost.postUpdate(2)
println("Sonne -Ost-, Rollo auf wenn Sonne im Süden ")
logInfo("Sun_Protection","Sonnenschutz Ost - Stufe 2")
} else if (SonneS_aus.state == 0 && sonneost.state == 2 && azimuth >= 220 && elevation <= 60) { // Rollos auf, ohne wenn und aber
mailActions.sendMail("abc@api.prowlapp.com", "Information", "Sonnenschutz Ost - Stufe 3")
/* Rollladen Ost */
Bad_Rollo.sendCommand(hoehe5)
Kind1_Strasse_Rollo.sendCommand(hoehe5)
GaesteWC_Rollo.sendCommand(hoehe5)
sonneost.postUpdate(0)
println("Sonne ist fast untergegangen alles auf -Ost-")
logInfo("Sun_Protection","Sonnenschutz Ost - Stufe 3")
}
/* ################################################################# */
/* Sonnenschutz SÜD */
if (SonneS_aus.state == 0 && sonnesued.state == 0 && tempmax >= 20 && azimuth >= 120 && azimuth <= 250 && elevation >= 40) { //
mailActions.sendMail("abc@api.prowlapp.com", "Information", "Sonnenschutz Süd - Stufe 1")
/* Rollladen Sued */
Kind1_Widerkehr_Rollo.sendCommand(hoehe2)
Schlaf_Widerkehr_Rollo.sendCommand(hoehe2)
Terrasse_links_Fenster_Rollo.sendCommand(hoehe2)
Terrasse_links_Tuere_Rollo.sendCommand(hoehe2)
Terrasse_rechts_Tuere_Rollo.sendCommand(hoehe2)
Terrasse_rechts_Fenster_Rollo.sendCommand(hoehe2)
sonnesued.postUpdate(1)
println("**Sonnenschutz Zu-Fahren Süden- ")
logInfo("Sun_Protection","Sonnenschutz Süden - Stufe 1")
} else if (SonneS_aus.state == 0 && sonnesued.state == 1 && azimuth >= 137) {
mailActions.sendMail("abc@api.prowlapp.com", "Information", "Sonnenschutz Süd - Stufe 2")
/* Rollladen Sued */
Kind1_Widerkehr_Rollo.sendCommand(hoehe2)
Schlaf_Widerkehr_Rollo.sendCommand(hoehe2)
Terrasse_links_Fenster_Rollo.sendCommand(hoehe2)
Terrasse_links_Tuere_Rollo.sendCommand(hoehe2)
Terrasse_rechts_Tuere_Rollo.sendCommand(hoehe2)
Terrasse_rechts_Fenster_Rollo.sendCommand(hoehe2)
sonnesued.postUpdate(2)
println("**Sonnenschutz Fahren. Sonne ist fast weg Süd- ")
logInfo("Sun_Protection","Sonnenschutz Süden - Stufe 2")
} else if (SonneS_aus.state == 0 && sonnesued.state == 2 && azimuth >= 270) {
mailActions.sendMail("abc@api.prowlapp.com", "Information", "Sonnenschutz Süd - Stufe 3")
/* Rollladen Sued */
Terrasse_links_Fenster_Rollo.sendCommand(hoehe4)
Terrasse_links_Tuere_Rollo.sendCommand(hoehe4)
Terrasse_rechts_Tuere_Rollo.sendCommand(hoehe4)
Terrasse_rechts_Fenster_Rollo.sendCommand(hoehe4)
sonnesued.postUpdate(3)
println("**Sonnenschutz Auf-Fahren. Sonne ist fast weg Süd- ")
logInfo("Sun_Protection","Sonnenschutz Süden - Stufe 3")
} else if (SonneS_aus.state == 0 && sonnesued.state == 3 && azimuth >= 280 && elevation <= 13) {
mailActions.sendMail("abc@api.prowlapp.com", "Information", "Sonnenschutz Süd - Stufe 4")
/* Rollladen Sued */
Terrasse_links_Fenster_Rollo.sendCommand(hoehe5)
Terrasse_links_Tuere_Rollo.sendCommand(hoehe5)
Terrasse_rechts_Tuere_Rollo.sendCommand(hoehe5)
Terrasse_rechts_Fenster_Rollo.sendCommand(hoehe5)
sonnesued.postUpdate(4)
println("**Sonnenschutz Auf-Fahren. Sonne ist weg Süd- ")
logInfo("Sun_Protection","Sonnenschutz Süden - Stufe 4")
} else if (SonneS_aus.state == 0 && sonnesued.state == 4 && elevation <= 10) {
mailActions.sendMail("abc@api.prowlapp.com", "Information", "Sonnenschutz Süd - Stufe 5")
/* Rollladen Sued */
Kind1_Widerkehr_Rollo.sendCommand(hoehe5)
Schlaf_Widerkehr_Rollo.sendCommand(hoehe5)
Terrasse_links_Fenster_Rollo.sendCommand(hoehe5)
Terrasse_links_Tuere_Rollo.sendCommand(hoehe5)
Terrasse_rechts_Tuere_Rollo.sendCommand(hoehe5)
Terrasse_rechts_Fenster_Rollo.sendCommand(hoehe5)
sonnesued.postUpdate(0)
println("**Sonnenschutz Auf-Fahren. Sonne ist weg Süd- ")
logInfo("Sun_Protection","Sonnenschutz Süden - Stufe 5")
}
/* ################################################################# */
/* Sonnenschutz WEST */
if (SonneS_aus.state == 0 && sonnewest.state == 0 && tempmax >= 20 && azimuth >= 210 && elevation >=30) {
mailActions.sendMail("abc@api.prowlapp.com", "Information", "Sonnenschutz West - Stufe 1")
/* Rollladen West */
Schlaf_Garten_Rollo.sendCommand(hoehe2)
Lea_Rollo.sendCommand(hoehe2)
Esszimmer_links_Rollo.sendCommand(hoehe2)
Esszimmer_rechts_Rollo.sendCommand(hoehe2)
Kueche_links_Rollo.sendCommand(hoehe2)
sonnewest.postUpdate(1)
println("**Sonnenschutz weil warm -West- ")
logInfo("Sun_Protection","Sonnenschutz Westen - Stufe 1")
} else if (SonneS_aus.state == 0 && sonnewest.state == 1 && azimuth >= 282 && elevation <= 20) { //azi 270
mailActions.sendMail("abc@api.prowlapp.com", "Information", "Sonnenschutz West - Stufe 2")
/* Rollladen West */
Schlaf_Garten_Rollo.sendCommand(hoehe3)
Lea_Rollo.sendCommand(hoehe3)
Esszimmer_links_Rollo.sendCommand(hoehe5)
Esszimmer_rechts_Rollo.sendCommand(hoehe5)
Kueche_links_Rollo.sendCommand(hoehe5)
sonnewest.postUpdate(2)
println("**Sonne -West- ")
logInfo("Sun_Protection","Sonnenschutz Westen - Stufe 2")
} else if (SonneS_aus.state == 0 && sonnewest.state == 2 && azimuth >= 285 && elevation <= 15) { //azi 270
mailActions.sendMail("abc@api.prowlapp.com", "Information", "Sonnenschutz West - Stufe 3")
/* Rollladen West */
Schlaf_Garten_Rollo.sendCommand(hoehe5)
Lea_Rollo.sendCommand(hoehe5)
sonnewest.postUpdate(0)
println("**Sonne -West- ")
logInfo("Sun_Protection","Sonnenschutz Westen - Stufe 3")
}
end
Viele Grüße
int5749