[FHEM-Tablet-UI] Keypad für PIN-Eingabe?

Begonnen von alpha1974, 15 Januar 2016, 09:05:36

Vorheriges Thema - Nächstes Thema

alpha1974

Jetzt nicht mehr. Vorher hing es anscheinend in einer Endlosschleife....

So sieht es jetzt aus:
2016-01-17 18:37:08 dummy keypad_key 1
2016-01-17 18:37:09 dummy keypad_key nul
2016-01-17 18:37:10 dummy keypad_key 2
2016-01-17 18:37:10 dummy keypad_key nul
2016-01-17 18:37:11 dummy keypad_key 3
2016-01-17 18:37:12 dummy keypad_key nul
2016-01-17 18:37:13 dummy keypad_key 4
2016-01-17 18:37:13 dummy keypad_key nul
FHEM/Z-Wave USB-Dongle + div. Devices

davedeluxe

Hi,

ich denke das es für deinen Fall nicht in Frage kommt aber ich möchte es einfach mal als Idee hier lassen:

Ich habe nach einer ähnlichen Möglichkeit gesucht mein Tablet zu sperren wenn z.B. die Alarmanlage aktiv ist.
Ich habe das ganze per Tasker gelöst, dieser sperrt das Tablet indem er an oberster Stelle eine PIN-Abfrage stellt. Während diese aktiv ist kann man am Tablet nichts machen.
Ist also ähnlich wie die integrierte Tablet-Sperre, welche aber nicht in Frage kam da ich mein Tablet per Motion wecke und dann nicht immer eine PIN eingeben will.

Tasker lässt sich schön per Push von FHEM steuern.

Grüße

CoolTux

Auch hier noch mal der Hinweis das das AMAD Modul in der derzeitigen Developerversion die Android Pinsperre aktivieren und deaktivieren kann. Hierbei wird ein vorher als Attribut festgelegter Pin genommen.



Grüße
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

NilsB

Zitat von: alpha1974 am 17 Januar 2016, 10:43:11
define keypad_release notify keypad_key:[0-9|#] sleep 0.5; set keypad_key nul

Hallo alpha,

habe den gesamten Aufbau deiner Keypad-Logik jetzt mehrmals im Kopf durchgespielt (mangels eingerichteter Tablet-UI nicht getestet). Mir ist nicht ganz klar, wofür es den o.g. notify überhaupt braucht?
Ich sehe keinen Nachteil darin, wenn der letztgedrückte Key immer in dem Dummy gespeichert bleibt.

Falls es doch einen Grund dafür gab, freue ich mich über Erleuchtung!

Gruß
Nils

alpha1974

Zitat von: NilsB am 21 Februar 2016, 11:15:39
Mir ist nicht ganz klar, wofür es den o.g. notify überhaupt braucht?
Ich sehe keinen Nachteil darin, wenn der letztgedrückte Key immer in dem Dummy gespeichert bleibt.
Ich meine mich zu erinnern, dass ich zunächst andere Tablet-UI-Funktionen genutzt hatte, um die Tasten darzustellen. Durch den Release-Notify wird letztlich nur simuliert, dass eine "gedrückte" Taste wieder "zurückspringt".  In der Umsetzung, die ich letztlich gepostet habe, ist das aber nicht nötig, weil data-type push quasi von alleine zurückspringt und daher nicht gedrückt hängen bleiben kann.
FHEM/Z-Wave USB-Dongle + div. Devices

NilsB

Zitat von: alpha1974 am 21 Februar 2016, 14:42:31
(...) In der Umsetzung, die ich letztlich gepostet habe, ist das aber nicht nötig, weil data-type push quasi von alleine zurückspringt und daher nicht gedrückt hängen bleiben kann.

Okay, dann hatte ich ja doch den richtigen Überblick. Also eher ein historisch bedingtes notify ;)
Danke für die Info, dann kann ich das bei mir direkt streichen. Schließlich kosten notifys ja auch Systemrressourcen :D

Grüße
Nils

coolice

Hallo, mit einem aktuellem Update hat es mir das Eingabefeld zerrissen. Kann mir jemand sagen wie ich das wieder hin bekomme?

hoods

#22
Hallo coolice,

hatte das gleiche Problem. Welche Ursache es hat konnte ich leider nicht herausfinden aber ich habe mein keypad kurzerhand umgebaut.

Hier der Code:
<li data-row="1" data-col="3" data-sizex="4" data-sizey="5">
<header>ALARMANLAGE</header>

<div class="cell big top-space-2x wider">&nbsp;</div>
<div class="cell big top-space-2x wider">Alarm scharf schalten</div>

