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:
Spoiler
{
"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:
Spoiler
/*******************************************************************************
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;
}