Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Visualisierung
    4. [Vorlage] VIS: View durch Pin schützen

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    [Vorlage] VIS: View durch Pin schützen

    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      Micha3004 @Lueghi last edited by

      @lueghi

      ich denke das ich es auch so machen werde. bin ja eh noch nicht 100% fertig mit meiner VIS

      1 Reply Last reply Reply Quote 0
      • S
        Shigoru last edited by

        Es funktioniert bei mir nicht. Hmmm...

        Hallo zusammen,

        ich habe das Javascript importiert. Die Daten angepasst nur Name und Projekt
        Da das Script die Datenpunkte unter javascript.0 gesperrt angelegt hat habe ich im Skript dann noch die Anlage der Variablen ausgetauscht. Der Code war auch in einem Post vorhanden

        Bildschirmfoto 2024-01-01 um 15.17.46.png

        so schaut das Skript im Moment aus

        /*******************************************************************************
         * ---------------------------
         * Pin-Schutz für VIS-View
         * ---------------------------
         * Autor: Mic
         * Change Log
         *  - 0.2 - Fix: 0 on keypad was not recognized
         *  - 0.1 - initial version
         * Support: https://forum.iobroker.net/viewtopic.php?f=30&t=19871
         ******************************************************************************/
        
        /*******************************************************************************
         * Konfiguration
         ******************************************************************************/
        const STATE_PATH = 'javascript.' + instance + '.' + 'visViewPinSperre.';
        
        const LOGGING = true;         // Detaillierte Ausgabe im Log. Falls keine Probleme, dann auf false setzen.
        
        
        /*******************************************************************************
         * Konfiguration: Views
         ******************************************************************************/
        // Es können beliebig mehr Views hinzugefügt oder auf eine limitiert werden, bitte aber Aufbau beibehalten!
        const PIN_VIEWS = [
          {
            name:       'reboot',        // Name der View, zu der bei Erfolg gewechselt werden soll
            project:    'main',            // VIS-Projekt, in dem die View ist, für den Viewwechsel bei Erfolg. Wert bekommt man u.a.: Vis -> Menü: Setup > Projekte (den Namen des jeweilgen Projektes nehmen)
            instance:   'FFFFFFFF',      // Funktioniert bei mir (und einigen anderen) immer mit 'FFFFFFFF', ansonsten Wert vom Vis, Menü Tools, Feld "Instanz ID" nehmen
            pin:        '1234',          // Pin
          },
          {
            name:       'Test',          
            project:    'Testprojekt',   
            instance:   'FFFFFFFF',      
            pin:        '5678',          
          },
        ];
        
        
        /**********************************************************************************************************
         ++++++++++++++++++++++++++++ Ab hier nichts mehr ändern / Stop editing here! ++++++++++++++++++++++++++++
         *********************************************************************************************************/
        
        
        /*******************************************************************************
         * Globale Variablen
         *******************************************************************************/
        // Array, pro View ein Element
        var G_LastKeyPressed = [];      // Letzte Taste, die gedrückt wurde
        var G_PinBufferKeys = [];       // Puffer für eingegebene Ziffern
        var G_PinBufferWildcards = [];  // Für Vis-Anzeigefeld der Pineingabe, füllt sich mit "*" nach jeder Zifferneingabe
        
        /*******************************************************************************
         * Executed on every script start.
         *******************************************************************************/
        init();
        function init() {
         
            // Create states
            createScriptStates();
        
            // 1. Initialize global variables
            // 2. Reset for each view
            setTimeout(function(){
                for (let i = 0; i < PIN_VIEWS.length; i++) {
                    // Initialize global variables
                    G_LastKeyPressed[PIN_VIEWS[i].name] = '';
                    G_PinBufferKeys[PIN_VIEWS[i].name] = '';
                    G_PinBufferWildcards[PIN_VIEWS[i].name] = '';        
                    // Reset für jede View durchführen
                    resetPin(PIN_VIEWS[i].name)
                }
            }, 3000);
        
            // Main Script starten, 5 Sekunden nach State-Generierung
            setTimeout(main, 5000);
        
        }
        
        /*******************************************************************************
         * Haupt-Skript
         *******************************************************************************/
        function main() {
            // Überwacht das Tastenfeld in VIS für jede View
            for (var i = 0; i < PIN_VIEWS.length; i++) {
                on({id: STATE_PATH + PIN_VIEWS[i].name + '.CurrentKey', change: "any"}, function (obj) {
                    var currView = obj.id.substr(STATE_PATH.length).split(".")[0]; // get View Name simply from obj.id
                    if(LOGGING) if(obj.state.val !== '') log('Eingabe über Tastenfeld: ' + obj.state.val + ', Viewname: ' + currView);
                    switch(obj.state.val) {
                        case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9:
                            G_LastKeyPressed[currView] = obj.state.val;
                            setState(obj.id, '');
                            userEnteredNumber(currView);
                            break;
                        case 'Enter':   // Der User hat die Pin-Eingabe bestätigt.
                            checkEnteredPin(currView);
                            break;
                        case 'Reset':
                            resetPin(currView);
                            break;
                        default:
                            //None
                    } 
                });
            }
        }
        
        
        /********************************
         * Create States
         ********************************/
        function createScriptStates() {
            for (let i = 0; i < PIN_VIEWS.length; i++) {
                createState(STATE_PATH + PIN_VIEWS[i].name + '.CurrentKey', {'name':'Mit Tasten aus VIS setzen', 'type':'mixed', 'read':true, 'write':true, 'role':'info', 'def':'' });
                createState(STATE_PATH + PIN_VIEWS[i].name + '.WrongPinEntered', {'name':'Pin-Fehler', 'type':'boolean', 'read':true, 'write':true, 'role':'info'});
                createState(STATE_PATH + PIN_VIEWS[i].name + '.PinWildcards', {'name':'Sterne (*) für VIS-Anzeige', 'type':'string', 'read':true, 'write':true, 'role':'info', 'def':'' });
            }
        }
        
        
        
        /********************************
         * Wird ausgeführt, sobald der User eine Nummer im Tastenfeld eingibt.
         * @param {string}   viewName     Name der View
         *********************************/
        function userEnteredNumber(viewName) {
            G_PinBufferKeys[viewName] = G_PinBufferKeys[viewName] + G_LastKeyPressed[viewName];
            G_PinBufferWildcards[viewName] = G_PinBufferWildcards[viewName] + ' *';
            setState(STATE_PATH + viewName + '.PinWildcards', G_PinBufferWildcards[viewName]);
        }
        
        /********************************
         * Wird ausgeführt, sobald der User E für "Enter" eingibt
         * @param {string}   viewName     Name der View
         ********************************/
        function checkEnteredPin(viewName) {
            if (G_PinBufferKeys[viewName] == getPresetElement(viewName, 'pin')) {
                if(LOGGING) log('Pin-Eingabe erfolgreich, View [' + viewName + ']');
                onSuccess(viewName);
                setTimeout(function() { resetPin(viewName) }, 3000);    // Reset nach 3 Sekunden
            } else {
                if(LOGGING) log('Falschen Pin eingegeben, View [' + viewName + ']');
                setState(STATE_PATH + viewName + '.WrongPinEntered', true);
                resetPin(viewName);
            }
        }    
        
        /********************************
         * Reset
         * @param {string}   viewName     Name der View
         ********************************/
        function resetPin(viewName) {
            if(LOGGING) log('Reset Pin, View-Name: [' + viewName + ']');
            G_PinBufferWildcards[viewName] = '';
            G_PinBufferKeys[viewName] = '';
            setState(STATE_PATH + viewName + '.CurrentKey', '');
            setState(STATE_PATH + viewName + '.PinWildcards', '');
            setStateDelayed(STATE_PATH + viewName + '.WrongPinEntered', false, 3000); // Erst nach 3 Sekunden, für VIS-Anzeige
        }
        
        /********************************
         * Wird bei erfolgreicher Pin-Eingabe ausgeführt
         * @param {string}   viewName     Name der View
         ********************************/
        function onSuccess(viewName){
            // Change View
            setState("vis-2.0.control.instance", getPresetElement(viewName, 'instance'));
            setState("vis-2.0.control.data",     getPresetElement(viewName, 'project') + '/' + viewName);
            setState("vis-2.0.control.command",  'changeView');
        }
        
        
        /********************************
         * Gibt Elemente von PIN_VIEWS zurück
         * @param {string}   viewName     Name of the view
         * @param {string}   key          'project', 'instance', 'pin'
         * @return {string}  Content of the element, e.g. the Pin "1234" for element 'pin'
         ********************************/
        function getPresetElement(viewName, key) {
            var keyEntry = '';
            for (let i = 0; i < PIN_VIEWS.length; i++) {
                if (PIN_VIEWS[i].name === viewName) {
                    keyEntry = PIN_VIEWS[i][key]
                }
            }
            return keyEntry;
        }
        

        ich habe die Widgets importiert und die Buttons mit dem Javascript verbunden

        Bildschirmfoto 2024-01-01 um 15.19.14.png

        Wenn ich jetzt in der Vis auf die Buttons drücke passiert nix!?

        Es werden auch keine Zahlen in die Werfelder des Objekts Current key geschrieben!

        Was mache ich falsch!?

        Ich benutzte die vis-2 darum hätte ich den Teil in dem Skript von vis auf vis-2 geändert. Hoffe das stimmt.

        function onSuccess(viewName){
            // Change View
            setState("vis-2.0.control.instance", getPresetElement(viewName, 'instance'));
            setState("vis-2.0.control.data",     getPresetElement(viewName, 'project') + '/' + viewName);
            setState("vis-2.0.control.command",  'changeView');
        }
        

        Jede Hilfe ist willkommen. Danke und guten Rutsch nachträglich

        Shigoru

        A 1 Reply Last reply Reply Quote 0
        • A
          andreep @Shigoru last edited by

          @shigoru

          Also bei mir läuft es jetzt mit VIS 2. Habe die Buttons wie im Bild geändert. Dann habe ich noch dein Skript wie im Bild angepasst.VIS_2_Buttons_anpassen.JPG Skript.JPG

          H 1 Reply Last reply Reply Quote 0
          • P
            PeZi @Eisbaeeer last edited by

            @eisbaeeer
            @matthias-s
            Ich habe bei mir die ganze Zeile

            //    instance:   'FFFFFFFF',      // Funktioniert bei mir (und einigen anderen) immer mit 'FFFFFFFF', ansonsten Wert vom Vis, Menü Tools, Feld "Instanz ID" nehmen
            

            einfach auskommentiert.
            Dann wird die geschützte View nur auf dem Gerät aufgerufen, auf dem die PIN eingegeben wurde.
            Ich verwende allerdings nur eine PIN-geschützte View. Wie sich das bei mehreren Views verhält habe ich nicht getestet.

            Kann jemand das Verhalten auch für mehrere Views bestätigen?

            1 Reply Last reply Reply Quote 0
            • H
              HeN30 @andreep last edited by

              @andreep Ich versuche auch gerade das ganze auf VIS2 zu implementieren. Funktioniert alles auch soweit, bis auf die Wildcard-Anzeige bei PIN-Eingabe. Wie hast du das hinbekommen?
              Und wie kann ich bei "Enter" und "Reset" Symbole zuweisen?

              1 Reply Last reply Reply Quote 0
              • andre1de
                andre1de @Mic last edited by

                Hallo,
                ich kriege Fehler:
                Screenshot 2024-09-08 at 20-06-08 logs - raspberrypi.png
                Wo und wie soll ich ask-flage setzen?
                Danke!

                C 1 Reply Last reply Reply Quote 0
                • C
                  Chrunchy @andre1de last edited by

                  @andre1de Das ACK-Flag setzt du, indem du in deinem Script, überall wo ein setState verwendet wird, das Flag einfügst.

                  Dazu wird der setState-Befehl innerhalb der Klammer um ein ", true" erweitert.

                  setState(STATE_PATH + viewName + '.WrongPinEntered', true);
                  

                  wird zu

                  setState(STATE_PATH + viewName + '.WrongPinEntered', true, true);
                  
                  L 1 Reply Last reply Reply Quote 0
                  • L
                    Lueghi @Chrunchy last edited by

                    @chrunchy Dieses Thema mit dem fehlenden ACK-Flag kam ja schon öfter auf. Kann das denn niemand im Originalcode einbringen?

                    C mcm1957 2 Replies Last reply Reply Quote 0
                    • C
                      Chrunchy @Lueghi last edited by

                      @lueghi Das musst du den Entwickler fragen.

                      1 Reply Last reply Reply Quote 0
                      • mcm1957
                        mcm1957 @Lueghi last edited by

                        @lueghi said in [Vorlage] VIS: View durch Pin schützen:

                        @chrunchy Dieses Thema mit dem fehlenden ACK-Flag kam ja schon öfter auf. Kann das denn niemand im Originalcode einbringen?

                        Wenn es um einen Adapter geht bitte Issue im Adapter Repository anlegen.

                        Es scheint sich hier aber um ein Script zu handeln. Nun ja - die meistens sind nicht in GitHub versioniert. Damit ist schon mal schwer zu sagen, was denn der "Originalcode" ist....

                        1 Reply Last reply Reply Quote 0
                        • H
                          hugo1217 last edited by

                          Hallo zusammen,

                          kann man es auch als Dialog öffnen bzw. das view in einem Dialog-Fenster??

                          Gruß

                          1 Reply Last reply Reply Quote 0
                          • P
                            ps1304 last edited by ps1304

                            Habe das auch für mich auf VIS 2 adaptiert - Import der alten Widgets ging bei mir nicht.

                            c25b4e24-a996-4d9b-883a-80399721e09d-image.png

                            Seite zum importieren:


                            {
                            "settings": {
                            "style": {
                            "background_class": "",
                            "background-color": "black"
                            },
                            "theme": "black-tie",
                            "sizex": "1280",
                            "sizey": "800",
                            "gridSize": "",
                            "snapType": null,
                            "useBackground": false
                            },
                            "widgets": {
                            "w001554": {
                            "tpl": "tplInventwoWidgetUniversal",
                            "data": {
                            "bindings": [],
                            "type": "nav",
                            "g_common": true,
                            "mode": "singleButton",
                            "direction": "row",
                            "oid": "",
                            "httpType": "send",
                            "buttonSize": 110,
                            "btnSpacing": 10,
                            "countStates": 0,
                            "dialogWidth": 500,
                            "g_attr_group_type_view_in_dialog": true,
                            "dialogHeight": 300,
                            "dialogPadding": 10,
                            "dialogBackground": "rgb(18, 18, 18)",
                            "dialogTitleColor": "rgb(255,255,255)",
                            "dialogTitleSize": 20,
                            "dialogCloseButtonBackground": "rgba(255,255,255,0)",
                            "dialogCloseButtonColor": "rgba(255,255,255,1)",
                            "dialogCloseButtonSize": 14,
                            "dialogBorderRadiusTopLeft": 12,
                            "dialogBorderRadiusTopRight": 0,
                            "dialogBorderRadiusBottomRight": 12,
                            "dialogBorderRadiusBottomLeft": 0,
                            "feedbackDuration": 0,
                            "g_attr_group_click_feedback": true,
                            "backgroundFeedback": "rgba(69, 86, 24, 1)",
                            "outerShadowColorFeedback": "rgba(0, 0, 0, 1)",
                            "contentBlinkInterval": 0,
                            "g_attr_group_state_default": true,
                            "outerShadowColor": "",
                            "colorPickerColorModel": "hex",
                            "g_attr_content_color_picker": true,
                            "colorPickerWidth": 200,
                            "colorPickerHandleSize": 8,
                            "colorPickerHandleMargin": 6,
                            "colorPickerComponentsSpace": 12,
                            "colorPickerDirection": "vertical",
                            "colorPickerBorderWidth": 0,
                            "colorPickerShowWheel": true,
                            "colorPickerShowSaturation": true,
                            "colorPickerShowValue": true,
                            "textDecoration": "none",
                            "g_attr_group_css_text": true,
                            "textMarginTop": 0,
                            "textMarginBottom": 0,
                            "textMarginLeft": 0,
                            "textMarginRight": 0,
                            "contentType": "image",
                            "g_attr_group_css_content": true,
                            "contentMarginTop": 0,
                            "contentMarginBottom": 0,
                            "contentMarginLeft": 0,
                            "contentMarginRight": 0,
                            "contentSize": 60,
                            "contentRotation": 0,
                            "contentMirror": false,
                            "flexDirection": "column",
                            "g_attr_group_css_alignment": true,
                            "alignItems": "flex-start",
                            "textAlign": "start",
                            "contentAlign": "start",
                            "backgroundOpacity": 1,
                            "g_attr_group_css_transparency": true,
                            "contentOpacity": 1,
                            "paddingLeft": 10,
                            "g_attr_group_css_spacing": true,
                            "paddingRight": 10,
                            "paddingTop": 10,
                            "paddingBottom": 10,
                            "borderRadiusTopLeft": 15,
                            "g_attr_group_css_border_radius": true,
                            "borderRadiusTopRight": 15,
                            "borderRadiusBottomRight": 15,
                            "borderRadiusBottomLeft": 15,
                            "borderSizeTop": 2,
                            "g_attr_group_css_border": true,
                            "borderSizeBottom": 2,
                            "borderSizeLeft": 2,
                            "borderSizeRight": 2,
                            "borderStyle": "solid",
                            "outerShadowX": 0,
                            "g_attr_group_css_outer_shadow": true,
                            "outerShadowY": 0,
                            "outerShadowBlur": 0,
                            "outerShadowSize": 0,
                            "innerShadowX": 0,
                            "g_attr_group_css_inner_shadow": true,
                            "innerShadowY": 0,
                            "innerShadowBlur": 0,
                            "innerShadowSize": 0,
                            "background": "rgba(34,25,77,0.04)",
                            "textColor": "rgba(247,246,253,1)",
                            "borderColor": "rgba(210,232,96,1)",
                            "text": "",
                            "image": "",
                            "invertOrder": true,
                            "g_css_font_text": true,
                            "valueTrue": "true",
                            "valueFalse": "false"
                            },
                            "style": {
                            "bindings": [],
                            "left": "351px",
                            "top": "149px",
                            "width": "488.976px",
                            "height": "420.986px",
                            "position": "absolute",
                            "overflow": "visible",
                            "z-index": "2",
                            "font-size": "small",
                            "font-weight": "bold"
                            },
                            "widgetSet": "vis-2-widgets-inventwo"
                            },
                            "w001557": {
                            "tpl": "tplImage",
                            "data": {
                            "bindings": [],
                            "refreshInterval": 0,
                            "g_common": true,
                            "src": "/vis-icontwo/Backgrounds/101.jpg",
                            "name": "Wallpaper",
                            "comment": null,
                            "class": "rgb-glow",
                            "filterkey": null,
                            "multi-views": null,
                            "locked": null,
                            "g_fixed": true,
                            "g_css_border": true
                            },
                            "style": {
                            "bindings": [],
                            "left": 6,
                            "top": 7,
                            "width": "1260",
                            "height": "740",
                            "z-index": "0",
                            "border-radius": "15"
                            },
                            "widgetSet": "basic"
                            },
                            "w001624": {
                            "tpl": "tplValueString",
                            "data": {
                            "oid": "javascript.1.visViewPinSperre._shelly.PinWildcards",
                            "g_fixed": true,
                            "g_visibility": false,
                            "g_css_font_text": true,
                            "g_css_background": true,
                            "g_css_shadow_padding": false,
                            "g_css_border": true,
                            "g_gestures": false,
                            "g_signals": false,
                            "signals-cond-0": "==",
                            "signals-val-0": true,
                            "signals-icon-0": "/vis/signals/lowbattery.png",
                            "signals-icon-size-0": 0,
                            "signals-blink-0": false,
                            "signals-horz-0": 0,
                            "signals-vert-0": 0,
                            "signals-hide-edit-0": false,
                            "signals-cond-1": "==",
                            "signals-val-1": true,
                            "signals-icon-1": "/vis/signals/lowbattery.png",
                            "signals-icon-size-1": 0,
                            "signals-blink-1": false,
                            "signals-horz-1": 0,
                            "signals-vert-1": 0,
                            "signals-hide-edit-1": false,
                            "signals-cond-2": "==",
                            "signals-val-2": true,
                            "signals-icon-2": "/vis/signals/lowbattery.png",
                            "signals-icon-size-2": 0,
                            "signals-blink-2": false,
                            "signals-horz-2": 0,
                            "signals-vert-2": 0,
                            "signals-hide-edit-2": false,
                            "html_append": "",
                            "test_html": " * * * *",
                            "lc-type": "last-change",
                            "lc-is-interval": true,
                            "lc-is-moment": false,
                            "lc-format": "",
                            "lc-position-vert": "top",
                            "lc-position-horz": "right",
                            "lc-offset-vert": 0,
                            "lc-offset-horz": 0,
                            "lc-font-size": "12px",
                            "lc-font-family": "",
                            "lc-font-style": "",
                            "lc-bkg-color": "",
                            "lc-color": "",
                            "lc-border-width": "0",
                            "lc-border-style": "",
                            "lc-border-color": "",
                            "lc-border-radius": 10,
                            "lc-zindex": 0,
                            "name": "",
                            "visibility-cond": "==",
                            "visibility-val": 1,
                            "visibility-groups-action": "hide",
                            "class": "",
                            "filterkey": "",
                            "bindings": []
                            },
                            "style": {
                            "left": "492px",
                            "top": "152px",
                            "border-width": "",
                            "border-style": "",
                            "border-color": "",
                            "border-radius": "4px",
                            "width": "211.983px",
                            "height": "32px",
                            "background-color": "",
                            "opacity": "0.9",
                            "color": "#ffffff",
                            "text-align": "center",
                            "line-height": "40px",
                            "font-size": "20px",
                            "z-index": 11,
                            "text-shadow": "",
                            "font-family": "RobotoCondensed-Bold",
                            "background": "rgba(111,113,111,0.5)",
                            "bindings": []
                            },
                            "widgetSet": "basic"
                            },
                            "w001625": {
                            "tpl": "tplValueString",
                            "data": {
                            "oid": "javascript.1.visViewPinSperre._shelly.CurrentKey",
                            "g_fixed": false,
                            "g_visibility": true,
                            "g_css_font_text": true,
                            "g_css_background": false,
                            "g_css_shadow_padding": false,
                            "g_css_border": false,
                            "g_gestures": false,
                            "g_signals": false,
                            "g_last_change": false,
                            "visibility-cond": "==",
                            "visibility-val": "true",
                            "visibility-groups-action": "hide",
                            "signals-cond-0": "==",
                            "signals-val-0": true,
                            "signals-icon-0": "/vis/signals/lowbattery.png",
                            "signals-icon-size-0": 0,
                            "signals-blink-0": false,
                            "signals-horz-0": 0,
                            "signals-vert-0": 0,
                            "signals-hide-edit-0": false,
                            "signals-cond-1": "==",
                            "signals-val-1": true,
                            "signals-icon-1": "/vis/signals/lowbattery.png",
                            "signals-icon-size-1": 0,
                            "signals-blink-1": false,
                            "signals-horz-1": 0,
                            "signals-vert-1": 0,
                            "signals-hide-edit-1": false,
                            "signals-cond-2": "==",
                            "signals-val-2": true,
                            "signals-icon-2": "/vis/signals/lowbattery.png",
                            "signals-icon-size-2": 0,
                            "signals-blink-2": false,
                            "signals-horz-2": 0,
                            "signals-vert-2": 0,
                            "signals-hide-edit-2": false,
                            "lc-type": "last-change",
                            "lc-is-interval": true,
                            "lc-is-moment": false,
                            "lc-format": "",
                            "lc-position-vert": "top",
                            "lc-position-horz": "right",
                            "lc-offset-vert": 0,
                            "lc-offset-horz": 0,
                            "lc-font-size": "12px",
                            "lc-font-family": "",
                            "lc-font-style": "",
                            "lc-bkg-color": "",
                            "lc-color": "",
                            "lc-border-width": "0",
                            "lc-border-style": "",
                            "lc-border-color": "",
                            "lc-border-radius": 10,
                            "lc-zindex": 0,
                            "html_prepend": "Falsche Pin",
                            "visibility-oid": "javascript.1.visViewPinSperre._shelly.WrongPinEntered",
                            "bindings": []
                            },
                            "style": {
                            "left": 508,
                            "top": 158,
                            "width": "180px",
                            "height": "24px",
                            "z-index": "100",
                            "text-align": "center",
                            "color": "#cc1919",
                            "font-weight": "bold",
                            "bindings": []
                            },
                            "widgetSet": "basic"
                            },
                            "w001626": {
                            "tpl": "tplMetroTileState",
                            "data": {
                            "bindings": [],
                            "hover": "true",
                            "g_common": true,
                            "transform": "true",
                            "bg_class_false": "bg-orange",
                            "bg_class_true": "bg-orange",
                            "icon_class_false": "",
                            "g_icon": true,
                            "icon_class_true": "",
                            "state_oid": "javascript.1.visViewPinSperre._shelly.CurrentKey",
                            "value": "1",
                            "label_false": "1",
                            "label_true": "1",
                            "g_css_font_text": true,
                            "g_css_background": true
                            },
                            "style": {
                            "bindings": [],
                            "left": 493,
                            "top": 189,
                            "width": "67.9861px",
                            "height": "74.9757px",
                            "color": "rgba(76,214,65,1)",
                            "font-size": "large",
                            "background-color": "rgba(185,212,39,1)",
                            "z-index": "6"
                            },
                            "widgetSet": "metro"
                            },
                            "w001627": {
                            "tpl": "tplMetroTileState",
                            "data": {
                            "bindings": [],
                            "hover": "true",
                            "g_common": true,
                            "transform": "true",
                            "bg_class_false": "bg-orange",
                            "bg_class_true": "bg-orange",
                            "icon_class_false": "",
                            "g_icon": true,
                            "icon_class_true": "",
                            "state_oid": "javascript.1.visViewPinSperre._shelly.CurrentKey",
                            "value": "2",
                            "label_false": "2",
                            "label_true": "2",
                            "g_css_font_text": true,
                            "g_css_background": true
                            },
                            "style": {
                            "bindings": [],
                            "left": 564,
                            "top": 190,
                            "width": "67.9861px",
                            "height": "74.9757px",
                            "color": "rgba(76,214,65,1)",
                            "font-size": "large",
                            "background-color": "rgba(185,212,39,1)",
                            "z-index": "6"
                            },
                            "widgetSet": "metro"
                            },
                            "w001628": {
                            "tpl": "tplMetroTileState",
                            "data": {
                            "bindings": [],
                            "hover": "true",
                            "g_common": true,
                            "transform": "true",
                            "bg_class_false": "bg-orange",
                            "bg_class_true": "bg-orange",
                            "icon_class_false": "",
                            "g_icon": true,
                            "icon_class_true": "",
                            "state_oid": "javascript.1.visViewPinSperre._shelly.CurrentKey",
                            "value": "0",
                            "label_false": "0",
                            "label_true": "0",
                            "g_css_font_text": true,
                            "g_css_background": true
                            },
                            "style": {
                            "bindings": [],
                            "left": 563,
                            "top": 411,
                            "width": "67.9861px",
                            "height": "74.9757px",
                            "color": "rgba(76,214,65,1)",
                            "font-size": "large",
                            "background-color": "rgba(185,212,39,1)",
                            "z-index": "6"
                            },
                            "widgetSet": "metro"
                            },
                            "w001629": {
                            "tpl": "tplMetroTileState",
                            "data": {
                            "bindings": [],
                            "hover": "true",
                            "g_common": true,
                            "transform": "true",
                            "bg_class_false": "bg-orange",
                            "bg_class_true": "bg-orange",
                            "icon_class_false": "",
                            "g_icon": true,
                            "icon_class_true": "",
                            "state_oid": "javascript.1.visViewPinSperre._shelly.CurrentKey",
                            "value": "3",
                            "label_false": "3",
                            "label_true": "3",
                            "g_css_font_text": true,
                            "g_css_background": true
                            },
                            "style": {
                            "bindings": [],
                            "left": 633,
                            "top": 190,
                            "width": "67.9861px",
                            "height": "74.9757px",
                            "color": "rgba(76,214,65,1)",
                            "font-size": "large",
                            "background-color": "rgba(185,212,39,1)",
                            "z-index": "6"
                            },
                            "widgetSet": "metro"
                            },
                            "w001630": {
                            "tpl": "tplMetroTileState",
                            "data": {
                            "bindings": [],
                            "hover": "true",
                            "g_common": true,
                            "transform": "true",
                            "bg_class_false": "bg-orange",
                            "bg_class_true": "bg-orange",
                            "icon_class_false": "",
                            "g_icon": true,
                            "icon_class_true": "",
                            "state_oid": "javascript.1.visViewPinSperre._shelly.CurrentKey",
                            "value": "Enter",
                            "label_false": "Enter",
                            "label_true": "Enter",
                            "name": null,
                            "comment": null,
                            "class": "keypad",
                            "filterkey": null,
                            "multi-views": null,
                            "locked": null,
                            "g_fixed": true,
                            "select_on_value": false,
                            "g_css_font_text": true,
                            "g_css_background": true
                            },
                            "style": {
                            "bindings": [],
                            "left": 633,
                            "top": 411,
                            "width": "67.9861px",
                            "height": "74.9757px",
                            "color": "rgba(76,214,65,1)",
                            "font-size": "large",
                            "background-color": "rgba(185,212,39,1)",
                            "z-index": "6"
                            },
                            "widgetSet": "metro"
                            },
                            "w001631": {
                            "tpl": "tplMetroTileState",
                            "data": {
                            "bindings": [],
                            "hover": "true",
                            "g_common": true,
                            "transform": "true",
                            "bg_class_false": "bg-orange",
                            "bg_class_true": "bg-orange",
                            "icon_class_false": "",
                            "g_icon": true,
                            "icon_class_true": "",
                            "state_oid": "javascript.1.visViewPinSperre._shelly.CurrentKey",
                            "value": "4",
                            "label_false": "4",
                            "label_true": "4",
                            "g_css_font_text": true,
                            "g_css_background": true
                            },
                            "style": {
                            "bindings": [],
                            "left": 493,
                            "top": 261,
                            "width": "67.9861px",
                            "height": "74.9757px",
                            "color": "rgba(76,214,65,1)",
                            "font-size": "large",
                            "background-color": "rgba(185,212,39,1)",
                            "z-index": "6"
                            },
                            "widgetSet": "metro"
                            },
                            "w001632": {
                            "tpl": "tplMetroTileState",
                            "data": {
                            "bindings": [],
                            "hover": "true",
                            "g_common": true,
                            "transform": "true",
                            "bg_class_false": "bg-orange",
                            "bg_class_true": "bg-orange",
                            "icon_class_false": "",
                            "g_icon": true,
                            "icon_class_true": "",
                            "state_oid": "javascript.1.visViewPinSperre._shelly.CurrentKey",
                            "value": "5",
                            "label_false": "5",
                            "label_true": "5",
                            "g_css_font_text": true,
                            "g_css_background": true
                            },
                            "style": {
                            "bindings": [],
                            "left": 564,
                            "top": 262,
                            "width": "67.9861px",
                            "height": "74.9757px",
                            "color": "rgba(76,214,65,1)",
                            "font-size": "large",
                            "background-color": "rgba(185,212,39,1)",
                            "z-index": "6"
                            },
                            "widgetSet": "metro"
                            },
                            "w001633": {
                            "tpl": "tplMetroTileState",
                            "data": {
                            "bindings": [],
                            "hover": "true",
                            "g_common": true,
                            "transform": "true",
                            "bg_class_false": "bg-orange",
                            "bg_class_true": "bg-orange",
                            "icon_class_false": "",
                            "g_icon": true,
                            "icon_class_true": "",
                            "state_oid": "javascript.1.visViewPinSperre._shelly.CurrentKey",
                            "value": "6",
                            "label_false": "6",
                            "label_true": "6",
                            "g_css_font_text": true,
                            "g_css_background": true
                            },
                            "style": {
                            "bindings": [],
                            "left": 633,
                            "top": 262,
                            "width": "67.9861px",
                            "height": "74.9757px",
                            "color": "rgba(76,214,65,1)",
                            "font-size": "large",
                            "background-color": "rgba(185,212,39,1)",
                            "z-index": "6"
                            },
                            "widgetSet": "metro"
                            },
                            "w001634": {
                            "tpl": "tplMetroTileState",
                            "data": {
                            "bindings": [],
                            "hover": "true",
                            "g_common": true,
                            "transform": "true",
                            "bg_class_false": "bg-orange",
                            "bg_class_true": "bg-orange",
                            "icon_class_false": "",
                            "g_icon": true,
                            "icon_class_true": "",
                            "state_oid": "javascript.1.visViewPinSperre._shelly.CurrentKey",
                            "value": "7",
                            "label_false": "7",
                            "label_true": "7",
                            "g_css_font_text": true,
                            "g_css_background": true
                            },
                            "style": {
                            "bindings": [],
                            "left": 493,
                            "top": 334,
                            "width": "67.9861px",
                            "height": "74.9757px",
                            "color": "rgba(76,214,65,1)",
                            "font-size": "large",
                            "background-color": "rgba(185,212,39,1)",
                            "z-index": "6"
                            },
                            "widgetSet": "metro"
                            },
                            "w001635": {
                            "tpl": "tplMetroTileState",
                            "data": {
                            "bindings": [],
                            "hover": "true",
                            "g_common": true,
                            "transform": "true",
                            "bg_class_false": "bg-orange",
                            "bg_class_true": "bg-orange",
                            "icon_class_false": "",
                            "g_icon": true,
                            "icon_class_true": "",
                            "state_oid": "javascript.1.visViewPinSperre._shelly.CurrentKey",
                            "value": "8",
                            "label_false": "8",
                            "label_true": "8",
                            "g_css_font_text": true,
                            "g_css_background": true
                            },
                            "style": {
                            "bindings": [],
                            "left": 564,
                            "top": 335,
                            "width": "67.9861px",
                            "height": "74.9757px",
                            "color": "rgba(76,214,65,1)",
                            "font-size": "large",
                            "background-color": "rgba(185,212,39,1)",
                            "z-index": "6"
                            },
                            "widgetSet": "metro"
                            },
                            "w001636": {
                            "tpl": "tplMetroTileState",
                            "data": {
                            "bindings": [],
                            "hover": "true",
                            "g_common": true,
                            "transform": "true",
                            "bg_class_false": "bg-orange",
                            "bg_class_true": "bg-orange",
                            "icon_class_false": "",
                            "g_icon": true,
                            "icon_class_true": "",
                            "state_oid": "javascript.1.visViewPinSperre._shelly.CurrentKey",
                            "value": "9",
                            "label_false": "9",
                            "label_true": "9",
                            "g_css_font_text": true,
                            "g_css_background": true
                            },
                            "style": {
                            "bindings": [],
                            "left": 633,
                            "top": 335,
                            "width": "67.9861px",
                            "height": "74.9757px",
                            "color": "rgba(76,214,65,1)",
                            "font-size": "large",
                            "background-color": "rgba(185,212,39,1)",
                            "z-index": "6"
                            },
                            "widgetSet": "metro"
                            },
                            "w001637": {
                            "tpl": "tplMetroTileState",
                            "data": {
                            "bindings": [],
                            "hover": "true",
                            "g_common": true,
                            "transform": "true",
                            "bg_class_false": "bg-orange",
                            "bg_class_true": "bg-orange",
                            "icon_class_false": "",
                            "g_icon": true,
                            "icon_class_true": "",
                            "state_oid": "javascript.1.visViewPinSperre._shelly.CurrentKey",
                            "value": "Reset",
                            "label_false": "Reset",
                            "label_true": "Reset",
                            "name": null,
                            "comment": null,
                            "class": "keypad",
                            "filterkey": null,
                            "multi-views": null,
                            "locked": null,
                            "g_fixed": true,
                            "select_on_value": false,
                            "g_css_font_text": true,
                            "g_css_background": true
                            },
                            "style": {
                            "bindings": [],
                            "left": 493,
                            "top": 411,
                            "width": "67.9861px",
                            "height": "74.9757px",
                            "color": "rgba(76,214,65,1)",
                            "font-size": "large",
                            "background-color": "rgba(185,212,39,1)",
                            "z-index": "6"
                            },
                            "widgetSet": "metro"
                            },
                            "w001638": {
                            "tpl": "tplHtml",
                            "data": {
                            "g_fixed": true,
                            "g_visibility": false,
                            "g_css_font_text": true,
                            "g_css_background": false,
                            "g_css_shadow_padding": false,
                            "g_css_border": false,
                            "g_gestures": false,
                            "g_signals": false,
                            "g_last_change": false,
                            "visibility-cond": "==",
                            "visibility-val": 1,
                            "visibility-groups-action": "hide",
                            "refreshInterval": 100,
                            "signals-cond-0": "==",
                            "signals-val-0": true,
                            "signals-icon-0": "/vis/signals/lowbattery.png",
                            "signals-icon-size-0": 0,
                            "signals-blink-0": false,
                            "signals-horz-0": 0,
                            "signals-vert-0": 0,
                            "signals-hide-edit-0": false,
                            "signals-cond-1": "==",
                            "signals-val-1": true,
                            "signals-icon-1": "/vis/signals/lowbattery.png",
                            "signals-icon-size-1": 0,
                            "signals-blink-1": false,
                            "signals-horz-1": 0,
                            "signals-vert-1": 0,
                            "signals-hide-edit-1": false,
                            "signals-cond-2": "==",
                            "signals-val-2": true,
                            "signals-icon-2": "/vis/signals/lowbattery.png",
                            "signals-icon-size-2": 0,
                            "signals-blink-2": false,
                            "signals-horz-2": 0,
                            "signals-vert-2": 0,
                            "signals-hide-edit-2": false,
                            "lc-type": "last-change",
                            "lc-is-interval": true,
                            "lc-is-moment": false,
                            "lc-format": "",
                            "lc-position-vert": "top",
                            "lc-position-horz": "right",
                            "lc-offset-vert": 0,
                            "lc-offset-horz": 0,
                            "lc-font-size": "12px",
                            "lc-font-family": "",
                            "lc-font-style": "",
                            "lc-bkg-color": "",
                            "lc-color": "",
                            "lc-border-width": "0",
                            "lc-border-style": "",
                            "lc-border-color": "",
                            "lc-border-radius": 10,
                            "lc-zindex": 0,
                            "html": "Bitte PIN eingeben",
                            "class": "glow-text",
                            "bindings": []
                            },
                            "style": {
                            "left": 423,
                            "top": 523,
                            "z-index": "4",
                            "text-align": "center",
                            "width": "341.988953px",
                            "height": "27.992645px",
                            "font-size": "large",
                            "bindings": []
                            },
                            "widgetSet": "basic"
                            }
                            },
                            "name": "z-content",
                            "activeWidgets": [],
                            "filterList": []
                            }

                            Skript zum importieren und anpassen:


                            /*******************************************************************************


                            • Pin-Schutz für VIS-View

                            • Autor: Mic
                            • Change Log
                              • 0.2 - Fix: 0 on keypad was not recognized
                              • 0.1 - initial version
                            • Support: https://forum.iobroker.net/viewtopic.php?f=30&t=19871
                              ******************************************************************************/

                            /*******************************************************************************

                            • Konfiguration
                              ******************************************************************************/
                              const STATE_PATH = 'javascript.' + instance + '.' + 'visViewPinSperre.';

                            const LOGGING = true; // Detaillierte Ausgabe im Log. Falls keine Probleme, dann auf false setzen.

                            /*******************************************************************************

                            • Konfiguration: Views
                              ******************************************************************************/
                              // Es können beliebig mehr Views hinzugefügt oder auf eine limitiert werden, bitte aber Aufbau beibehalten!
                              const PIN_VIEWS = [
                              {
                              name: '_shelly', // Name der View, zu der bei Erfolg gewechselt werden soll
                              project: 'VIS2-Tablet-Blue', // VIS-Projekt, in dem die View ist, für den Viewwechsel bei Erfolg. Wert bekommt man u.a.: Vis -> Menü: Setup > Projekte (den Namen des jeweilgen Projektes nehmen)
                              instance: 'e8.bdb03', // Funktioniert bei mir (und einigen anderen) immer mit 'FFFFFFFF', ansonsten Wert vom Vis, Menü Tools, Feld "Instanz ID" nehmen
                              pin: '2310', // Pin
                              },
                              {
                              name: 'Test',
                              project: 'Testprojekt',
                              instance: 'FFFFFFFF',
                              pin: '5678',
                              },
                              ];

                            /**********************************************************************************************************
                            ++++++++++++++++++++++++++++ Ab hier nichts mehr ändern / Stop editing here! ++++++++++++++++++++++++++++
                            *********************************************************************************************************/

                            /*******************************************************************************

                            • Globale Variablen
                              ******************************************************************************/
                              // Array, pro View ein Element
                              var G_LastKeyPressed = []; // Letzte Taste, die gedrückt wurde
                              var G_PinBufferKeys = []; // Puffer für eingegebene Ziffern
                              var G_PinBufferWildcards = []; // Für Vis-Anzeigefeld der Pineingabe, füllt sich mit "
                              " nach jeder Zifferneingabe

                            /*******************************************************************************

                            • Executed on every script start.
                              *******************************************************************************/
                              init();
                              function init() {

                              // Create states
                              createScriptStates();

                              // 1. Initialize global variables
                              // 2. Reset for each view
                              setTimeout(function(){
                              for (let i = 0; i < PIN_VIEWS.length; i++) {
                              // Initialize global variables
                              G_LastKeyPressed[PIN_VIEWS[i].name] = '';
                              G_PinBufferKeys[PIN_VIEWS[i].name] = '';
                              G_PinBufferWildcards[PIN_VIEWS[i].name] = '';
                              // Reset für jede View durchführen
                              resetPin(PIN_VIEWS[i].name)
                              }
                              }, 3000);

                              // Main Script starten, 5 Sekunden nach State-Generierung
                              setTimeout(main, 5000);

                            }

                            /*******************************************************************************

                            • Haupt-Skript
                              *******************************************************************************/
                              function main() {

                              // Überwacht das Tastenfeld in VIS für jede View
                              for (var i = 0; i < PIN_VIEWS.length; i++) {
                              on({id: STATE_PATH + PIN_VIEWS[i].name + '.CurrentKey', change: "any"}, function (obj) {
                              var currView = obj.id.substr(STATE_PATH.length).split(".")[0]; // get View Name simply from obj.id
                              if(LOGGING) if(obj.state.val !== '') log('Eingabe über Tastenfeld: ' + obj.state.val + ', Viewname: ' + currView);
                              switch(obj.state.val) {
                              case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9:
                              G_LastKeyPressed[currView] = obj.state.val;
                              userEnteredNumber(currView);
                              break;
                              case 'Enter': // Der User hat die Pin-Eingabe bestätigt.
                              checkEnteredPin(currView);
                              break;
                              case 'Reset':
                              resetPin(currView);
                              break;
                              default:
                              //None
                              }
                              });
                              }

                            }

                            /********************************

                            • Create States
                              ********************************/
                              function createScriptStates() {
                              for (let i = 0; i < PIN_VIEWS.length; i++) {
                              createState(STATE_PATH + PIN_VIEWS[i].name + '.CurrentKey', {'name':'Mit Tasten aus VIS setzen', 'type':'string', 'read':true, 'write':false, 'role':'info', 'def':'' });
                              createState(STATE_PATH + PIN_VIEWS[i].name + '.WrongPinEntered', {'name':'Pin-Fehler', 'type':'boolean', 'read':true, 'write':false, 'role':'info'});
                              createState(STATE_PATH + PIN_VIEWS[i].name + '.PinWildcards', {'name':'Sterne (*) für VIS-Anzeige', 'type':'string', 'read':true, 'write':false, 'role':'info', 'def':'' });
                              }
                              }

                            /********************************

                            • Wird ausgeführt, sobald der User eine Nummer im Tastenfeld eingibt.
                            • @param {string} viewName Name der View
                              *********************************/
                              function userEnteredNumber(viewName) {
                              G_PinBufferKeys[viewName] = G_PinBufferKeys[viewName] + G_LastKeyPressed[viewName];
                              G_PinBufferWildcards[viewName] = G_PinBufferWildcards[viewName] + ' *';
                              setState(STATE_PATH + viewName + '.PinWildcards', G_PinBufferWildcards[viewName]);
                              }

                            /********************************

                            • Wird ausgeführt, sobald der User E für "Enter" eingibt
                            • @param {string} viewName Name der View
                              ********************************/
                              function checkEnteredPin(viewName) {
                              if (G_PinBufferKeys[viewName] == getPresetElement(viewName, 'pin')) {
                              if(LOGGING) log('Pin-Eingabe erfolgreich, View [' + viewName + ']');
                              onSuccess(viewName);
                              setTimeout(function() { resetPin(viewName) }, 3000); // Reset nach 3 Sekunden
                              } else {
                              if(LOGGING) log('Falschen Pin eingegeben, View [' + viewName + ']');
                              setState(STATE_PATH + viewName + '.WrongPinEntered', true);
                              resetPin(viewName);
                              }
                              }

                            /********************************

                            • Reset
                            • @param {string} viewName Name der View
                              ********************************/
                              function resetPin(viewName) {
                              if(LOGGING) log('Reset Pin, View-Name: [' + viewName + ']');
                              G_PinBufferWildcards[viewName] = '';
                              G_PinBufferKeys[viewName] = '';
                              setState(STATE_PATH + viewName + '.CurrentKey', '');
                              setState(STATE_PATH + viewName + '.PinWildcards', '');
                              setStateDelayed(STATE_PATH + viewName + '.WrongPinEntered', false, 3000); // Erst nach 3 Sekunden, für VIS-Anzeige
                              }

                            /********************************

                            • Wird bei erfolgreicher Pin-Eingabe ausgeführt
                            • @param {string} viewName Name der View
                              ********************************/
                              function onSuccess(viewName){
                              // Change View
                              setState("vis-2.0.control.instance", getPresetElement(viewName, 'instance'));
                              setState("vis-2.0.control.data", getPresetElement(viewName, 'project') + '/' + viewName);
                              setState("vis-2.0.control.command", 'changeView');
                              }

                            /********************************

                            • Gibt Elemente von PIN_VIEWS zurück
                            • @param {string} viewName Name of the view
                            • @param {string} key 'project', 'instance', 'pin'
                            • @return {string} Content of the element, e.g. the Pin "1234" for element 'pin'
                              ********************************/
                              function getPresetElement(viewName, key) {
                              var keyEntry = '';
                              for (let i = 0; i < PIN_VIEWS.length; i++) {
                              if (PIN_VIEWS[i].name === viewName) {
                              keyEntry = PIN_VIEWS[i][key]
                              }
                              }
                              return keyEntry;
                              }
                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post

                            Support us

                            ioBroker
                            Community Adapters
                            Donate

                            518
                            Online

                            31.8k
                            Users

                            79.9k
                            Topics

                            1.3m
                            Posts

                            template vis
                            36
                            96
                            15254
                            Loading More Posts
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes
                            Reply
                            • Reply as topic
                            Log in to reply
                            Community
                            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                            The ioBroker Community 2014-2023
                            logo