Alarm und FTUI: Unterschied zwischen den Versionen

Aus FHEMWiki
Zeile 34: Zeile 34:
==3.Schritt: Einbinden des Keypads in das FTUI==
==3.Schritt: Einbinden des Keypads in das FTUI==
Dazu muss in die anzuzeigende Seite der folgende Code eingetragen werden:
Dazu muss in die anzuzeigende Seite der folgende Code eingetragen werden:
<!-- Alarmanlage Keypad -->
  &lt;!-- Alarmanlage Keypad --&gt;
  <div data-type="popup" data-device="AAA.key" data-get-on="locked" data-get-off="unlocked" data-width="400px" data-height="500px" class="interlock">
  &lt;div data-type="popup" data-device="AAA.key" data-get-on="locked" data-get-off="unlocked"
     <div class="red bold top-space-2x"/>
    data-width="400px" data-height="500px" class="interlock"&gt;
     <div class="dialog">
     &lt;div class="red bold top-space-2x"/&gt;
         <header>Alarm deaktivieren</header>
     &lt;div class="dialog"&gt;
         <div data-type="label" class="cell big top-space-2x wider">PIN-Code</div>
         &lt;header&gt;Alarm deaktivieren&lt;/header&gt;
         <div class="inline big top-space">
         &lt;div data-type="label" class="cell big top-space-2x wider"&gt;PIN-Code&lt;/div&gt;
             <div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="1" onclick="">1</div>
         &lt;div class="inline big top-space"&gt;
             <div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="4" onclick="">4</div>
             &lt;div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="1"
             <div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="7" onclick="">7</div>
                onclick=""&gt;1&lt;/div&gt;
             <div data-type="push" data-icon="fa-long-arrow-left" data-device="AAA.key" data-set="key" data-set-on="&lt;" onclick=""/>
             &lt;div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="4"
         </div>
                onclick=""&gt;4&lt;/div&gt;
         <div class="inline big">
             &lt;div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="7"
             <div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="2" onclick="">2</div>
                onclick=""&gt;7&lt;/div&gt;
             <div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="5" onclick="">5</div>
             &lt;div data-type="push" data-icon="fa-long-arrow-left" data-device="AAA.key"
             <div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="8" onclick="">8</div>
                data-set="key" data-set-on="&lt;" onclick=""/&gt;
             <div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="0" onclick="">0</div>
         &lt;/div&gt;
         </div>
         &lt;div class="inline big"&gt;
         <div class="inline big">
             &lt;div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="2"
             <div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="3" onclick="">3</div>
                onclick=""&gt;2&lt;/div&gt;
             <div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="6" onclick="">6</div>
             &lt;div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="5"
             <div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="9" onclick="">9</div>
                onclick=""&gt;5&lt;/div&gt;
             <div data-type="push" data-off-color="green" data-icon="fa-unlock" data-device="AAA.key" data-set="key" data-set-on="#" onclick=""/>
             &lt;div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="8"
         </div>
                onclick=""&gt;8&lt;/div&gt;
         <div class="bg-lightgray border-white top-space centered" style="width:280px; height:50px;">
             &lt;div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="0"
             <div data-type="label" data-device="AAA.key" data-get="inputPin" class="tall"/>
                onclick=""&gt;0&lt;/div&gt;
         </div>
         &lt;/div&gt;
     </div>
         &lt;div class="inline big"&gt;
  </div>
             &lt;div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="3"
                onclick=""&gt;3&lt;/div&gt;
             &lt;div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="6"
                onclick=""&gt;6&lt;/div&gt;
             &lt;div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="9"
                onclick=""&gt;9&lt;/div&gt;
             &lt;div data-type="push" data-off-color="green" data-icon="fa-unlock" data-device="AAA.key"
                data-set="key" data-set-on="#" onclick=""/&gt;
         &lt;/div&gt;
         &lt;div class="bg-lightgray border-white top-space centered" style="width:280px; height:50px;"&gt;
             &lt;div data-type="label" data-device="AAA.key" data-get="inputPin" class="tall"/&gt;
         &lt;/div&gt;
     &lt;/div&gt;
  &lt;/div&gt;


==Bedienung==
==Bedienung==
[[Kategorie:FHEM Tablet UI]]
[[Kategorie:FHEM Tablet UI]]
[[Kategorie:Examples]]
[[Kategorie:Examples]]

Version vom 28. Februar 2018, 08:45 Uhr

Ziel und Voraussetzungen

