This is also my plan for the future - in the meantime I use the cloud coverage. But to be honest: most of the time I simply let the blinds down as soon as the sun comes around the house corner - no matter how bright the sun ist
I have thought about that but haven’t implemented it yet.
The scripts runs as soon as my item for the sun azimuth changes. And these items will be updated every 15 minute by the astro binding.
And yes, I have switches and settings for the opening of the blinds but in most cases I use just the closing automatism.
This basic code is based on some other community member’s code which I adapted for my needs. I also had some thoughts of refactoring the code to make it more readable and reusable, but I simply had no time for this until now.
RolloAbWest rule:
configuration: {}
triggers:
- id: "1"
configuration:
itemName: LokaleSonnendaten_Azimut
type: core.ItemStateChangeTrigger
conditions: []
actions:
- inputs: {}
id: "6"
configuration:
type: application/vnd.openhab.dsl.rule
script: >-
val String logPrefix = 'Rolloautomatik - RollosWestseiteRunterfahren - '
if (EnableLog_RolladenRules.state == ON) logInfo('rolladen.rules', logPrefix + 'Regel wurde gestartet')
var String timeLast = 'xxxx-xx-xx'
if (RolloAutomatik_WestRunterLastRun.state == NULL) {
if (EnableLog_RolladenRules.state == ON) logInfo('rolladen.rules', logPrefix + 'Erstmalige AusfĂĽhrung am System, Belegung mit Initialwert')
} else {
timeLast = RolloAutomatik_WestRunterLastRun.state.toString().substring(0,10)
}
var String timeNow = now.toString().substring(0,10)
if (RolloAutomatikEin.state == ON && RolloAutomatik_WestRunterfahren.state == ON) {
if (timeNow != timeLast) {
if ((LokaleSonnendaten_Azimut.state as QuantityType<Number>).intValue > (RolloAutomatik_WestAzimuthRunter.state as DecimalType).intValue) {
if (((TemperatursensorAussenHutte_ActualTemperature.state as QuantityType<Number>).intValue > (RolloAutomatik_WestTempMin.state as DecimalType).intValue) || RolloAutomatik_SperreTemperatur.state == ON) {
if (LokalesWetterVorhersage_Bewolkung.state <= (RolloAutomatik_WestWolkenMax.state as DecimalType).intValue || RolloAutomatik_SperreWolken.state == ON) {
if ((LokaleSonnendaten_Position_Elevation.state as QuantityType<Number>).intValue > (RolloAutomatik_WestElevationHoch.state as DecimalType).intValue) {
// Rollos runterfahren
if (EnableLog_RolladenRules.state == ON) logInfo('rolladen.rules', logPrefix + 'Rollos werden runtergefahren')
gRollosWest.members.forEach[i|
if (i.state <= (RolloAutomatik_WestZielwert.state as DecimalType).intValue) {
if (EnableLog_RolladenRules.state == ON) logInfo('rolladen.rules', logPrefix + 'Fahre Rolladen auf ' + RolloAutomatik_WestZielwert.state.toString() + '%: ' + i.name)
i.sendCommand((RolloAutomatik_WestZielwert.state as DecimalType).intValue)
} else {
if (EnableLog_RolladenRules.state == ON) logInfo('rolladen.rules', logPrefix + 'Rolladen ist bereits weiter geschlossen (' + i.state.toString() + '%) als er geschlossen werden sollte und wird daher ignoriert')
}
]
// Letzte AusfĂĽhrung mit entsprechendem Zeitstempel belegen
RolloAutomatik_WestRunterLastRun.postUpdate(new DateTimeType(now))
} else {
if (EnableLog_RolladenRules.state == ON) logInfo('rolladen.rules', logPrefix + 'Aktuelle Sonnenhöhe (' + (LokaleSonnendaten_Position_Elevation.state as QuantityType<Number>).intValue.toString() + ') ist kleiner als minimale Sonnenhöhe (' + (RolloAutomatik_WestElevationHoch.state as DecimalType).intValue.toString() + ')')
}
} else {
if (EnableLog_RolladenRules.state == ON) logInfo('rolladen.rules', logPrefix + 'Maximalbewölkung (' + (RolloAutomatik_WestWolkenMax.state as DecimalType).intValue.toString() + ') wurde ueberschritten (' + LokalesWetterVorhersage_Bewolkung.state.toString() + ')')
}
} else {
if (EnableLog_RolladenRules.state == ON) logInfo('rolladen.rules', logPrefix + 'Mindest-Temperatur (' + (RolloAutomatik_WestTempMin.state as DecimalType).intValue.toString() + ') wurde nicht erreicht durch aktuelle Temperatur (' + TemperatursensorAussenHutte_ActualTemperature.state.toString() + ')')
}
} else {
if (EnableLog_RolladenRules.state == ON) logInfo('rolladen.rules', logPrefix + 'Sonnenrichtung (' + (LokaleSonnendaten_Azimut.state as QuantityType<Number>).intValue.toString() + ') hat noch nicht Schwellwert (' + (RolloAutomatik_WestAzimuthRunter.state as DecimalType).intValue.toString() + ') erreicht')
}
} else {
if (EnableLog_RolladenRules.state == ON) logInfo('rolladen.rules', logPrefix + 'Automatik heute bereits einmal gelaufen, wird daher ignoriert')
}
} else {
if (EnableLog_RolladenRules.state == ON) logInfo('rolladen.rules', logPrefix + 'Beende, da Automatik nicht aktiv')
}
type: script.ScriptAction
Cheers.
Jonathan