<div data-type="switch"
data-device="Enable_alarm"
data-set-on="on"
data-set-off=""
data-get-on="on"
data-get-off="off"
data-states='["on","off"]'
data-icons='["fa-lock","fa-unlock"]'
data-colors='["white", "white"]'
data-background-colors='["red", "blue"]'
class="large wider"></div>

       <div data-type="label" class="cell big top-space-2x wider">Alarm unscharf schalten (PIN-Code)</div>
<div class="inline large top-space">
  <div data-type="push" data-icon="" data-device="Keypad_key" data-set-on="1">1</div>
  <div data-type="push" data-icon="" data-device="Keypad_key" data-set-on="4">4</div>
  <div data-type="push" data-icon="" data-device="Keypad_key" data-set-on="7">7</div>
  <div data-type="push" data-icon="" data-device="Keypad_key" data-set-on="?">?</div>
</div>
<div class="inline large">
  <div data-type="push" data-icon="" data-device="Keypad_key" data-set-on="2">2</div>
  <div data-type="push" data-icon="" data-device="Keypad_key" data-set-on="5">5</div>
  <div data-type="push" data-icon="" data-device="Keypad_key" data-set-on="8">8</div>
  <div data-type="push" data-icon="" data-device="Keypad_key" data-set-on="0">0</div>
</div>
<div class="inline large">
  <div data-type="push" data-icon="" data-device="Keypad_key" data-set-on="3">3</div>
  <div data-type="push" data-icon="" data-device="Keypad_key" data-set-on="6">6</div>
  <div data-type="push" data-icon="" data-device="Keypad_key" data-set-on="9">9</div>
  <div data-type="push" data-icon="" data-device="Keypad_key" data-set-on="#">#</div>
</div>

<div data-type="popup" data-device="Enable_alarm" data-get-on="on" data-height="240px" data-width="240px">
<div class="red bold top-space-2x">Show warnings</div>
<div class="dialog">
<header>WARNUNG</header>
<div data-type="label" data-device="Alarm_warning" data-get="lastWarning" class="top-space-3x red big"></div>
<div data-type="link" class="round top-space-3x left-space-3x"
data-width="150" data-height="50"
data-color="white"
data-background-color="red"
data-icon=""
onclick="$('.dialog-close').trigger('click');">OK</div>
</div>
</div>

</li>


Gruss Sven
Odroid C2, FHEM 5.8, HMUSB, Jeelink, Rademacher DuoFern Stick, Benning WR über HTTPMOD

ChrisW

#23
Zitat von: hoods am 16 Februar 2017, 18:25:21
Hallo coolice,

hatte das gleiche Problem. Welche Ursache es hat konnte ich leider nicht herausfinden aber ich habe mein keypad kurzerhand umgebaut.

Hier der Code:
<li data-row="1" data-col="3" data-sizex="4" data-sizey="5">
<header>ALARMANLAGE</header>

<div class="cell big top-space-2x wider">&nbsp;</div>
<div class="cell big top-space-2x wider">Alarm scharf schalten</div>

<div data-type="switch"
data-device="Enable_alarm"
data-set-on="on"
data-set-off=""
data-get-on="on"
data-get-off="off"
data-states='["on","off"]'
data-icons='["fa-lock","fa-unlock"]'
data-colors='["white", "white"]'
data-background-colors='["red", "blue"]'
class="large wider"></div>

       <div data-type="label" class="cell big top-space-2x wider">Alarm unscharf schalten (PIN-Code)</div>
<div class="inline large top-space">
  <div data-type="push" data-icon="" data-device="Keypad_key" data-set-on="1">1</div>
  <div data-type="push" data-icon="" data-device="Keypad_key" data-set-on="4">4</div>
  <div data-type="push" data-icon="" data-device="Keypad_key" data-set-on="7">7</div>
  <div data-type="push" data-icon="" data-device="Keypad_key" data-set-on="?">?</div>
</div>
<div class="inline large">
  <div data-type="push" data-icon="" data-device="Keypad_key" data-set-on="2">2</div>
  <div data-type="push" data-icon="" data-device="Keypad_key" data-set-on="5">5</div>
  <div data-type="push" data-icon="" data-device="Keypad_key" data-set-on="8">8</div>
  <div data-type="push" data-icon="" data-device="Keypad_key" data-set-on="0">0</div>
</div>
<div class="inline large">
  <div data-type="push" data-icon="" data-device="Keypad_key" data-set-on="3">3</div>
  <div data-type="push" data-icon="" data-device="Keypad_key" data-set-on="6">6</div>
  <div data-type="push" data-icon="" data-device="Keypad_key" data-set-on="9">9</div>
  <div data-type="push" data-icon="" data-device="Keypad_key" data-set-on="#">#</div>
</div>