Auf dieser Seite wird erläutert, wie man das Modul Alarm mit Hilfe eines Keypads aus dem FTUI heraus steuert.

Ziel ist, das TabletUI mit einem Keypad zu schützen während der Alarm aktiv ist und darüber hinaus über Eingabe des korrekten Pins die Alarmanlage zu entschärfen.

  • Das Modul Alarm muss installiert sein, das Alarmdevice wird im Folgenden AAA genannt (ansonsten muss der entsprechende Name in den nachfolgenden Beispielen geändert werden)
  • Es muss eine laufende TabletUI-Instanz vorhanden sein

1.Schritt: Anlegen eines Dummy

defmod AAA.key dummy
attr AAA.key alarmDevice Sensor
attr AAA.key alarmSettings alarm<alarmlevel>,|AAA.key:.unlocked|unlocked|off   # wird durch das Modul Alarm angelegt
attr AAA.key event-on-change-reading state,inputPin
attr AAA.key event-on-update-reading key
attr AAA.key readingList key,inputPin,fails,unlockPin
attr AAA.key room Alarm
attr AAA.key setList unlockPin
attr AAA.key userReadings inputPin:key:.[0-9] { return ReadingsVal($NAME, "inputPin", "*") . ReadingsVal($NAME, "key", "0");; }, fails:key:.# { if (ReadingsVal($NAME, "inputPin", "0") ne ReadingsVal($NAME, "unlockPin", "0")) { return ReadingsVal($NAME, "fails", 0)+1;; } else { return 0;; } }, state:key:.# { if (ReadingsVal($NAME, "inputPin", "0") ne ReadingsVal($NAME, "unlockPin", "0")) { return "locked";; } else { return "unlocked";; } }, inputPin:key:.[\<] { my $inputVal = ReadingsVal($NAME, "inputPin", "0");; chop($inputVal);; return $inputVal;; },  inputPin:key:.# { return "";; }

Darin muss natürlich <alarmlevel> durch den gewünschten Level ersetzt werden (die Änderung dieses Attributes erfolgt automatisch durch das Alarm-Modul, bitte nicht manuell eingeben). In diesem Dummy kann über den Befehl

set unlockPin <Wert>

der gültige Pincode gesetzt werden

Die userReadings füllen (je nach Änderung des Readings key) die folgenden Readings:

  • fails (Anzahl ungültiger Versuche)
  • inputPin (Eingabe Pin, als Aneinanderreihung der einzelnen Keys)
  • state (locked/unlocked)

2.Schritt: Anlegen eines Notify

Wenn der richtige Code eingegeben wurde, soll die Alarmanlage unscharf geschaltet werden:

defmod AAA.disarmed.N notify AAA.key:unlocked set AAA disarmed <alarmlevel>
attr AAA.disarmed.N room Alarm

3.Schritt: Einbinden des Keypads in das FTUI

Dazu muss in die anzuzeigende Seite der folgende Code eingetragen werden:

 <!-- Alarmanlage Keypad -->
<div data-type="popup" data-device="AAA.key" data-get-on="locked" data-get-off="unlocked"
   data-width="400px" data-height="500px" class="interlock">
   <div class="red bold top-space-2x"/>
   <div class="dialog">
       <header>Alarm deaktivieren</header>
       <div data-type="label" class="cell big top-space-2x wider">PIN-Code</div>
       <div class="inline big top-space">
           <div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="1"
               onclick="">1</div>
           <div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="4"
               onclick="">4</div>
           <div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="7"
               onclick="">7</div>
           <div data-type="push" data-icon="fa-long-arrow-left" data-device="AAA.key"
               data-set="key" data-set-on="<" onclick=""/>
       </div>
       <div class="inline big">
           <div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="2"
               onclick="">2</div>
           <div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="5"
               onclick="">5</div>
           <div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="8"
               onclick="">8</div>
           <div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="0"
               onclick="">0</div>
       </div>
       <div class="inline big">
           <div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="3"
               onclick="">3</div>
           <div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="6"
               onclick="">6</div>
           <div data-type="push" data-icon="" data-device="AAA.key" data-set="key" data-set-on="9"
               onclick="">9</div>
           <div data-type="push" data-off-color="green" data-icon="fa-unlock" data-device="AAA.key"
               data-set="key" data-set-on="#" onclick=""/>
       </div>
       <div class="bg-lightgray border-white top-space centered" style="width:280px; height:50px;">
           <div data-type="label" data-device="AAA.key" data-get="inputPin" class="tall"/>
       </div>
   </div>
</div>

Bedienung