uid: absorb-it:blockly:nspanel_screensaver tags: [] props: parameters: [] parameterGroups: [] timestamp: Nov 30, 2023, 7:45:09 PM component: BlockLibrary config: name: NSPanel Screensaver slots: blocks: - component: BlockType config: args0: - align: CENTER type: input_dummy args1: - align: CENTER type: input_dummy - check: - nspanel_entityLabelString name: MAIN type: input_value - check: - nspanel_entityLabelString name: FORECAST_1 type: input_value - check: - nspanel_entityLabelString name: FORECAST_2 type: input_value - check: - nspanel_entityLabelString name: FORECAST_3 type: input_value - check: - nspanel_entityLabelString name: FORECAST_4 type: input_value - check: - nspanel_entityLabelString name: ALTERNATIVE type: input_value colour: 90 helpUrl: "https://github.com/absorb-it/openhab-blockly-nspanel/blob/main/docs/blockLibrary_nspanel_screensaver_updateStandard.md" inputsInline: false message0: UPDATE Standard Screensaver %1 message1: > choose Label Entities (see NSPanel Entities) %1 Weather MainIcon %2 1st Forecast %3 2nd Forecast %4 3rd Forecast %5 4th Forecast %6 2nd Weather MainIcon (4th Forecast ignored) %7 nextStatement: "" previousStatement: "" tooltip: "Configure Icons and Labels shown on your Screensaver. Best called by some rule, but be aware that some context information about the NSPanel Item is required." type: absorb_it_nspanel_weatherupdate slots: code: - component: BlockCodeTemplate config: template: >- {{utility:absorb_it_nspanel_weatherupdate}}([{{input:MAIN}}, {{input:FORECAST_1}}, {{input:FORECAST_2}}, {{input:FORECAST_3}}, {{input:FORECAST_4}}, {{input:ALTERNATIVE}}]); toolbox: - component: BlockType config: args0: - align: CENTER type: input_dummy args1: - align: CENTER type: input_dummy - check: - nspanel_entityLabelString name: MAIN type: input_value - type: input_dummy args2: - align: CENTER type: input_dummy - check: - nspanel_entityLabelString name: LEFT_1 type: input_value - check: - nspanel_entityLabelString name: LEFT_2 type: input_value - check: - nspanel_entityLabelString name: LEFT_3 type: input_value - type: input_dummy args3: - align: CENTER type: input_dummy - check: - nspanel_entityLabelString name: BOTTOM_1 type: input_value - check: - nspanel_entityLabelString name: BOTTOM_2 type: input_value - check: - nspanel_entityLabelString name: BOTTOM_3 type: input_value - check: - nspanel_entityLabelString name: BOTTOM_4 type: input_value - check: - nspanel_entityLabelString name: BOTTOM_5 type: input_value - check: - nspanel_entityLabelString name: BOTTOM_6 type: input_value - type: input_dummy args4: - align: CENTER type: input_dummy - check: - nspanel_entityLabelString name: INDICATOR_1 type: input_value - check: - nspanel_entityLabelString name: INDICATOR_2 type: input_value - check: - nspanel_entityLabelString name: INDICATOR_3 type: input_value - check: - nspanel_entityLabelString name: INDICATOR_4 type: input_value - check: - nspanel_entityLabelString name: INDICATOR_5 type: input_value colour: 90 helpUrl: "https://github.com/absorb-it/openhab-blockly-nspanel/blob/main/docs/blockLibrary_nspanel_screensaver_updateComplex.md" inputsInline: false message0: UPDATE Complex Screensaver %1 message1: choose Label Entities (see NSPanel Entities) %1 Main Entity %2 %3 message2: > left Entities %1 1st Entity %2 2nd Entity %3 3rd Entity %4 %5 message3: > bottom Entities %1 1st Entity %2 2nd Entity %3 3rd Entity %4 4th Entity %5 5th Entity %6 6th Entity %7 %8 message4: > Indicator Entities %1 1st Entity %2 2nd Entity %3 3rd Entity %4 4th Entity %5 5th Entity %6 nextStatement: "" previousStatement: "" tooltip: "Configure Icons and Labels shown on your complex Screensaver. Best called by some rule, but be aware that some context information about the NSPanel Item is required." type: absorb_it_nspanel_weatherupdate2 slots: code: - component: BlockCodeTemplate config: template: >- {{utility:absorb_it_nspanel_weatherupdate}}([{{input:MAIN}}, {{input:LEFT_1}}, {{input:LEFT_2}}, {{input:LEFT_3}}, {{input:BOTTOM_1}}, {{input:BOTTOM_2}}, {{input:BOTTOM_3}}, {{input:BOTTOM_4}}, {{input:BOTTOM_5}}, {{input:BOTTOM_6}}, {{input:INDICATOR_1}}, {{input:INDICATOR_2}}, {{input:INDICATOR_3}}, {{input:INDICATOR_4}}, {{input:INDICATOR_5}}]); toolbox: - component: BlockType config: args0: - align: CENTER type: input_dummy args1: - align: CENTER type: input_dummy - check: String name: HEADER type: input_value - check: String name: TEXT type: input_value colour: 90 helpUrl: "https://github.com/absorb-it/openhab-blockly-nspanel/blob/main/docs/blockLibrary_nspanel_screensaver_screensaverNotification.md" inputsInline: false message0: SCREENSAVER NOTIFICATION %1 message1: (use empty fields to cancel previous notification) %1 Header %2 Text %3 nextStatement: "" previousStatement: "" tooltip: "Show some Notification in the lower part of your Screensaver (if this is shown). Be aware that some context information about the NSPanel Item is required." type: absorb_it_nspanel_notify slots: code: - component: BlockCodeTemplate config: template: >- {{utility:absorb_it_nspanel_notify}}({{input:HEADER}}, {{input:TEXT}}); toolbox: - component: PresetInput config: fields: TEXT: Header name: HEADER required: false shadow: true type: text - component: PresetInput config: fields: TEXT: Text name: TEXT required: false shadow: true type: text - component: BlockType config: args0: - align: CENTER type: input_dummy args1: - name: LEFT_FONT options: - - Small - "0" - - Normal - "1" type: field_dropdown - name: LEFT_ICON type: input_value - name: LEFT_ICON_COLOR type: input_value - type: input_dummy - name: RIGHT_FONT options: - - Small - "0" - - Normal - "1" type: field_dropdown - name: RIGHT_ICON type: input_value - name: RIGHT_ICON_COLOR type: input_value colour: 90 helpUrl: "https://github.com/absorb-it/openhab-blockly-nspanel/blob/main/docs/blockLibrary_nspanel_screensaver_screensaverStatusIcons.md" inputsInline: false message0: SCREENSAVER STATUS Icons %1 message1: > Left Icon (Font Size %1) %2 Left Icon Color %3 %4 Right Icon (Font Size %5) %6 Right Icon Color %7 nextStatement: "" previousStatement: "" tooltip: "Update Status Icons of Screensaver. Standard Screensaver has these Icons on Top, complex Screensaver has these Icons on Bottom. Be aware that some context information about the NSPanel Item is required." type: absorb_it_nspanel_status slots: code: - component: BlockCodeTemplate config: template: >- {{utility:absorb_it_nspanel_status}}({{input:LEFT_ICON}}, {{input:LEFT_ICON_COLOR}}, '{{field:LEFT_ICON_FONT}}', {{input:RIGHT_ICON}}, {{input:RIGHT_ICON_COLOR}}, '{{field:RIGHT_ICON_FONT}}'); toolbox: - component: PresetInput config: fields: TEXT: "*" name: LEFT_ICON required: false shadow: true type: text - component: PresetInput config: fields: COLOUR: "#00ee00" name: LEFT_ICON_COLOR required: false shadow: true type: colour_picker - component: PresetField config: name: LEFT_FONT required: true shadow: false value: "0" - component: PresetInput config: fields: TEXT: "*" name: RIGHT_ICON required: false shadow: true type: text - component: PresetInput config: fields: COLOUR: "#00ee00" name: RIGHT_ICON_COLOR required: false shadow: true type: colour_picker - component: PresetField config: name: RIGHT_FONT required: true shadow: false value: "0" - component: BlockType config: args0: - align: CENTER type: input_dummy args1: - check: Colour name: COLOR_background type: input_value - check: Colour name: COLOR_tTime type: input_value - check: Colour name: COLOR_timeAMPM type: input_value - check: Colour name: COLOR_tDate type: input_value - check: Colour name: COLOR_tMainText type: input_value - check: Colour name: COLOR_tForecast1 type: input_value - check: Colour name: COLOR_tForecast2 type: input_value - check: Colour name: COLOR_tForecast3 type: input_value - check: Colour name: COLOR_tForecast4 type: input_value - check: Colour name: COLOR_tForecast1Val type: input_value - check: Colour name: COLOR_tForecast2Val type: input_value - check: Colour name: COLOR_tForecast3Val type: input_value - check: Colour name: COLOR_tForecast4Val type: input_value - check: Colour name: COLOR_bar type: input_value - check: Colour name: COLOR_tMainTextAlt2 type: input_value - check: Colour name: COLOR_tTimeAdd type: input_value - type: input_dummy - type: input_dummy - type: input_dummy colour: 90 helpUrl: "https://github.com/absorb-it/openhab-blockly-nspanel/blob/main/docs/blockLibrary_nspanel_screensaver_screensaverColors.md" inputsInline: false message0: SCREENSAVER COLORS %1 message1: > Background %1 Horizontal Bar %14 %19 Main Text %5 Main Text (alt2) %15 %18 Time %2 AM/PM %3 Date %4 Time (add) %16 %17 Forecast 1 %6 Forecast 1 (value) %10 Forecast 2 %7 Forecast 2 (value) %11 Forecast 3 %8 Forecast 3 (value) %12 Forecast 4 %9 Forecast 4 (value) %13 nextStatement: "" previousStatement: "" tooltip: "Configure all Colors of your Screensaver. Be aware that some context information about the NSPanel Item is required." type: absorb_it_nspanel_color slots: code: - component: BlockCodeTemplate config: template: >- {{utility:absorb_it_nspanel_color}}({{input:COLOR_background}}, {{input:COLOR_tTime}}, {{input:COLOR_timeAMPM}}, {{input:COLOR_tDate}}, {{input:COLOR_tMainText}}, {{input:COLOR_tForecast1}}, {{input:COLOR_tForecast2}}, {{input:COLOR_tForecast3}}, {{input:COLOR_tForecast4}}, {{input:COLOR_tForecast1Val}}, {{input:COLOR_tForecast2Val}}, {{input:COLOR_tForecast3Val}}, {{input:COLOR_tForecast4Val}}, {{input:COLOR_bar}}, {{input:COLOR_tMainTextAlt2}}, {{input:COLOR_tTimeAdd}}); toolbox: - component: PresetInput config: fields: COLOUR: "#000000" name: COLOR_background shadow: true type: colour_picker - component: PresetInput config: fields: COLOUR: "#eeeeee" name: COLOR_tTime shadow: true type: colour_picker - component: PresetInput config: fields: COLOUR: "#eeeeee" name: COLOR_timeAMPM shadow: true type: colour_picker - component: PresetInput config: fields: COLOUR: "#eeeeee" name: COLOR_tDate shadow: true type: colour_picker - component: PresetInput config: fields: COLOUR: "#ffffff" name: COLOR_tMainText shadow: true type: colour_picker - component: PresetInput config: fields: COLOUR: "#00dd00" name: COLOR_tForecast1 shadow: true type: colour_picker - component: PresetInput config: fields: COLOUR: "#00dd00" name: COLOR_tForecast2 shadow: true type: colour_picker - component: PresetInput config: fields: COLOUR: "#00dd00" name: COLOR_tForecast3 shadow: true type: colour_picker - component: PresetInput config: fields: COLOUR: "#00dd00" name: COLOR_tForecast4 shadow: true type: colour_picker - component: PresetInput config: fields: COLOUR: "#0000dd" name: COLOR_tForecast1Val shadow: true type: colour_picker - component: PresetInput config: fields: COLOUR: "#0000dd" name: COLOR_tForecast2Val shadow: true type: colour_picker - component: PresetInput config: fields: COLOUR: "#0000dd" name: COLOR_tForecast3Val shadow: true type: colour_picker - component: PresetInput config: fields: COLOUR: "#0000dd" name: COLOR_tForecast4Val shadow: true type: colour_picker - component: PresetInput config: fields: COLOUR: "#eeeeee" name: COLOR_bar shadow: true type: colour_picker - component: PresetInput config: fields: COLOUR: "#eeeeee" name: COLOR_tMainTextAlt2 shadow: true type: colour_picker - component: PresetInput config: fields: COLOUR: "#eeeeee" name: COLOR_tTimeAdd shadow: true type: colour_picker utilities: - component: UtilityFunction config: code: >- function {{name}}(command) { // evaluate command let result = ""; if (command) { try { result = eval(command); } catch (e) { console.error("Error", e.stack); console.log("Error", e.toString()); console.log("eval failed: '" + command + "'"); } } return result; } name: absorb_it_nspanel_ssaver_safeEval - component: UtilityFunction config: code: >- function {{name}}(color) { let result = (parseInt("0x"+color.substr(1, 2)) << 8) & 0xF800; result |= (parseInt("0x"+color.substr(3, 2)) << 3) & 0x07E0; result |= (parseInt("0x"+color.substr(5, 2)) >> 3) & 0x001F; return result; } name: absorb_it_nspanel_ssaver_getRGB565 - 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_ssaver_checkParam - component: UtilityFunction config: code: >- function {{name}}(functionName) { console.log("starting script '" + functionName + "' " + ctx); if (!ctx.target && !ctx.triggerLoadPageDone) { if (!ctx.triggerLoadPage) console.error("missing context for loading '" + functionName + "' in '" + ctx.ruleUID + "', try 'NSPanel Item' from Helpers library!"); else { console.warn("missing context for loading '" + functionName + "' in '" + ctx.ruleUID + "'. Context from 'NSPanel Item via CallBack' can't be used for standalone screensaver helpers. If used in combination with real (fullPage) cards, just ignore this message."); } return 0; } return 1; } name: absorb_it_nspanel_ssaver_startupCheck - component: UtilityFunction config: code: >- function {{name}}(entities) { if (!{{absorb_it_nspanel_ssaver_startupCheck}}(arguments.callee.name)) return; let mqtt = 'weatherUpdate'; for (let i = 0; i < entities.length; i++) { let result = entities[i]; if (result === undefined) { mqtt += {{absorb_it_nspanel_ssaver_checkParam}}("", 6); continue; } mqtt += {{absorb_it_nspanel_ssaver_checkParam}}(result.resultString, 6); } items.getItem(ctx.target).sendCommand(mqtt); } name: absorb_it_nspanel_weatherupdate - component: UtilityFunction config: code: >- function {{name}}(header, text) { if (!{{absorb_it_nspanel_ssaver_startupCheck}}(arguments.callee.name)) return; items.getItem(ctx.target).sendCommand('notify' + {{absorb_it_nspanel_ssaver_checkParam}}(header, 1) + {{absorb_it_nspanel_ssaver_checkParam}}(text, 1)); } name: absorb_it_nspanel_notify - component: UtilityFunction config: code: >- function {{name}}(leftIcon, leftIconColor, leftIconFont, rightIcon, rightIconColor, rightIconFont) { if (!{{absorb_it_nspanel_ssaver_startupCheck}}(arguments.callee.name)) return; mqtt = {{absorb_it_nspanel_ssaver_checkParam}}(leftIcon, 1) + {{absorb_it_nspanel_ssaver_checkParam}}({{absorb_it_nspanel_ssaver_getRGB565}}(leftIconColor), 1) + {{absorb_it_nspanel_ssaver_checkParam}}(rightIcon, 1) + {{absorb_it_nspanel_ssaver_checkParam}}({{absorb_it_nspanel_ssaver_getRGB565}}(rightIconColor), 1); mqtt += (leftIconFont == '1')?{{absorb_it_nspanel_ssaver_checkParam}}(leftIconFont, 1):'~'; mqtt += (rightIconFont == '1')?{{absorb_it_nspanel_ssaver_checkParam}}(rightIconFont, 1):'~'; items.getItem(ctx.target).sendCommand('statusUpdate' + mqtt); } name: absorb_it_nspanel_status - component: UtilityFunction config: code: >- function {{name}}(background, tTime, timeAMPM, tDate, tMainText, tForecast1, tForecast2, tForecast3, tForecast4, tForecast1Val, tForecast2Val, tForecast3Val, tForecast4Val, bar, tMainTextAlt2, tTimeAdd) { if (!{{absorb_it_nspanel_ssaver_startupCheck}}(arguments.callee.name)) return; items.getItem(ctx.target).sendCommand('color~' + {{absorb_it_nspanel_ssaver_getRGB565}}(background) + '~' + {{absorb_it_nspanel_ssaver_getRGB565}}(tTime) + '~' + {{absorb_it_nspanel_ssaver_getRGB565}}(timeAMPM) + '~' + {{absorb_it_nspanel_ssaver_getRGB565}}(tDate) + '~' + {{absorb_it_nspanel_ssaver_getRGB565}}(tMainText) + '~' + {{absorb_it_nspanel_ssaver_getRGB565}}(tForecast1) + '~' + {{absorb_it_nspanel_ssaver_getRGB565}}(tForecast2) + '~' + {{absorb_it_nspanel_ssaver_getRGB565}}(tForecast3) + '~' + {{absorb_it_nspanel_ssaver_getRGB565}}(tForecast4) + '~' + {{absorb_it_nspanel_ssaver_getRGB565}}(tForecast1Val) + '~' + {{absorb_it_nspanel_ssaver_getRGB565}}(tForecast2Val) + '~' + {{absorb_it_nspanel_ssaver_getRGB565}}(tForecast3Val) + '~' + {{absorb_it_nspanel_ssaver_getRGB565}}(tForecast4Val) + '~' + {{absorb_it_nspanel_ssaver_getRGB565}}(bar) + '~' + {{absorb_it_nspanel_ssaver_getRGB565}}(tMainTextAlt2) + '~' + {{absorb_it_nspanel_ssaver_getRGB565}}(tTimeAdd) ); } name: absorb_it_nspanel_color