ich habe das mal wie Udo beschrieben hat geändert.
Rule:
Code: Alles auswählen
val nElevationMin = 0 // 10
val nElevationMax = 300 // 45
val nAzimutMin = 0 // 130
val nAzimutMax = 210 // 210
val nIntensityMin = 0 // 80
val nCloudynessMax = 110 // 40
rule "Beschattung"
when
Item LokaleSonnendaten_Position_Elevation changed
then
if(!(LokaleSonnendaten_Position_Elevation.state instanceof Number)) {
logWarn("shade","Elevation ungültig! Abbruch!")
return;
}
if(!(LokaleSonnendaten_Azimut.state instanceof Number)) {
logWarn("shade","Azimut ungültig! Abbruch!")
return;
}
val nElevation = (LokaleSonnendaten_Position_Elevation.state as Number).floatValue
val nAzimut = (LokaleSonnendaten_Azimut.state as Number).floatValue
var nIntens = 100
if(LokaleSonnendaten_DirekteStrahlung.state instanceof Number)
nIntens = (LokaleSonnendaten_DirekteStrahlung.state as Number).floatValue
var nCloud = 0
if(LokaleWettervorhersage_Bewolkung.state instanceof Number)
nCloud = (LokaleWettervorhersage_Bewolkung.state as Number).intValue
logInfo("shade","Elevation: Min({}) Max({}) aktuell:{}",nElevationMin,nElevationMax,nElevation)
logInfo("shade"," Azimut: Min({}) Max({}) aktuell:{}",nAzimutMin,nAzimutMax,nAzimut)
logInfo("shade","Intensity: Min({}) aktuell:{}",nIntensityMin,nIntens)
logInfo("shade"," Cloud: Max({}) aktuell:{}",nCloudynessMax,nCloud)
var Boolean bSchatten = true
logInfo("shade","Vergleich Minimum Elevation")
if(nElevation < nElevationMin)
bSchatten = false
logInfo("shade","Vergleich Maximum Elevation")
if(nElevation > nElevationMax)
bSchatten = false
logInfo("shade","Vergleich Minimum Azimut")
if(nAzimut < nAzimutMin)
bSchatten = false
logInfo("shade","Vergleich Maximum Azimut")
if(nAzimut > nAzimutMax)
bSchatten = false
logInfo("shade","Vergleich Minimum Intensity")
if(nIntensityMin > nIntens) //(nIntens < nIntensityMin) Vergleich Falsch -> Typenumwandlung?
bSchatten = false
logInfo("shade","Vergleich Maximum Bewölkung")
if(nCloud > nCloudynessMax)
bSchatten = false
if(!bSchatten)
{ logInfo("shade","Rolladen Büro und Kinderzimmer Beschattung aus!")
} else {
logInfo("shade","Rolladen Büro und Kinderzimmer Beschattung an!")
DGBuero.sendCommand(50)
DGKind.sendCommand(50)
}
end
Direkte Sonneneinstrahlung:
Code: Alles auswählen
"LokaleSonnendaten_DirekteStrahlung": {
"class": "org.openhab.core.items.ManagedItemProvider$PersistedItem",
"value": {
"groupNames": [
"LokaleSonnendaten"
],
"itemType": "Number",
"tags": [
"Point"
],
"label": "Direkte Strahlung",
"category": ""
Code: Alles auswählen
"LokaleSonnendaten_Azimut": {
"class": "org.openhab.core.items.ManagedItemProvider$PersistedItem",
"value": {
"groupNames": [
"LokaleSonnendaten"
],
"itemType": "Number",
"tags": [
"Point"
],
"label": "Azimut",
"category": ""
Code: Alles auswählen
"LokaleSonnendaten_Position_Elevation": {
"class": "org.openhab.core.items.ManagedItemProvider$PersistedItem",
"value": {
"groupNames": [
"LokaleSonnendaten"
],
"itemType": "Number",
"tags": [
"Point"
],
"label": "Elevationswinkel",
"category": ""
Code: Alles auswählen
"LokaleWettervorhersage_Bewolkung": {
"class": "org.openhab.core.items.ManagedItemProvider$PersistedItem",
"value": {
"groupNames": [
"Internet_Wetter"
],
"itemType": "Number",
"tags": [
"Measurement"
],
"label": "Bewölkung",
"category": "sun_clouds"
Code: Alles auswählen
2021-03-07 11:42:11.634 [INFO ] [org.openhab.core.model.script.shade ] - Elevation: Min(0) Max(300) aktuell:34.56112
2021-03-07 11:42:11.658 [INFO ] [org.openhab.core.model.script.shade ] - Azimut: Min(0) Max(210) aktuell:163.86551
2021-03-07 11:42:11.666 [INFO ] [org.openhab.core.model.script.shade ] - Intensity: Min(0) aktuell:320.15662
2021-03-07 11:42:11.671 [INFO ] [org.openhab.core.model.script.shade ] - Cloud: Max(110) aktuell:0
2021-03-07 11:42:11.674 [INFO ] [org.openhab.core.model.script.shade ] - Vergleich Minimum Elevation
2021-03-07 11:42:11.679 [INFO ] [org.openhab.core.model.script.shade ] - Vergleich Maximum Elevation
2021-03-07 11:42:11.683 [INFO ] [org.openhab.core.model.script.shade ] - Vergleich Minimum Azimut
2021-03-07 11:42:11.688 [INFO ] [org.openhab.core.model.script.shade ] - Vergleich Maximum Azimut
2021-03-07 11:42:11.693 [INFO ] [org.openhab.core.model.script.shade ] - Vergleich Minimum Intensity
2021-03-07 11:42:11.697 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'SonnenschutzBüro-1' failed: An error occurred during the script execution: Could not invoke method: org.eclipse.xtext.xbase.lib.IntegerExtensions.operator_greaterThan(int,int) on instance: null in SonnenschutzBüro