Um in FHEM eine automatische Beschattungslogik mit festen Uhrzeiten, Helligkeitsschwellen und einer Dämpfung (also Vermeidung von ständigen Schaltvorgängen) zu programmieren, verwendet man idealerweise das DOIF-Modul in Kombination mit einem Intervall-Timer.


🔧 Zieldefinition:

  • Zeitraum: täglich zwischen 11:00 und 18:00 Uhr
  • Lichtsensorwert:
    • >10.000 Lux:Rollo1 und Rollo2 auf 60%
    • <8.000 Lux:Rollo1 und Rollo2 auf 100% (hoch)
  • Abfrage-Intervall: alle 10 Minuten
  • Keine dauerhafte Umschaltung bei schwankenden Werten.

🧱 Voraussetzungen / Annahmen

  • Lichtsensor heißt Lichtsensor_Terrasse
  • Reading für Helligkeit: illuminance (häufig bei ZigBee, MQTT etc.)
  • Rollos heißen Rollo1 und Rollo2
  • DOIF-Modul ist installiert (update all + define Test DOIF {} zum Testen)

Schritt-für-Schritt: DOIF für automatische Beschattung

perl

define doif_Beschattung DOIF

(

    [timeofday] > "11:00" and [timeofday] < "18:00"

)

DOELSEIF

(

    [timeofday] < "11:00" or [timeofday] > "18:00"

)

DOELSE

DOIF_Timer

(

    [Lichtsensor_Terrasse:illuminance] > 10000

    and [Rollo1:position] != 60

)

(

    set Rollo1 pct 60; set Rollo2 pct 60

)

ELSEIF

(

    [Lichtsensor_Terrasse:illuminance] < 8000

    and [Rollo1:position] != 100

)

(

    set Rollo1 pct 100; set Rollo2 pct 100

)

📌 Dieser DOIF besteht aus zwei Bereichen:

  1. Zeitfensterprüfung ([timeofday]) – wann die Regel aktiv ist.
  2. Timer-gesteuerte Helligkeitsprüfung im 10-Minuten-Takt (s. nächster Schritt).

⏲️ Timer hinzufügen: Alle 10 Minuten prüfen

perl

attr doif_Beschattung timerWithWait

attr doif_Beschattung timer 10:00-18:00/600

Erklärung:

  • timerWithWait: verhindert, dass ein Timer erneut losläuft, solange der vorherige noch läuft
  • timer 10:00-18:00/600: alle 600 Sekunden (10 Minuten) zwischen 10 und 18 Uhr wird die Bedingung geprüft

🧠 Zusätzliche Schutzmaßnahmen / Tipps

  • Füge einen Dummy-Schalter ein, um die Automatik bei Bedarf zu deaktivieren.
  • Nutze Rollo1:position zur Dämpfung (nur schalten, wenn sich wirklich etwas ändern muss).
  • Wenn deine Rollos nicht pct unterstützen, verwende set Rollo1 down / stop / pos 60 je nach Gerät.

📄 Komplettbeispiel zusammengefasst

perl

define doif_Beschattung DOIF

(

    [timeofday] > "11:00" and [timeofday] < "18:00"

)

DOIF

(

    [Lichtsensor_Terrasse:illuminance] > 10000

    and [Rollo1:position] != 60

)

(

    set Rollo1 pct 60; set Rollo2 pct 60

)

ELSEIF

(

    [Lichtsensor_Terrasse:illuminance] < 8000

    and [Rollo1:position] != 100

)

(

    set Rollo1 pct 100; set Rollo2 pct 100

)


attr doif_Beschattung timerWithWait

attr doif_Beschattung timer 11:00-18:00/600