uid: absorb-it:blockly:nspanel_callback tags: [] props: parameters: [] parameterGroups: [] timestamp: Nov 30, 2023, 8:47:32 PM component: BlockLibrary config: name: NSPanel Callback slots: blocks: - component: BlockType config: args0: - type: input_dummy align: CENTER - check: oh_item name: TARGET required: true type: input_value - check: Number name: ACTIVE_BRIGHTNESS type: input_value - check: Colour name: BACKGROUND_COLOR type: input_value - type: input_dummy args1: - type: input_dummy align: CENTER - check: Number name: TIMEOUT type: input_value - check: Number name: SCREENSAVER_BRIGHTNESS type: input_value - name: SCREENSAVER2 type: field_checkbox - type: input_dummy - type: input_dummy - check: String name: SCREENSAVER_SCRIPT_ID type: input_value - type: input_dummy args2: - align: CENTER type: input_dummy - check: String name: STARTUP_SCRIPT_ID type: input_value - type: input_dummy - name: STARTUP_ACTION type: input_statement - name: SCRIPT_LANDINGPAGE type: field_checkbox - type: input_dummy - type: input_dummy colour: 90 helpUrl: https://github.com/absorb-it/openhab-blockly-nspanel/blob/main/docs/blockLibrary_nspanel_callback_callback.md message0: > NSPANEL CALLBACK %1 Display on %2 Initial Display Brightness (0 - 100) %3 Background Color %4 %5 message1: > INITIAL SCREENSAVER SETTINGS %1 Timeout (0 = disabled) %2 Brightness (0 - 100) %3 Use Complex Screensaver %4 %5 Call Script after Screensaver shown %6 (i.e. for WeatherUpdate, enter Id) %7 %8 message2: > STARTUP %1 Show Page / Call Script (enter Id) %2 %5 use LandingPage Mode %6 %7 Run Startup Statement %3 %4 nextStatement: "" previousStatement: "" tooltip: "Registers and maintains all external and internal requests to some NSPanel Item. Stores basic setings and forwards information like the NSPanel Item as context to called scripts. Some settings like screensaver brightness and timing are only used during startup and can only be modified trough other helpers." type: absorb_it_nspanel_callback slots: code: - component: BlockCodeTemplate config: template: >- {{utility:absorb_it_nspanel_callback}}({{input:TARGET}}, {{input:TIMEOUT}}, {{input:SCREENSAVER_BRIGHTNESS}}, {{input:ACTIVE_BRIGHTNESS}}, {{input:BACKGROUND_COLOR}}, "FALSE", '{{field:SCREENSAVER2}}', {{input:SCREENSAVER_SCRIPT_ID}}, [ {{input:STARTUP_SCRIPT_ID}}, {{input:STARTUP_SCRIPT_ID}}, {{input:STARTUP_SCRIPT_ID}}, {{input:STARTUP_SCRIPT_ID}}, {{input:STARTUP_SCRIPT_ID}}, {{input:STARTUP_SCRIPT_ID}} ], [ '{{field:SCRIPT_LANDINGPAGE}}', '{{field:SCRIPT_LANDINGPAGE}}', '{{field:SCRIPT_LANDINGPAGE}}', '{{field:SCRIPT_LANDINGPAGE}}', '{{field:SCRIPT_LANDINGPAGE}}' ], `{{statements:STARTUP_ACTION}}`, 0); toolbox: - component: PresetInput config: fields: COLOUR: "#000000" name: BACKGROUND_COLOR shadow: true type: colour_picker - component: PresetInput config: name: TARGET shadow: true type: oh_item - component: PresetInput config: fields: NUM: 20 name: TIMEOUT required: false shadow: true type: math_number - component: PresetInput config: fields: NUM: 50 name: SCREENSAVER_BRIGHTNESS required: false shadow: true type: math_number - component: PresetInput config: fields: NUM: 100 name: ACTIVE_BRIGHTNESS required: false shadow: true type: math_number - component: PresetInput config: fields: TEXT: Weather/IconUpdate Script Id name: SCREENSAVER_SCRIPT_ID required: false shadow: true type: text - component: PresetInput config: fields: TEXT: Script Id name: STARTUP_SCRIPT_ID required: false shadow: true type: text - component: BlockType config: args0: - type: input_dummy align: CENTER - check: oh_item name: TARGET required: true type: input_value - check: Number name: ACTIVE_BRIGHTNESS type: input_value - check: Colour name: BACKGROUND_COLOR type: input_value - name: EXPERIMENTAL_SLIDERS type: field_checkbox - type: input_dummy - type: input_dummy args1: - type: input_dummy align: CENTER - check: Number name: TIMEOUT type: input_value - check: Number name: SCREENSAVER_BRIGHTNESS type: input_value - name: SCREENSAVER2 type: field_checkbox - type: input_dummy - type: input_dummy - check: String name: SCREENSAVER_SCRIPT_ID type: input_value - type: input_dummy args2: - align: CENTER type: input_dummy - check: String name: STARTUP_SCRIPT_ID type: input_value - name: STARTUP_ACTION type: input_statement - type: input_dummy args3: - align: CENTER type: input_dummy - align: CENTER type: input_dummy - name: TOUCH_LANDINGPAGE type: field_checkbox - align: RIGHT check: String name: TOUCH_SCRIPT_ID type: input_value - name: SWIPE_LEFT_LANDINGPAGE type: field_checkbox - align: RIGHT check: String name: SWIPE_LEFT_SCRIPT_ID type: input_value - name: SWIPE_RIGHT_LANDINGPAGE type: field_checkbox - align: RIGHT check: String name: SWIPE_RIGHT_SCRIPT_ID type: input_value - name: SWIPE_UP_LANDINGPAGE type: field_checkbox - align: RIGHT check: String name: SWIPE_UP_SCRIPT_ID type: input_value - name: SWIPE_DOWN_LANDINGPAGE type: field_checkbox - align: RIGHT check: String name: SWIPE_DOWN_SCRIPT_ID type: input_value - check: Number name: LANDINGPAGETIME type: input_value - type: input_dummy colour: 90 helpUrl: https://github.com/absorb-it/openhab-blockly-nspanel/blob/main/docs/blockLibrary_nspanel_callback_callback_complex.md message0: > NSPANEL COMPLEX CALLBACK %1 Display on %2 Initial Display Brightness (0 - 100) %3 Background Color %4 Use Experimental Sliders %5 %6 %7 message1: > INITIAL SCREENSAVER SETTINGS %1 Timeout (0 = disabled) %2 Brightness (0 - 100) %3 Use Complex Screensaver %4 %5 Call Script after Screensaver shown %6 (i.e. for WeatherUpdate, enter Id) %7 %8 message2: > STARTUP %1 Startup Script (enter Id) %2 Run Startup Statement %3 %4 message3: > ACTION %1 activate box for LandingPage Mode%2 Touch %3 Script (enter Id) %4 Swipe Left %5 Script (enter Id) %6 Swipe Right %7 Script (enter Id) %8 Swipe Up %9 Script (enter Id) %10 Swipe Down %11 Script (enter Id) %12 LandingPage Mode after Timeout (0 = disabled) %13 %14 nextStatement: "" previousStatement: "" tooltip: "Registers and maintains all external and internal requests to some NSPanel Item. Stores basic setings and forwards information like the NSPanel Item as context to called scripts. Some settings like screensaver brightness and timing are only used during startup and can only be modified trough other helpers." type: absorb_it_nspanel_complex_callback slots: code: - component: BlockCodeTemplate config: template: >- {{utility:absorb_it_nspanel_callback}}({{input:TARGET}}, {{input:TIMEOUT}}, {{input:SCREENSAVER_BRIGHTNESS}}, {{input:ACTIVE_BRIGHTNESS}}, {{input:BACKGROUND_COLOR}}, '{{field:EXPERIMENTAL_SLIDERS}}', '{{field:SCREENSAVER2}}', {{input:SCREENSAVER_SCRIPT_ID}}, [ {{input:STARTUP_SCRIPT_ID}}, {{input:TOUCH_SCRIPT_ID}}, {{input:SWIPE_LEFT_SCRIPT_ID}}, {{input:SWIPE_RIGHT_SCRIPT_ID}}, {{input:SWIPE_UP_SCRIPT_ID}}, {{input:SWIPE_DOWN_SCRIPT_ID}} ], [ '{{field:TOUCH_LANDINGPAGE}}', '{{field:SWIPE_LEFT_LANDINGPAGE}}', '{{field:SWIPE_RIGHT_LANDINGPAGE}}', '{{field:SWIPE_UP_LANDINGPAGE}}', '{{field:SWIPE_DOWN_LANDINGPAGE}}' ], `{{statements:STARTUP_ACTION}}`, {{input:LANDINGPAGETIME}}); toolbox: - component: PresetInput config: fields: COLOUR: "#000000" name: BACKGROUND_COLOR shadow: true type: colour_picker - component: PresetInput config: name: TARGET shadow: true type: oh_item - component: PresetInput config: fields: NUM: 20 name: TIMEOUT required: false shadow: true type: math_number - component: PresetInput config: fields: NUM: 50 name: SCREENSAVER_BRIGHTNESS required: false shadow: true type: math_number - component: PresetInput config: fields: NUM: 100 name: ACTIVE_BRIGHTNESS required: false shadow: true type: math_number - component: PresetInput config: fields: TEXT: Weather/IconUpdate Script Id name: SCREENSAVER_SCRIPT_ID required: false shadow: true type: text - component: PresetInput config: fields: TEXT: Script Id name: STARTUP_SCRIPT_ID required: false shadow: true type: text - component: PresetInput config: fields: TEXT: Script Id name: TOUCH_SCRIPT_ID required: false shadow: true type: text - component: PresetInput config: fields: TEXT: Script Id name: SWIPE_LEFT_SCRIPT_ID required: false shadow: true type: text - component: PresetInput config: fields: TEXT: Script Id name: SWIPE_RIGHT_SCRIPT_ID required: false shadow: true type: text - component: PresetInput config: fields: TEXT: Script Id name: SWIPE_UP_SCRIPT_ID required: false shadow: true type: text - component: PresetInput config: fields: TEXT: Script Id name: SWIPE_DOWN_SCRIPT_ID required: false shadow: true type: text - component: PresetInput config: fields: NUM: 60 name: LANDINGPAGETIME required: false shadow: true type: math_number - component: BlockType config: args0: - name: TARGET required: true type: input_value check: oh_item args1: - name: TIME_FORMAT type: input_value check: String - name: DATE_FORMAT type: input_value check: String - name: TIME_ADD_STRING type: input_value check: String colour: 90 helpUrl: "https://github.com/absorb-it/openhab-blockly-nspanel/blob/main/docs/blockLibrary_nspanel_callback_timeUpdate.md" message0: > NSPANEL TIME UPDATE for %1 message1: > Time Format %1 Date Format %2 Additional Time Text %3 nextStatement: "" previousStatement: "" tooltip: "This updates the time on some NSPanel - there is no local clock in these devices." type: absorb_it_nspanel_timeUpdate inputsInline: false slots: code: - component: BlockCodeTemplate config: template: >- {{utility:absorb_it_nspanel_timeUpdate}}({{input:TARGET}}, {{input:TIME_FORMAT}}, {{input:DATE_FORMAT}} , {{input:TIME_ADD_STRING}}); toolbox: - component: PresetInput config: name: TARGET shadow: true type: oh_item - component: PresetInput config: fields: TEXT: HH:mm name: TIME_FORMAT required: false shadow: true type: text - component: PresetInput config: fields: TEXT: dd-MM-yyyy name: DATE_FORMAT required: false shadow: true type: text - component: PresetInput config: fields: TEXT: "" name: TIME_ADD_STRING required: false shadow: true type: text utilities: - component: UtilityFunction config: code: >- function {{name}}() { return 'absorb_it_nspanel_refreshTimer_' + ctx.ruleUID; } name: getTimerName - component: UtilityFunction config: code: >- function {{name}}() { if (cache.shared.exists({{getTimerName}}())) { console.debug("remove existing refresh timer " + {{getTimerName}}()); cache.shared.remove({{getTimerName}}()).cancel(); } } name: absorb_it_nspanel_callback_killRefreshTimer - component: UtilityFunction config: code: >- function {{name}}(scriptName, context, updateCacheLink) { if (!scriptName || scriptName === "Script Id") return 0; try { const RuleManager = osgi.getService('org.openhab.core.automation.RuleManager'); var thread = Java.type('java.lang.Thread'); let timer = 10; while (RuleManager.getStatus(scriptName) && RuleManager.getStatus(scriptName).toString() === "RUNNING") { if (!timer--) { console.debug("finished waiting for rule " + scriptName); break; } console.debug("waiting 1 sec. for running rule " + scriptName); thread.sleep(1000); } } catch (e) { } context["timerName"] = {{getTimerName}}(); try { console.debug("start rule with id '" + scriptName + "' and context:" + JSON.stringify(context)); rules.runRule(scriptName, context); cache.private.put('anyCurrentPage', scriptName); // any last page if (updateCacheLink) { cache.private.put('previousCard', cache.private.get('currentCard')); console.debug("updated previousCard to " + cache.private.get('previousCard')); cache.private.put('currentCard', scriptName); // only some last pages (excluding popupNotify, Screensaver) } return 1; } catch (e) { console.error("Error", e.stack); console.debug("Error", e.toString()); console.debug("can't start/find rule with id '" + scriptName + "'"); } return 0; } name: absorb_it_nspanel_callback_startScript - component: UtilityFunction config: code: >- function {{name}}(command, returnValue = '') { // evaluate command, use returnValue as context let result = ""; if (command) { try { result = eval(command); } catch (e) { console.error("Error", e.stack); console.debug("Error", e.toString()); console.debug("eval failed: '" + command + "'"); } } return result; } name: absorb_it_nspanel_callback_safeEval - component: UtilityFunction config: code: >- function {{name}}(param, noOfItems) { let result = String(param); if (result.charAt(0) != '~') result = '~' + result; while ((result.match(/~/g) || []).length < noOfItems) result += '~' while ((result.match(/~/g) || []).length > noOfItems) result = result.replace(/~/, ''); return result; } name: absorb_it_nspanel_callback_checkParam - component: UtilityFunction config: code: >- function {{name}}(eventName) { // check if LandingPage should be re-enabled if ( (!cache.private.exists('DetailPage')) && ( // we are not on any DetailPage (cache.private.get(eventName + "LandingPage") == "TRUE") || // LandingPage mode is set to true or (cache.private.get('anyCurrentPage') == 'screensaver' && cache.private.get('landingPageTime') && Date.now() - cache.private.get('screensaverTime') > cache.private.get('landingPageTime')*1000))) { // we are on Screensaver and last Page Data is too old console.debug("removing currentCard '" + cache.private.get('currentCard') + "' DetailPage=" + cache.private.get('DetailPage')); cache.private.remove('currentCard'); // remove last know card (start again with LandingPage) cache.private.remove('previousCard'); // remove previous card as well } } name: absorb_it_nspanel_callback_reenableLandingPage - component: UtilityFunction config: code: >- function {{name}}(target, timeout, screenSaverBrightness, activeBrightness, backgroundColor, experimentalSliders, screensaver2, screensaverStartupScript, actionScripts, scriptLandingPage, startupAction, landingPageTime) { console.debug("entering callback '" + (event.receivedState ?? event.itemState) + "' currentCard:" + cache.private.get('currentCard')+ " anyCurrentPage:" + cache.private.get('anyCurrentPage') + " previousCard:" + cache.private.get('previousCard')); switch (utils.OPENHAB_JS_VERSION) { case "5.13.0": console.error("NSPanel Lovelace UI Callback is not compatible with your JavaScript Scripting version (openhab-js v" + utils.OPENHAB_JS_VERSION + ")"); console.error("please upgrade openHAB or your JavaScript Scripting (openhab-js) addon"); return; default: console.debug("running absorb_it_nspanel_callback with openhab-js " + utils.OPENHAB_JS_VERSION); } // on first run only... if (!cache.private.exists('initialized')) { // allow refreshing of dimming and timeout when saving configured callback items.getItem(target).sendCommand( "timeout" + {{absorb_it_nspanel_callback_checkParam}}(timeout, 1) ); items.getItem(target).sendCommand( "dimmode" + {{absorb_it_nspanel_callback_checkParam}}(screenSaverBrightness, 1) + {{absorb_it_nspanel_callback_checkParam}}(activeBrightness, 1) + {{absorb_it_nspanel_callback_checkParam}}(backgroundColor, 1) + ((experimentalSliders == "TRUE")?'~~1':'~~0') ); // store settings from blockly interface to be able to change them on-the-fly cache.private.put('complexScreenSaver', screensaver2); cache.private.put('screensaverScriptName', screensaverStartupScript); cache.private.put('startupScriptName', actionScripts[0]); cache.private.put('touchScriptName', actionScripts[1]); cache.private.put('swipeLeftScriptName', actionScripts[2]); cache.private.put('swipeRightScriptName', actionScripts[3]); cache.private.put('swipeUpScriptName', actionScripts[4]); cache.private.put('swipeDownScriptName', actionScripts[5]); cache.private.put('touchLandingPage', scriptLandingPage[0]); cache.private.put('swipeLeftLandingPage', scriptLandingPage[1]); cache.private.put('swipeRightLandingPage', scriptLandingPage[2]); cache.private.put('swipeUpLandingPage', scriptLandingPage[3]); cache.private.put('swipeDownLandingPage', scriptLandingPage[4]); cache.private.put('landingPageTime', landingPageTime); // done cache.private.put('initialized', 1); }; var contextValues; var itemState = event.receivedState ?? event.itemState; try { contextValues = (JSON.parse(itemState))["CustomRecv"].split(','); } catch { if (itemState) { // if callback received non-JSON string check for local requests let callbackParam = itemState.toString().split('?'); switch (callbackParam[0]) { case "refresh": case "ON": // triggered by Hardware Button press (if rule configured to fire) case "OFF": // triggered by Hardware Button press (if rule configured to fire) if (cache.private.get('currentCard') && (cache.private.get('anyCurrentPage') !== "screensaver")) { let context = { "previousPage": cache.private.get('anyCurrentPage'), "target": target }; if (cache.private.exists('DetailPage')) { context["request"] = "pageOpenDetail"; context["item"] = cache.private.get('DetailPage'); }; console.debug("absorb_it_nspanel_callback_startScript refresh/ON/OFF"); {{absorb_it_nspanel_callback_startScript}}( cache.private.get('currentCard'), context, 0 ); } return; case "refreshTimer": if (cache.private.get('currentCard') && (cache.private.get('anyCurrentPage') !== "screensaver")) { console.debug("absorb_it_nspanel_callback_startScript refreshTimer"); {{absorb_it_nspanel_callback_startScript}}( cache.private.get('currentCard'), { "previousPage": cache.private.get('anyCurrentPage'), "target": target }, 0 ); } return; case "loadPage": if (callbackParam[1]) contextValues = [ , "buttonPress2", callbackParam[1] ]; break; case "loadScreensaver": contextValues = [ , "sleepReached" ]; break; case "newTimeout": if (callbackParam[1]) items.getItem(target).sendCommand( "timeout" + {{absorb_it_nspanel_callback_checkParam}}(callbackParam[1], 1) ); return; case "newLandingPageTime": cache.private.put('landingPageTime', callbackParam[1]); return; case "newBrightness": case "newBrigthness": // keep old value, type of parameter was fixed in 0.6 if (callbackParam[1] && callbackParam[2]) items.getItem(target).sendCommand( "dimmode" + {{absorb_it_nspanel_callback_checkParam}}(callbackParam[1], 1) + {{absorb_it_nspanel_callback_checkParam}}(callbackParam[2], 1) + {{absorb_it_nspanel_callback_checkParam}}(backgroundColor, 1) + ((experimentalSliders == "TRUE")?'~~1':'~~0') ); return; case "complexScreenSaver": cache.private.put('complexScreenSaver', callbackParam[1]); return; case "touchScriptName": case "swipeLeftScriptName": case "swipeRightScriptName": case "swipeUpScriptName": case "swipeDownScriptName": if (callbackParam[2]) { let eventName = callbackParam[0].substring(0, callbackParam[0].search("ScriptName")); cache.private.put(eventName + 'LandingPage', callbackParam[2]); } case "screensaverScriptName": case "startupScriptName": cache.private.put(callbackParam[0], callbackParam[1]); return; default: return; } } } switch(contextValues[1]) { case "startup": cache.private.put('screensaverActive', "FALSE"); items.getItem(target).sendCommand( "timeout" + {{absorb_it_nspanel_callback_checkParam}}(timeout, 1) ); items.getItem(target).sendCommand( "dimmode" + {{absorb_it_nspanel_callback_checkParam}}(screenSaverBrightness, 1) + {{absorb_it_nspanel_callback_checkParam}}(activeBrightness, 1) + {{absorb_it_nspanel_callback_checkParam}}(backgroundColor, 1) + ((experimentalSliders == "TRUE")?'~~1':'~~0') ); console.debug("absorb_it_nspanel_callback_startScript startup"); let success = {{absorb_it_nspanel_callback_startScript}}( cache.private.get('startupScriptName'), { "target": target }, 1 ); cache.private.remove('currentCard'); cache.private.remove('previousCard'); {{absorb_it_nspanel_callback_safeEval}}(startupAction); if (success || startupAction != '') break; case "buttonPress2": // disable screensaver if (cache.private.get('screensaverActive') == "TRUE") { cache.private.put('screensaverActive', "FALSE"); } let eventName = (contextValues[3] === "bExit")?"touch":contextValues[3]; if (!(contextValues[3] == "bExit" && contextValues[2] == "popupNotify")) { switch(contextValues[3]) { case "bExit": case "touch": case "swipeLeft": case "swipeRight": case "swipeUp": case "swipeDown": let eventName = (contextValues[3] === "bExit")?"touch":contextValues[3]; {{absorb_it_nspanel_callback_reenableLandingPage}}(eventName); cache.private.remove('DetailPage'); // if Detail was shown, close it and go back to main page if (cache.private.get('currentCard')) { console.debug("screensaver: " + eventName + " -> " + cache.private.get('currentCard')); console.debug("absorb_it_nspanel_callback_startScript bExit/touch/swipe previous card available"); {{absorb_it_nspanel_callback_startScript}}( cache.private.get('currentCard'), { "target": target }, 0 ); } else { let targetScript = cache.private.get(eventName + "ScriptName"); console.debug("screensaver: " + eventName + " -> " + targetScript); console.debug("absorb_it_nspanel_callback_startScript bExit/touch/swipe no previous card available"); {{absorb_it_nspanel_callback_startScript}}( targetScript, { "target": target }, 1 ); } break; default: if (contextValues[2].split('?')[0] !== cache.private.get('anyCurrentPage')) { // new page called, probably clicked on navigation buttons console.debug("absorb_it_nspanel_callback_startScript buttonPress2 for new Page"); {{absorb_it_nspanel_callback_startScript}}( contextValues[2].split('?')[0], { "target": target }, (contextValues[2] !== "popupNotify" && contextValues[3] !== "notifyAction") ); } else { // find the clicked item, if there hade been multiple on the page let item = ""; // alarmButtons: third context field contains 'cb' and item id, reparated by '?' // {"CustomRecv":"event,buttonPress2,*cardAlarmScriptName*,item?1,1"} if (contextValues[3] && contextValues[3].split('?')[0] === "item") item = contextValues[3].split('?')[1]; // HVACButtons: third context field contains script name and item id, reparated by '?' // {"CustomRecv":"event,buttonPress2,*cardThermoScriptName*,hvac_action,item?1"} if (contextValues[4] && contextValues[4].split('?')[0] === "item") item = contextValues[4].split('?')[1]; // entities: third context field contains both script name and item id, reparated by '?' // {"CustomRecv":"event,buttonPress2,*cardEntitiesScriptName*?2,OnOff,0"} else item = contextValues[2].split('?')[1]; console.debug("absorb_it_nspanel_callback_startScript buttonPress2 handover new parameter (trigger, newState)"); {{absorb_it_nspanel_callback_startScript}}( contextValues[2].split('?')[0], { "request": cache.private.exists('DetailPage')?"pageOpenDetail":"pageUpdate", "item": item, "trigger": contextValues[3], "newState": contextValues[4] || "", // newState must be a String "previousPage": cache.private.get('anyCurrentPage'), "target": target }, (contextValues[2] !== "popupNotify" && contextValues[3] !== "notifyAction") ); } } break; } else { // {"CustomRecv":"event,buttonPress2,popupNotify,bExit"} {{absorb_it_nspanel_callback_reenableLandingPage}}(eventName); // exit Notify, restore previous Card if available if (cache.private.get('previousCard')) { console.debug("absorb_it_nspanel_callback_startScript popupNotify exit"); {{absorb_it_nspanel_callback_startScript}}( cache.private.get('previousCard'), { "target": target }, 1 ); break; } // else show screensaver, no break - continue with switch/case } case "sleepReached": {{absorb_it_nspanel_callback_killRefreshTimer}}(); cache.private.put('screensaverActive', "TRUE"); if (cache.private.get('complexScreenSaver') == "TRUE") items.getItem(target).sendCommand("pageType~screensaver2"); else items.getItem(target).sendCommand("pageType~screensaver"); console.debug("absorb_it_nspanel_callback_startScript sleepReached"); {{absorb_it_nspanel_callback_startScript}}( cache.private.get('screensaverScriptName'), { "target": target }, 0 ); cache.private.put('anyCurrentPage', 'screensaver'); // therefore ignore timer updates during screensaver cache.private.put('screensaverTime', Date.now()); // remember time screensaver was activated break; case "pageOpenDetail": let item = contextValues[3].split('?')[1]; cache.private.put('DetailPage', item?item:0); console.debug("absorb_it_nspanel_callback_startScript pageOpenDetail"); {{absorb_it_nspanel_callback_startScript}}( contextValues[3].split('?')[0], { "request": "pageOpenDetail", "item": item, "trigger": contextValues[2], "target": target }, 1 ); break; default: } } name: absorb_it_nspanel_callback - component: UtilityFunction config: code: >- function {{name}}(target, patternTime = 'HH:mm', patternDate = 'dd-MM-yyyy', tTimeAdd = '') { let timeString = String((time.ZonedDateTime.now()).format(time.DateTimeFormatter.ofPattern(patternTime))); let dateString = String((time.ZonedDateTime.now()).format(time.DateTimeFormatter.ofPattern(patternDate))); items.getItem(target).sendCommand('time~' + timeString + '~' + tTimeAdd); items.getItem(target).sendCommand('date~' + dateString); } name: absorb_it_nspanel_timeUpdate