Ankündigung

Einklappen
Keine Ankündigung bisher.

Fensterkontakte / mapping

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

    Fensterkontakte / mapping

    Hallo zusammen,

    hat vielleicht schon jemand sogenannte "Doppelfenster" (mit zwei Flügeln und Kontakten) visualisierte und ggf. einen Tip für mich? Ich habe ein Problem mit der Anzahl der Kontakte und dem entsprechenden mapping zu den Incons, da jeder Fensterflügel mindestens einen Kontakt (und damit eine eigene Gruppenadresse durch den Binäreingang) hat, mit Kippfunktion sogar vier Kontakte...

    Hier ein Beispiel: Das Icon "fts_windows_2w" zeigt ein geschlossenes Doppelfenster. Wenn der linke und/oder rechte Fensterflügel geöffnet wird, ändern sich jedoch "zwei" Kontaktwerte und damit verschiedene Gruppenadressen von 1 auf 0. Wie ist dass dann bitte bei dem mapping auf die Icons "open", "open_l" und open_lr" gedacht - mapping geht doch nur mit "einer" Gruppenadresse, oder?

    VG
    Tommy

    #2
    Du musst als erstes in einer Logik Engine die verschiedenen GAs mit ihrem Status-Bit in eine GA mit entsprechend mehr Infos (also z.B. einem Status-Byte) überführen, dann kannst Du auch leicht mit einem Mapping das dazu gewünschte Icon anzeigen.

    Ob dann noch der Fall eine-Seite-gekippt-andere-offen wirklich getrennt von Fenster-offen betrachtet werden muss ist Geschmackssache.
    TS2, B.IQ, DALI, WireGate für 1wire so wie Server für Logik und als KNX Visu die CometVisu auf HomeCockpit Minor. - Bitte keine PNs, Fragen gehören in das Forum, damit jeder was von den Antworten hat!

    Kommentar


      #3
      Moin.
      Hier mal ein Beispiel aus meiner Konfiguration (etwas länger, aber naja ...).
      Ich habe pro Flügel ("Left", "Right") 2 Kontakte ("Top", "Bottom") verbaut, so dass ich zwischen gekippt (Kontakt unten geschlossen) und offen (beide Kontakte offen) unterscheiden kann.

      sample.items
      Code:
      Group:Number:SUM                WindowBedroom1    "Fensterkontakt Schlafzimmer 1 [%d]"  (Status, FF_Windows)
      
      Contact Window_FF_Bedroom_1_Status        "Fensterstatus Schlafzimmer [MAP(de.map):%s]"       (FF_Bedroom_1, FF_Windows, WindowBedroom1)    { knx="5/3/60" }
      Contact Window_FF_Bedroom_1_TL            "Fensterkontakt links oben [MAP(de.map):%s]"        (FF_Bedroom_1, FF_Windows, WindowBedroom1)    { knx="<5/3/61" }
      Contact Window_FF_Bedroom_1_BL            "Fensterkontakt links unten [MAP(de.map):%s]"       (FF_Bedroom_1, FF_Windows, WindowBedroom1)    { knx="<5/3/62" }
      Contact Window_FF_Bedroom_1_TR            "Fensterkontakt rechts oben [MAP(de.map):%s]"       (FF_Bedroom_1, FF_Windows, WindowBedroom1)    { knx="<5/3/63" }
      Contact Window_FF_Bedroom_1_BR            "Fensterkontakt rechts unten [MAP(de.map):%s]"      (FF_Bedroom_1, FF_Windows, WindowBedroom1)    { knx="<5/3/64" }
      windows.rules
      Code:
      import org.openhab.core.library.types.*
      import org.openhab.core.library.items.*
      import org.openhab.model.script.actions.*
      
      /**
       * Rules for window contacts to transform the states of the contacts into a number
       * used by the corresponding status icons.
       */
      
      /**
       * Calculate the current state of a single window.
       *
       * @param ContactItem cItemTop
       *   Top sensor.
       * @param ContactItem cItemBottom
       *   Bottom sensor.
       *
       * @return Number
       *   Current state of window.
       */
      val org.eclipse.xtext.xbase.lib.Functions$Function2 calculateWindowStateSingle = [
          ContactItem cItemTop,
          ContactItem cItemBottom |
            var nState = 0
            if (cItemTop.state == CLOSED) {
              // Window is tilted.
              nState = nState + 1
            }
            if (cItemBottom.state == CLOSED) {
              // Window is open.
              nState = nState + 2
            }
            // Return state.
            nState
      ]
      
      /**
       * Calculate the current state of a double wing window.
       *
       * @param ContactItem cItemTopLeft
       *   Sensor top left.
       * @param ContactItem cItemBottomLeft
       *   Sensor bottom left.
       * @param ContactItem cItemTopRight
       *   Sensor top right.
       * @param ContactItem cItemBottomRight
       *   Sensor bottom right.
       *
       * @return Number
       *   Current state of window.
       */
      val org.eclipse.xtext.xbase.lib.Functions$Function4 calculateWindowStateDouble = [
          ContactItem cItemTopLeft,
          ContactItem cItemBottomLeft,
          ContactItem cItemTopRight,
          ContactItem cItemBottomRight |
            var int nState = 0
            if (cItemTopLeft.state == CLOSED) {
              // Left window is tilted.
              nState = nState + 1
            }
            if (cItemBottomLeft.state == CLOSED) {
              // Left window is open.
              nState = nState + 2
            }
            if (cItemTopRight.state == CLOSED) {
              // Right window is tilted.
              nState = nState + 4
            }
            if (cItemBottomRight.state == CLOSED) {
              // Right window is open.
              nState = nState + 8
            }
            // Return state.
            return nState
      ]
      
      /**
       * Convert data of window contacts WindowBedroom1.
       */
      rule "window contacts FF_Bedroom_1"
      when
          Item Window_FF_Bedroom_1_TL received update or
          Item Window_FF_Bedroom_1_BL received update or
          Item Window_FF_Bedroom_1_TR received update or
          Item Window_FF_Bedroom_1_BR received update
      then
        logInfo("rules.window.contacts", "Window contacts [FF_Bedroom_1] received update")
        var int sum = 0
        try {
          sum = calculateWindowStateDouble.apply(Window_FF_Bedroom_1_TL, Window_FF_Bedroom_1_BL, Window_FF_Bedroom_1_TR, Window_FF_Bedroom_1_BR) as Integer
        }
        catch (Exception e) {
          logInfo("rules.window.contacts", "Couldn't calculate state of window contacts [FF_Bedroom_1]")
          logDebug("rules.window.contacts", "Error: " + e.toString)
        }
          logInfo("rules.window.contacts", "state of WindowBedroom1: " + sum)
          WindowBedroom1.postUpdate(sum)
      end
      visu_config.xml (mappings)
      Code:
          <mappings>
            <mapping name="WindowStatus1w">
              <entry value="0" default="true">
                <icon flavour="white" name="fts_window_1w"/>
              </entry>
              <entry value="1">
                <icon flavour="white" name="fts_window_1w_tilt"/>
              </entry>
              <entry value="3">
                <icon flavour="white" name="fts_window_1w_open"/>
              </entry>
            </mapping>
            <mapping name="WindowStatus2w">
              <entry value="0" default="true">
                <icon flavour="white" name="fts_window_2w"/>
              </entry>
              <entry value="1">
                <icon flavour="white" name="fts_window_2w_tilt_l"/>
              </entry>
              <entry value="3">
                <icon flavour="white" name="fts_window_2w_open_l"/>
              </entry>
              <entry value="4">
                <icon flavour="white" name="fts_window_2w_tilt_r"/>
              </entry>
              <entry value="5">
                <icon flavour="white" name="fts_window_2w_tilt_lr"/>
              </entry>
              <entry value="7">
                <icon flavour="white" name="fts_window_2w_open_l_tilt_r"/>
              </entry>
              <entry value="12">
                <icon flavour="white" name="fts_window_2w_open_r"/>
              </entry>
              <entry value="13">
                <icon flavour="white" name="fts_window_2w_tilt_l_open_r"/>
              </entry>
              <entry value="15">
                <icon flavour="white" name="fts_window_2w_open_lr"/>
              </entry>
            </mapping>
          </mappings>
      visu_config.xml (pages)
      Code:
            <page name="Fenster" visible="false">
              <group name="Schlafzimmer">
                <info align="right" mapping="WindowStatus2w">
                  <address transform="OH:Number" mode="read">WindowBedroom1</address>
                </info>
              </group>
            </page>
      Das geht bestimmt auch einfacher und kürzer, aber es funktioniert so schon seit einiger Zeit äußerst zuverlässig.

      Kommentar


        #4
        Hey,

        vielen Dank für die Info - ich hatte mir sowas schon gedacht und daher ein Python-Script geschrieben, wird noch um die Kippfunktion erweitert:

        Code:
        def main():
        
           Save_Icons = 1
           knx_write('22/6/2', dpt_encode(Save_Icons, 12, 1))
        
           while 1:
        
              Status_links = dpt_decode(knx_read('22/6/0'), 1, 1)
              Status_rechts = dpt_decode(knx_read('22/6/1'), 1, 1)
        
              if Status_links == 0 and Status_rechts == 0:
                 Icons = 0
              elif Status_links == 1 and Status_rechts == 1:
                 Icons = 1
              elif Status_links == 1 and Status_rechts == 0:
                 Icons = 2
              elif Status_links == 0 and Status_rechts == 1:
                 Icons = 3
        
              if Icons != Save_Icons:
                 knx_write('22/6/2', dpt_encode(Icons, 12, 1))
                 Save_Icons = Icons
        
              sleep(1)
        VG
        Tommy
        Zuletzt geändert von arteco; 02.01.2017, 12:28.

        Kommentar

        Lädt...
        X