Beziehungsweise: ist OneCallAPIweatherandforecast_Current_Conditionid vom Typ String?
Code: Alles auswählen
OneCallAPIweatherandforecast_Current_Conditionid.state.toString
Gesendet von iPad mit Tapatalk
Code: Alles auswählen
OneCallAPIweatherandforecast_Current_Conditionid.state.toString
Code: Alles auswählen
String OneCallAPIweatherandforecast_Current_Conditionid "Weather Condition Id"
Habe ich gemacht, aber leider wieder nix :-/
2021-07-22 08:30:00.186 [INFO ] [rg.openhab.core.model.script.Shutter] - OneCallAPIweatherandforecast_Current_Conditionid: 800
2021-07-22 08:30:00.186 [INFO ] [rg.openhab.core.model.script.Shutter] - tempmax: 24
2021-07-22 08:30:00.201 [INFO ] [rg.openhab.core.model.script.Shutter] - Night: OFF
2021-07-22 08:30:00.201 [INFO ] [rg.openhab.core.model.script.Shutter] - Comfort_Shutter: ON
2021-07-22 08:30:00.201 [INFO ] [rg.openhab.core.model.script.Shutter] - Holiday: OFF
2021-07-22 08:30:00.217 [INFO ] [rg.openhab.core.model.script.Shutter] - Rollladen fahren auf.
Code: Alles auswählen
if (Night.state == OFF && Comfort_Shutter.state == ON && Holiday.state == OFF && (tempmax < 20 || (tempmax >= 20 && (OneCallAPIweatherandforecast_Current_Conditionid.state != "800" || OneCallAPIweatherandforecast_Current_Conditionid.state != "801")))) {
Code: Alles auswählen
if (tempmax < 20 || (tempmax >= 20 && (OneCallAPIweatherandforecast_Current_Conditionid.state != "800" || OneCallAPIweatherandforecast_Current_Conditionid.state != "801"))) {
Code: Alles auswählen
if(true)
Code: Alles auswählen
if(tempmax >= 20 && (OneCallAPIweatherandforecast_Current_Conditionid.state != "800" || OneCallAPIweatherandforecast_Current_Conditionid.state != "801")))
Code: Alles auswählen
var Boolean bCondition = false // default: falsch
if(strCondition == "800") bCondition = true // falls Condition 800
if(strCondition == "801") bCondition = true // oder 801 -> true
if(tempmax < 20) bCondition = false // falls Temperatur < 20 false
if(!bCondition)) { // falls false
Code: Alles auswählen
var Integer tempmax = 0
rule Rollladen_Task
when
Time cron "0 30 08 ? * MON-SAT" or
Time cron "0 00 09 ? * SUN"
then
val mailActions = getActions("mail","mail:smtp:h478579470")
tempmax = (Weather_Temp_Max_0.state as DecimalType).intValue
val String strCondition = OneCallAPIweatherandforecast_Current_Conditionid.state.toString // schon wegen der Länge des Itemnamens...
logInfo("Shutter", "Comfort_Shutter: {}", Comfort_Shutter.state)
logInfo("Shutter", "Holiday: {}", Holiday.state)
logInfo("Shutter", "Night: {}", Night.state)
logInfo("Shutter", "tempmax: {}", tempmax)
logInfo("Shutter", "OneCallAPIweatherandforecast_Current_Conditionid: {}", strCondition)
if(Comfort_Shutter.state != ON) { // Automatik ist ausgeschaltet
mailActions.sendMail("abcdefghijklmnop@api.prowlapp.com", "Komfortfunktion aus: " + OffsetDateTime.now().toString, "Rollladen bleiben unten.")
return;
}
if (Holiday.state == ON) { // Ferien
mailActions.sendMail("abcdefghijklmnop@api.prowlapp.com", "" + SpecialDay + ": " + OffsetDateTime.now().toString, "Rollladen bleiben unten.")
return;
}
if (Night.state != ON) { // Es ist Tag
// anders gestaltete Logik:
var Boolean bCondition = false // default: falsch
if(strCondition == "800") bCondition = true // falls Condition 800
if(strCondition == "801") bCondition = true // oder 801 -> true
if(tempmax < 20) bCondition = false // falls Temperatur < 20 false
if(!bCondition) { // falls false
logInfo("Shutter", "Rollladen fahren auf.")
mailActions.sendMail("abcdefghijklmnop@api.prowlapp.com", ""+ tempmax + " Grad: " + OffsetDateTime.now().toString, "Rollladen fahren auf.")
Rollladen.allMembers.filter(f|(f.state as Number).intValue != 0).forEach[ s|
s.sendCommand(UP)
logInfo("Shutter", s.name + " received UP")
]
Lampe_Treppe.sendCommand(OFF)
} else { // Temperatur >= 20 und (800 oder 801)
SunProtection.postUpdate(ON)
}
} else { // es ist Nacht
mailActions.sendMail("abcdefghijklmnop@api.prowlapp.com", "Information: " + OffsetDateTime.now().toString, "Es ist noch Nacht, Rollladen bleiben unten.")
if (t_night !== null) { // Timer läuft bereits
return;
}
t_night = createTimer(now.plusMinutes(10), [ |
if (Night.state == ON) { // es ist weiterhin Nacht
mailActions.sendMail("abcdefghijklmnop@api.prowlapp.com", "Information: " + OffsetDateTime.now().toString, "Es ist immer noch Nacht, Rollladen bleiben unten.")
t_night.reschedule(now.plusMinutes(10))
} else { // es ist nun Tag
mailActions.sendMail("abcdefghijklmnop@api.prowlapp.com", "Information: " + OffsetDateTime.now().toString, "Rollladen fahren auf")
Rollladen.allMembers.filter(f|(f.state as Number).intValue != 0).forEach[ s|
s.sendCommand(UP)
logInfo("Shutter", s.name + " received UP")
]
Lampe_Treppe.sendCommand(OFF)
t_night = null
}
])
}
end
Code: Alles auswählen
var Number a = 5
if(a === 5)
logInfo("test","a ist identisch mit 5!")
else if (a == 5)
logInfo("test","a ist gleich 5!")
Ich hatte es ja befürchtet, bin aber nicht auf den Fehler gekommen
DANKE, habe ich so eingebaut. Evtl. magst Du oben den Post noch einmal editieren, falls sich den jemand kopieren möchte.
Hier hat sich eine zweite ")" eingeschlichen
Ich kürze für die Diskussion hier mal OneCallAPIweatherandforecast_Current_Conditionid auf Conditionid (wegen der Länge )udo1toni hat geschrieben: ↑22. Jul 2021 22:47 Wenn wir mal die ersten drei Bedingungen weg lassen, bleibtStattdessen kannst Du aber auchCode: Alles auswählen
if (tempmax < 20 || (tempmax >= 20 && (OneCallAPIweatherandforecast_Current_Conditionid.state != "800" || OneCallAPIweatherandforecast_Current_Conditionid.state != "801"))) {
schreiben.Code: Alles auswählen
if(true)
Entweder, die Bedingung ist wahr, weil tempmax < 20 ist. Oder tempmax >= 20 und eine der beiden nachfolgenden Bedinguen ist nicht(!!!) erfüllt. Da aber immer maximal eine der beiden Bedingungen erfüllt sein kann, ist dieser Teil immer true, womit der Rest des Bool'schen Terms ebenfalls immer true ist.
Es geht um die Condition
Code: Alles auswählen
OneCallAPIweatherandforecast_Current_Conditionid.state != "800" || OneCallAPIweatherandforecast_Current_Conditionid.state != "801"
Code: Alles auswählen
if(a != 800 && a!= 801)
Code: Alles auswählen
2021-07-24 08:30:03.710 [INFO ] [rg.openhab.core.model.script.Shutter] - Comfort_Shutter: ON
2021-07-24 08:30:03.725 [INFO ] [rg.openhab.core.model.script.Shutter] - Holiday: OFF
2021-07-24 08:30:03.725 [INFO ] [rg.openhab.core.model.script.Shutter] - Night: OFF
2021-07-24 08:30:03.725 [INFO ] [rg.openhab.core.model.script.Shutter] - tempmax: 25
2021-07-24 08:30:03.725 [INFO ] [rg.openhab.core.model.script.Shutter] - OneCallAPIweatherandforecast_Current_Conditionid: 800
2021-07-24 08:34:05.410 [INFO ] [rg.openhab.core.model.script.Shutter] - Flur_Rollo received Höhe 55
2021-07-24 08:34:05.425 [INFO ] [rg.openhab.core.model.script.Shutter] - Kueche_rechts_Rollo received Höhe 55