<div data-type="popup" data-device="Enable_alarm" data-get-on="on" data-height="240px" data-width="240px">
<div class="red bold top-space-2x">Show warnings</div>
<div class="dialog">
<header>WARNUNG</header>
<div data-type="label" data-device="Alarm_warning" data-get="lastWarning" class="top-space-3x red big"></div>
<div data-type="link" class="round top-space-3x left-space-3x"
data-width="150" data-height="50"
data-color="white"
data-background-color="red"
data-icon=""
onclick="$('.dialog-close').trigger('click');">OK</div>
</div>
</div>

</li>


Gruss Sven
Super Danke.
Wie pack ich das Pinpad in ein Popup ?
Raspberry PI3 mit allem möglichen.

Standarduser

Indem du ein Popup einfügst und das Pinpad da hinein packst?

ToM_ToM

Ich hatte es zwar irgendwo schon mal gepostet, aber hier nochmal meine Lösung:

Verwendet wird das Alarm - Modul

FHEM-Config
define AlarmKeypadDummy dummy
attr AlarmKeypadDummy DbLogExclude .*
attr AlarmKeypadDummy alarmDevice Sensor
attr AlarmKeypadDummy alarmSettings alarm0,alarm1,alarm2,alarm3,alarm4,alarm5,alarm6,alarm7,|AlarmKeypadDummy:.unlocked|unlocked|off
attr AlarmKeypadDummy event-on-change-reading state,inputPin
attr AlarmKeypadDummy event-on-update-reading key
attr AlarmKeypadDummy group Alarmanlage
attr AlarmKeypadDummy readingList key,inputPin,fails,unlockPin
attr AlarmKeypadDummy room Allgemein
attr AlarmKeypadDummy setList unlockPin
attr AlarmKeypadDummy 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 "";; }

define notify_AlarmanalageUnlocked notify AlarmKeypadDummy:unlocked set Alarmanlage disarmed 0
attr notify_AlarmanalageUnlocked DbLogExclude .*
attr notify_AlarmanalageUnlocked group Alarmanlage
attr notify_AlarmanalageUnlocked room Allgemein

define alarm0.off.N notify (AlarmKeypadDummy:.unlocked) {main::Alarm_Exec("Alarmanlage",0,"$NAME","$EVENT","off")}
attr alarm0.off.N DbLogExclude .*
attr alarm0.off.N group alarmNotifier
attr alarm0.off.N room Alarm


Tablet-UI


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


Sobald die Alarmanlage scharf geschalten wurde, geht das Keypad auf dem Tablet auf und man kann nichts anderes in der Tablet-UI schalten, bis der Pin korrekt eingegeben wurde und die Alarmanlage somit abgeschalten. Es können Zahlen eingegeben und auch beim Vertippen gelöscht werden. Das Raute-Zeichen dient als Bestätigung der Eingabe.
Nach Eingabe der korrekten Pin wird der Alarm oder das Alarmsystem deaktiviert und das Keypad-Popup geschlossen.

Hardware: BananaPi, Busmaster CUL, SanDisk 16GB Ultra SD, 16 GB USB-Stick | Software: Armbian, FHEM 5.8

docb

Hi,
vielen Dank für die geniale Lösung, das ist echt top! Ich habe allerdings ein großes Problem, meine Tablet-UI Oberfläche ist wohl so überladen, dass das Pinpad kaum auf Eingaben reagiert, wenn ich nach Hause komme und das Tablet angeht (das Erneuern der ganzen Werte im Hintergrund legt wohl das Tablet lahm, teilweise wird das Pinpad auch gar nicht mehr korrekt angezeigt, sonder einfach die Zahlen nebeneinander).

Gäbe es eine Möglichkeit, sobald das Popup hochkommt, alle Abfragen im Hintergrund zu unterbinden bis es wieder verschwunden ist (durch Eingabe der korrekten PIN -> device AlarmKeypadDummy unlocked)?
Oder kann ich sobald eigentlich das Popup hochkommt (weil device locked) auf eine andere Seite umleiten, die nur das Pinpad enthält?
Die Lösung über AMAD mit der Systempinsperre von Android funktioniert bei mir leider auch nicht, weil Android 7. 
Ansonsten läuft bei mir FTUI auf Fully (falls das was hilft für die Lösung).

Viele Grüße und frohe Weihnachten ;-)
doc
I love FHEM!

speridal

Hallo zusammen,

seit dem letzten Update hat das AlarmKeypadDummy keine Tasten mehr angenommen. Bei mir lag es an der Einstellung

attr AlarmKeypadDummy readingList key,inputPin,fails,unlockPin

Dort musste ich die "," entfernen, seitdem geht es wieder. Falls das jemand von euch auch hat.

attr AlarmKeypadDummy readingList key inputPin fails unlockPin

Gruß,
Bernd