Ankündigung

Einklappen
Keine Ankündigung bisher.

Fensterbeschattungssteuerung

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

    Fensterbeschattungssteuerung

    Hi,
    ich habe mich heute hingesetzt und eine Fensterbeschattungsregel programmiert, die aber irgendwie nicht so richtig greift.
    Kann sich einer mal den Code anschauen und mir sagen, was ich falsch gemacht habe?
    Code:
     [COLOR=#3933FF][FONT=Monaco][SIZE=11px][COLOR=#931a68]rule[/COLOR][COLOR=#000000] [/COLOR]"[U]Suedbeschattung[/U]"[/SIZE][/FONT][/COLOR]
      [COLOR=#931A68][FONT=Monaco][SIZE=11px]when[/SIZE][/FONT][/COLOR]
      [COLOR=#3933FF][FONT=Monaco][SIZE=11px][COLOR=#000000]    [/COLOR][COLOR=#931a68]Time[/COLOR][COLOR=#000000] [/COLOR][COLOR=#931a68]cron[/COLOR][COLOR=#000000] [/COLOR]"0 0/1 * * * ?"[/SIZE][/FONT][/COLOR]
      [COLOR=#931A68][FONT=Monaco][SIZE=11px]then[/SIZE][/FONT][/COLOR]
      [FONT=Monaco][SIZE=11px]    [COLOR=#931a68]var[/COLOR] [COLOR=#931a68]int[/COLOR] azimuth = (Azimuth.state [COLOR=#931a68]as[/COLOR] DecimalType).intValue[/SIZE][/FONT]
      [FONT=Monaco][SIZE=11px]    [COLOR=#931a68]var[/COLOR] [COLOR=#931a68]int[/COLOR] elevation = (Elevation.state [COLOR=#931a68]as[/COLOR] DecimalType).intValue[/SIZE][/FONT]
      [FONT=Monaco][SIZE=11px]    [COLOR=#931a68]if[/COLOR] (azimuth > [COLOR=#909090]79[/COLOR] && azimuth < [COLOR=#909090]220[/COLOR] && elevation > [COLOR=#909090]15[/COLOR] && Beschattungssteuerung.state==ON && Shutter_ALLG_Alle_Rollos.state==OFF && Suedbeschattung.state==OFF)[/SIZE][/FONT]
      [COLOR=#3933FF][FONT=Monaco][SIZE=11px][COLOR=#000000]    {callScript ([/COLOR]"Suedfensterbeschattung.script"[COLOR=#000000])}[/COLOR][/SIZE][/FONT][/COLOR]
      [FONT=Monaco][SIZE=11px]    [COLOR=#931a68]else[/COLOR] [COLOR=#931a68]if[/COLOR]  (azimuth > [COLOR=#909090]219[/COLOR] && Beschattungssteuerung.state==ON && Shutter_ALLG_Alle_Rollos.state==OFF && Suedbeschattung.state==ON)[/SIZE][/FONT]
      [COLOR=#3933FF][FONT=Monaco][SIZE=11px][COLOR=#000000]    {callScript ([/COLOR]"[U]Suedfensterbeschattung[/U] aus.script"[COLOR=#000000])}[/COLOR][/SIZE][/FONT][/COLOR]
      [COLOR=#931A68][FONT=Monaco][SIZE=11px]end[/SIZE][/FONT][/COLOR]
    Ich habe das Astrobinding eingebunden und diese liefert mir ja den Azimuth. Aber irgendwie reagieren die Rollos und die Schalter nicht. Anscheinend wird die Rule nicht ausgeführt, aber warum?

    #2
    Ich habe es jetzt noch ein bisschen abgeändert um es per Schalter zu testen, funktioniert aber auch nicht:
    Code:
     [COLOR=#3933FF][FONT=Monaco][SIZE=11px][COLOR=#931a68]rule[/COLOR][COLOR=#000000] [/COLOR]"[U]Beschattung[/U]"[/SIZE][/FONT][/COLOR]
      [COLOR=#931A68][FONT=Monaco][SIZE=11px]when[/SIZE][/FONT][/COLOR]
      [FONT=Monaco][SIZE=11px]    [COLOR=#931a68]Item[/COLOR] Westbeschattung [COLOR=#931a68]changed[/COLOR][/SIZE][/FONT]
      [COLOR=#4E9072][FONT=Monaco][SIZE=11px]//    Item azimuth changed[/SIZE][/FONT][/COLOR]
      [COLOR=#931A68][FONT=Monaco][SIZE=11px]then[/SIZE][/FONT][/COLOR]
      [COLOR=#4E9072][FONT=Monaco][SIZE=11px]//    [U]var[/U] [U]int[/U] azimuth_dec = (azimuth.state as DecimalType).intValue[/SIZE][/FONT][/COLOR]
      [COLOR=#4E9072][FONT=Monaco][SIZE=11px]//    [U]var[/U] [U]int[/U] elevation_dec = (elevation.state as DecimalType).intValue[/SIZE][/FONT][/COLOR]
      [FONT=Monaco][SIZE=11px]    [/SIZE][/FONT]
      [COLOR=#4E9072][FONT=Monaco][SIZE=11px]//[U]Ostfensterbeschattung[/U]    [/SIZE][/FONT][/COLOR]
      [FONT=Monaco][SIZE=11px]    [COLOR=#931a68]if[/COLOR] (azimuth.state > [COLOR=#909090]72[/COLOR] && azimuth.state < [COLOR=#909090]117[/COLOR] && elevation.state > [COLOR=#909090]15[/COLOR] && Beschattungssteuerung.state==ON && Shutter_ALLG_Alle_Rollos.state==OFF && Ostbeschattung.state==OFF)[/SIZE][/FONT]
      [COLOR=#3933FF][FONT=Monaco][SIZE=11px][COLOR=#000000]    {callScript ([/COLOR]"Ostfensterbeschattung.script"[COLOR=#000000])}[/COLOR][/SIZE][/FONT][/COLOR]
      [FONT=Monaco][SIZE=11px]    [COLOR=#931a68]if[/COLOR]  (azimuth.state > [COLOR=#909090]116[/COLOR] && Beschattungssteuerung.state==ON && Shutter_ALLG_Alle_Rollos.state==OFF && Ostbeschattung.state==ON)[/SIZE][/FONT]
      [COLOR=#3933FF][FONT=Monaco][SIZE=11px][COLOR=#000000]    {callScript ([/COLOR]"[U]Ostfensterbeschattung[/U] aus.script"[COLOR=#000000])}[/COLOR][/SIZE][/FONT][/COLOR]
      [FONT=Monaco][SIZE=11px]    [/SIZE][/FONT]
      [COLOR=#4E9072][FONT=Monaco][SIZE=11px]// [U]Südfenster[/U] [U]Beschattung[/U]    [/SIZE][/FONT][/COLOR]
      [FONT=Monaco][SIZE=11px]    [COLOR=#931a68]if[/COLOR] (azimuth.state > [COLOR=#909090]79[/COLOR] && azimuth.state < [COLOR=#909090]220[/COLOR] && elevation.state > [COLOR=#909090]15[/COLOR] && Beschattungssteuerung.state==ON && Shutter_ALLG_Alle_Rollos.state==OFF && Suedbeschattung.state==OFF)[/SIZE][/FONT]
      [COLOR=#3933FF][FONT=Monaco][SIZE=11px][COLOR=#000000]    {callScript ([/COLOR]"Suedfensterbeschattung.script"[COLOR=#000000])}[/COLOR][/SIZE][/FONT][/COLOR]
      [FONT=Monaco][SIZE=11px]    [COLOR=#931a68]if[/COLOR]  (azimuth.state > [COLOR=#909090]219[/COLOR] && Beschattungssteuerung.state==ON && Shutter_ALLG_Alle_Rollos.state==OFF && Suedbeschattung.state==ON)[/SIZE][/FONT]
      [COLOR=#3933FF][FONT=Monaco][SIZE=11px][COLOR=#000000]    {callScript ([/COLOR]"[U]Suedfensterbeschattung[/U] aus.script"[COLOR=#000000])}[/COLOR][/SIZE][/FONT][/COLOR]
      [FONT=Monaco][SIZE=11px] [/SIZE][/FONT]
      [COLOR=#4E9072][FONT=Monaco][SIZE=11px]// [U]Westfenster[/U] [U]Beschattung[/U][/SIZE][/FONT][/COLOR]
      [FONT=Monaco][SIZE=11px]    [COLOR=#931a68]if[/COLOR] (azimuth.state > [COLOR=#909090]179[/COLOR] && azimuth.state < [COLOR=#909090]300[/COLOR] && elevation.state > [COLOR=#909090]15[/COLOR] && Beschattungssteuerung.state==ON && Shutter_ALLG_Alle_Rollos.state==OFF && Westbeschattung.state==OFF)[/SIZE][/FONT]
      [COLOR=#3933FF][FONT=Monaco][SIZE=11px][COLOR=#000000]    {callScript ([/COLOR]"Westfensterbeschattung.script"[COLOR=#000000])}[/COLOR][/SIZE][/FONT][/COLOR]
      [FONT=Monaco][SIZE=11px]    [COLOR=#931a68]if[/COLOR]  (azimuth.state > [COLOR=#909090]300[/COLOR] && Beschattungssteuerung.state==ON && Shutter_ALLG_Alle_Rollos.state==OFF && Westbeschattung.state==ON)[/SIZE][/FONT]
      [COLOR=#3933FF][FONT=Monaco][SIZE=11px][COLOR=#000000]    {callScript ([/COLOR]"[U]Westfensterbeschattung[/U] aus.script"[COLOR=#000000])}[/COLOR][/SIZE][/FONT][/COLOR]
      [FONT=Monaco][SIZE=11px] [/SIZE][/FONT]
      [COLOR=#931A68][FONT=Monaco][SIZE=11px]end[/SIZE][/FONT][/COLOR]

    Kommentar


      #3
      Ad Hoc sehe ich nichts. Ich würde jetzt mal ein paar Log Infos einbauen. Z.B. am anfang, dann siehst du im Log, ob die Rule getriggert wird. dann würde ich die Bedingungen in teilen prüfen und per logInfo ausgeben. Last but not least würde ich mir ein paat schalter bauen, mit denen du definierte werte setzen kannst also z.B. den azimuth auf 105 setzen. du kannst auch die Beschattungssteuerung als übergreifende If abfrage machst, das vereinfacht die Bedingung.

      so mehr fällt mir jetzt nicht ein.

      Gruß
      Thomas

      Kommentar


        #4
        Wie baue ich solche Log-Infos ein? Ich habe so etwas noch nie gemacht (Copy-Paste-Programmierer)!

        Kommentar


          #5
          einfach copy und Paste :-)

          Code:
          rule"Suedbeschattung"
          when
              Timecron"0 0/1 * * * ?"
          then
              var int azimuth = (Azimuth.state as DecimalType).intValue
              var int elevation = (Elevation.state as DecimalType).intValue
                    
              logInfo("rule.beschattung","Beschattungsrule gestartet.")
          
              if (Beschattungssteuerung.state==ON) {
          
                  logInfo("rule.beschattung","Beschattungssteuerung ist an.")
          
                  if (azimuth > 79 && azimuth < 220 && elevation > 15  && Shutter_ALLG_Alle_Rollos.state==OFF && Suedbeschattung.state==OFF) {
                        logInfo("rule.beschattung","Suedfenster beschatten.")
                       callScript ("Suedfensterbeschattung.script")
                  } else if  (azimuth > 219 && Shutter_ALLG_Alle_Rollos.state==OFF && Suedbeschattung.state==ON) {
                        logInfo("rule.beschattung","Suedfenster entschatten.")
                      callScript ("Suedfensterbeschattung aus.script")
                  }
          
                }
          
          end

          Fehler solltest du jetzt finden. Weiterhin kannst du die BEdingungen stückweise aufbauen. Also ggf. einfach sagen azimuth >79 und wenn es dann funktioniert die nächste Bedingung einbauen. Ich würde die Regel auch nicht für die Schalter umbauen, sonden eine Switch definieren, der eine Regel auslöst und in dieser Regel dann z.B. ein postUpdate(Azimuth, 80) einbauen und beim ausschalten dann den Azimuth auf 230 setzen oder so

          Thomas

          Kommentar


            #6
            Der Befehl lautet loginfo("Logger","Ereignistext"), für beide Variablen kannst Du im Prinzip beliebige Werte einsetzen. Wenn Du spezielle Logfiles für Deine Logs anlegen lassen willst, muss die "Logger"-Variable zu dem Eintrag in logback.xml passen, alles, was der logger-Service nicht zuordnen kann, landet ansonsten automatisch in der openhab.log unterhalb ./logs/. Der Ereignistext kann ebenfalls frei gewählt werden, insbesondere kannst Du an dieser Stelle auch Itemstates mit ausgeben, falls das sinnvoll ist, in der Form loginfo("logger","Item hat den Wert "+Item.state.toString+" angenommen.")

            Ansonsten fehlte beim ersten Post ein Leerzeichen zwischen Time und cron (das sollte der Designer aber anmeckern), korrekt für den Aufruf sollte also
            Code:
            Time cron "0 * * * * ?"
            funktionieren. Das 0/1 aus dem Original bedeutet "ab der nullten Minute jede Minute", ist also gleichbedeutend mit "Die Minute spielt keine Rolle"

            Hast Du am Anfang des Rulefiles auch import org.openhab.core.library.types.* angegeben?

            Beim Namen der Scripte möchte ich empfehlen, auf Leerzeichen zu verzichten, lieber ein _ oder -, Umlaute hast Du ja schon weg gelassen. Groß/Kleinschreibung kann auch eine Quelle von Ärgernissen sein, sollte aber natürlich grundsätzlich funktionieren.

            Sind eventuell irgendwelche der abgefragten Bedingungen keine Itemstates sondern Gruppenstates?

            EDIT: Ah, beim Schreiben überholt worden

            Kommentar

            Lädt...
            X