uid: absorb-it:blockly:nspanel_entities tags: [] props: parameters: [] parameterGroups: [] timestamp: Nov 29, 2023, 8:13:57 AM component: BlockLibrary config: name: NSPanel Entities slots: blocks: - component: BlockType config: args0: - type: input_dummy align: CENTER - name: ICON type: input_value check: String - name: ICON_COLOR type: input_value check: Colour - name: DISPLAY_NAME type: input_value check: String - name: GETTER type: input_value check: String colour: 90 helpUrl: "https://github.com/absorb-it/openhab-blockly-nspanel/blob/main/docs/blockLibrary_nspanel_entities_label.md" inputsInline: false message0: > ENTITY LABEL %1 Icon %2 Icon Color %3 Displayed Name %4 Displayed Value %5 output: nspanel_entityLabelString tooltip: "Entity displaying some Icon and some Text. Dependend on the usage, the supplied Value might be shown or not." type: absorb_it_nspanel_entityLabel slots: code: - component: BlockCodeTemplate config: template: >- {{utility:absorb_it_nspanel_entityLabel}}({{input:ICON}}, {{input:ICON_COLOR}}, {{input:DISPLAY_NAME}}, {{input:GETTER}}) toolbox: - component: PresetInput config: fields: TEXT: "*" name: ICON shadow: true type: text - component: PresetInput config: fields: COLOUR: "#0000ee" name: ICON_COLOR shadow: true type: colour_picker - component: PresetInput config: fields: TEXT: Label name: DISPLAY_NAME shadow: true type: text - component: PresetInput config: fields: TEXT: 1 name: GETTER shadow: true type: text - component: BlockType config: args0: - type: input_dummy align: CENTER - name: ICON type: input_value check: String - name: ICON_COLOR type: input_value check: Colour - name: DISPLAY_NAME type: input_value check: String - name: GETTER type: input_value check: String - name: SETTER type: input_statement colour: 90 helpUrl: "https://github.com/absorb-it/openhab-blockly-nspanel/blob/main/docs/blockLibrary_nspanel_entities_button.md" inputsInline: false message0: > ENTITY BUTTON %1 Icon %2 Icon Color %3 Displayed Name %4 Displayed Value %5 Buttonpress Action %6 output: nspanel_entityButtonString tooltip: "Entity displaying some Icon and some Text. Additonally some Action can be added. Dependend on the usage, the supplied Value might be shown or not." type: absorb_it_nspanel_entityButton slots: code: - component: BlockCodeTemplate config: template: >- {{utility:absorb_it_nspanel_entityButton}}({{input:ICON}}, {{input:ICON_COLOR}}, {{input:DISPLAY_NAME}}, {{input:GETTER}}, `{{statements:SETTER}}`) toolbox: - component: PresetInput config: fields: TEXT: "*" name: ICON shadow: true type: text - component: PresetInput config: fields: COLOUR: "#0000ee" name: ICON_COLOR shadow: true type: colour_picker - component: PresetInput config: fields: TEXT: Button name: DISPLAY_NAME shadow: true type: text - component: PresetInput config: fields: TEXT: 1 name: GETTER shadow: true type: text - component: BlockType config: args0: - type: input_dummy align: CENTER - name: ICON type: input_value check: String - name: ICON_COLOR type: input_value check: Colour - name: DISPLAY_NAME type: input_value check: String - type: input_dummy - name: GETTER type: input_value check: String - name: SETTER type: input_statement - 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_entities_switch.md" inputsInline: false message0: > ENTITY SWITCH %1 Icon %2 Icon Color %3 Displayed Name %4 %5 Switch State ([0,1]) %6 Switch Action %8 - on Entities View: (returnValue=[0,1]) %9 - on other Views: (plain trigger) %10 %7 output: nspanel_entitySwitchString tooltip: "Entity displaying some Icon and some Text. A Switch is displayed, the Switch State and the Switch Actions can be configured. Dependend on the usage, the supplied Value might be shown or not." type: absorb_it_nspanel_entitySwitch slots: code: - component: BlockCodeTemplate config: template: >- {{utility:absorb_it_nspanel_entitySwitch}}({{input:ICON}}, {{input:ICON_COLOR}}, {{input:DISPLAY_NAME}}, {{input:GETTER}}, `{{statements:SETTER}}`) toolbox: - component: PresetInput config: fields: TEXT: "*" name: ICON shadow: true type: text - component: PresetInput config: fields: COLOUR: "#0000ee" name: ICON_COLOR shadow: true type: colour_picker - component: PresetInput config: fields: TEXT: Switch name: DISPLAY_NAME shadow: true type: text - component: PresetInput config: fields: TEXT: 1 name: GETTER shadow: true type: text - component: BlockType config: message0: > ENTITY LIGHT %1 Icon %2 Icon Color %3 Displayed Name %4 %5 Light State ([0,1]) %6 Switch Action %7 - on Entities View: (returnValue=[0,1]) %8 - on other Views: (plain trigger) %9 %10 args0: - type: input_dummy align: CENTER - name: ICON type: input_value check: String - name: ICON_COLOR type: input_value check: Colour - name: DISPLAY_NAME type: input_value check: String - type: input_dummy - name: GETTER type: input_value check: String - type: input_dummy - type: input_dummy - name: SETTER type: input_statement - type: input_dummy message1: > **** POPUP **** %1 %2 Show Color Wheel with Label %3 Brightness to use for RGB calculation %4 Set Color (returnValue=Color="#RGB") %5 %6 %7 Show Color Temp Slider with Label %8 Preset Value [0-100] %9 Set Color Temp (returnValue=[0-100]) %10 %11 %12 Show Brightness Slider with Label %13 Preset Value [0-100] %14 Set Brightness (returnValue=[0-100]) %15 args1: - type: input_dummy - name: COLOR_WHEEL type: field_checkbox - name: COLOR_WHEEL_LABEL type: input_value check: String - name: BRIGHTNESS_FOR_WHEEL type: input_value check: Number - name: SET_COLOR_WHEEL type: input_statement align: RIGHT - type: input_dummy - name: COLOR_TEMP type: field_checkbox - name: COLOR_TEMP_LABEL type: input_value check: String - name: GET_COLOR_TEMP type: input_value check: Number - name: SET_COLOR_TEMP type: input_statement - type: input_dummy - name: BRIGHTNESS type: field_checkbox - name: BRIGHTNESS_LABEL type: input_value check: String - name: GET_BRIGHTNESS type: input_value check: Number - name: SET_BRIGHTNESS type: input_statement inputsInline: false colour: 90 helpUrl: "https://github.com/absorb-it/openhab-blockly-nspanel/blob/main/docs/blockLibrary_nspanel_entities_light.md" output: nspanel_entityLightString tooltip: >- Entity displaying some Icon and some Text. A Switch is displayed, the Switch State and the Switch Actions can be configured. Dependend on the usage, the supplied Value might be shown or not. Additionally to the Switch entity some Popup Page can be accessed to control more specific light settings. type: absorb_it_nspanel_entityLight slots: code: - component: BlockCodeTemplate config: template: >- {{utility:absorb_it_nspanel_entityLight}}({{input:ICON}}, {{input:ICON_COLOR}}, {{input:DISPLAY_NAME}}, {{input:GETTER}}, `{{statements:SETTER}}`, '{{field:COLOR_WHEEL}}', {{input:COLOR_WHEEL_LABEL}}, {{input:BRIGHTNESS_FOR_WHEEL}}, `{{statements:SET_COLOR_WHEEL}}`, '{{field:COLOR_TEMP}}', {{input:COLOR_TEMP_LABEL}}, {{input:GET_COLOR_TEMP}}, `{{statements:SET_COLOR_TEMP}}`, '{{field:BRIGHTNESS}}', {{input:BRIGHTNESS_LABEL}}, {{input:GET_BRIGHTNESS}}, `{{statements:SET_BRIGHTNESS}}`) toolbox: - component: PresetInput config: fields: TEXT: "*" name: ICON shadow: true type: text - component: PresetInput config: fields: COLOUR: "#0000ee" name: ICON_COLOR shadow: true type: colour_picker - component: PresetInput config: fields: TEXT: Light name: DISPLAY_NAME shadow: true type: text - component: PresetInput config: fields: TEXT: 1 name: GETTER shadow: true type: text - component: PresetInput config: fields: TEXT: Color name: COLOR_WHEEL_LABEL shadow: true type: text - component: PresetInput config: fields: NUM: 100 name: BRIGHTNESS_FOR_WHEEL shadow: true type: math_number - component: PresetInput config: fields: TEXT: Color Temperature name: COLOR_TEMP_LABEL shadow: true type: text - component: PresetInput config: fields: NUM: 100 name: GET_COLOR_TEMP shadow: true type: math_number - component: PresetInput config: fields: TEXT: Brightness name: BRIGHTNESS_LABEL shadow: true type: text - component: PresetInput config: fields: NUM: 100 name: GET_BRIGHTNESS shadow: true type: math_number - component: BlockType config: message0: > ENTITY SHUTTER %1 Icon %2 Icon Color %3 Displayed Name %4 %5 **** POPUP **** %9 Popup Page Icon %6 Popup Page Subtitle %7 %8 args0: - type: input_dummy align: CENTER - name: ICON type: input_value check: String - name: ICON_COLOR type: input_value check: Colour - name: DISPLAY_NAME type: input_value check: String - type: input_dummy - name: POPUP_ICON type: input_value check: String - name: POPUP_SUBTITLE type: input_value check: String - type: input_dummy - type: input_dummy message1: > Upper Slider (Position) - Label %1 - %2 'UP' Icon %3 - %4 'STOP' Icon %5 - %6 'DOWN' Icon %7 - Position ([0-100]) %8 - Action Trigger (Entities Page and Popup) %9 . (returnValue = [0-100|UP|STOP|DOWN]) %11 %10 %12 args1: - name: UPPER_LABEL type: input_value check: String - name: UPPER_UP_ENABLE type: field_checkbox - name: UPPER_UP_ICON type: input_value check: String - name: UPPER_STOP_ENABLE type: field_checkbox - name: UPPER_STOP_ICON type: input_value check: String - name: UPPER_DOWN_ENABLE type: field_checkbox - name: UPPER_DOWN_ICON type: input_value check: String - name: UPPER_GETTER type: input_value check: Number - type: input_dummy - name: UPPER_SETTER type: input_statement - type: input_dummy - type: input_dummy message2: > Lower Slider (Tilt) - Label %1 - %2 'OPEN' Icon %3 - %4 'STOP' Icon %5 - %6 'CLOSE' Icon %7 - Position ([0-100]) %8 - Action Trigger %9 . (returnValue = [0-100|OPEN|STOP|CLOSE]) %11 %10 args2: - name: LOWER_LABEL type: input_value check: String - name: LOWER_LEFT_ENABLE type: field_checkbox - name: LOWER_LEFT_ICON type: input_value check: String - name: LOWER_STOP_ENABLE type: field_checkbox - name: LOWER_STOP_ICON type: input_value check: String - name: LOWER_RIGHT_ENABLE type: field_checkbox - name: LOWER_RIGHT_ICON type: input_value check: String - name: LOWER_GETTER type: input_value check: Number - type: input_dummy - name: LOWER_SETTER type: input_statement - type: input_dummy inputsInline: false colour: 90 helpUrl: "https://github.com/absorb-it/openhab-blockly-nspanel/blob/main/docs/blockLibrary_nspanel_entities_shutter.md" output: nspanel_entityShutterString tooltip: "Entity displaying some Icon and some Text. Additionally some shutter controls might be displayed and access to some Popup Page with more specific settings is given." type: absorb_it_nspanel_entityShutter slots: code: - component: BlockCodeTemplate config: template: >- {{utility:absorb_it_nspanel_entityShutter}}({{input:ICON}}, {{input:ICON_COLOR}}, {{input:DISPLAY_NAME}}, {{input:POPUP_ICON}}, {{input:POPUP_SUBTITLE}}, {{input:UPPER_LABEL}}, '{{field:UPPER_UP_ENABLE}}', {{input:UPPER_UP_ICON}}, '{{field:UPPER_STOP_ENABLE}}', {{input:UPPER_STOP_ICON}}, '{{field:UPPER_DOWN_ENABLE}}', {{input:UPPER_DOWN_ICON}}, {{input:UPPER_GETTER}}, `{{statements:UPPER_SETTER}}`, {{input:LOWER_LABEL}}, '{{field:LOWER_LEFT_ENABLE}}', {{input:LOWER_LEFT_ICON}}, '{{field:LOWER_STOP_ENABLE}}', {{input:LOWER_STOP_ICON}}, '{{field:LOWER_RIGHT_ENABLE}}', {{input:LOWER_RIGHT_ICON}}, {{input:LOWER_GETTER}}, `{{statements:LOWER_SETTER}}`) toolbox: - component: PresetInput config: fields: TEXT: "*" name: ICON shadow: true type: text - component: PresetInput config: fields: COLOUR: "#0000ee" name: ICON_COLOR shadow: true type: colour_picker - component: PresetInput config: fields: TEXT: Shutter name: DISPLAY_NAME shadow: true type: text - component: PresetInput config: fields: TEXT: "#" name: POPUP_ICON shadow: true type: text - component: PresetInput config: fields: TEXT: Shutter Control name: POPUP_SUBTITLE shadow: true type: text - component: PresetInput config: fields: TEXT: Shutter State name: UPPER_LABEL shadow: true type: text - component: PresetInput config: fields: TEXT: ^ name: UPPER_UP_ICON shadow: true type: text - component: PresetInput config: fields: TEXT: x name: UPPER_STOP_ICON shadow: true type: text - component: PresetInput config: fields: TEXT: v name: UPPER_DOWN_ICON shadow: true type: text - component: PresetInput config: fields: TEXT: Tilt State name: LOWER_LABEL shadow: true type: text - component: PresetInput config: fields: TEXT: "{" name: LOWER_LEFT_ICON shadow: true type: text - component: PresetInput config: fields: TEXT: x name: LOWER_STOP_ICON shadow: true type: text - component: PresetInput config: fields: TEXT: "}" name: LOWER_RIGHT_ICON shadow: true type: text - component: PresetInput config: fields: NUM: 75 name: UPPER_GETTER shadow: true type: math_number - component: PresetInput config: fields: NUM: 50 name: LOWER_GETTER shadow: true type: math_number - component: BlockType config: message0: > ENTITY SELECTOR %1 Icon %2 Icon Color %3 Displayed Name %4 %5 Active Option ('option'-label expected) %6 Trigger State Change (call on button press) %7 %8 %9 args0: - type: input_dummy align: CENTER - name: ICON type: input_value check: String - name: ICON_COLOR type: input_value check: Colour - name: DISPLAY_NAME type: input_value check: String - type: input_dummy - name: GET_SELECTION type: input_value check: String - type: input_dummy - name: TRIGGER_CHANGE type: input_statement - type: input_dummy message1: > **** POPUP **** %3 Popup Icon Color %1 %2 args1: - name: POPUP_ICON_COLOR type: input_value check: Colour - type: input_dummy - type: input_dummy message2: > Possible Options (separate by options by '?') %1 - Action Trigger %2 . (returnValue = (index) = [1-X]) %3 . (returnMode = 'Option') %4 %5 args2: - name: GET_OPTIONS type: input_value check: String - type: input_dummy - type: input_dummy - type: input_dummy - name: SETTER type: input_statement colour: 90 helpUrl: "https://github.com/absorb-it/openhab-blockly-nspanel/blob/main/docs/blockLibrary_nspanel_entities_selector.md" output: nspanel_entitySelectorString tooltip: "Entity displaying some Icon and some Text. Additionally the pre-selected Mode might be displayed and access to some Popup Page with more specific settings is given." type: absorb_it_nspanel_entitySelector slots: code: - component: BlockCodeTemplate config: template: >- {{utility:absorb_it_nspanel_entitySelector}}({{input:ICON}}, {{input:ICON_COLOR}}, {{input:DISPLAY_NAME}}, {{input:POPUP_ICON_COLOR}}, {{input:GET_OPTIONS}}, {{input:GET_SELECTION}}, `{{statements:SETTER}}`, `{{statements:TRIGGER_CHANGE}}`) toolbox: - component: PresetInput config: fields: TEXT: "*" name: ICON shadow: true type: text - component: PresetInput config: fields: COLOUR: "#0000ee" name: ICON_COLOR shadow: true type: colour_picker - component: PresetInput config: fields: TEXT: Selector name: DISPLAY_NAME shadow: true type: text - component: PresetInput config: fields: COLOUR: "#0000ee" name: POPUP_ICON_COLOR shadow: true type: colour_picker - component: PresetInput config: fields: TEXT: hdmi?dp?vga?usb-c?dvi name: GET_OPTIONS shadow: true type: text - component: PresetInput config: fields: TEXT: usb-c name: GET_SELECTION shadow: true type: text - component: BlockType config: message0: > ENTITY FAN %1 Icon %2 Icon Color %3 Displayed Name %4 %5 State of Item ([0,1]) %6 Set Item State (returnValue=[0,1]) %7 %8 %9 args0: - type: input_dummy align: CENTER - name: ICON type: input_value check: String - name: ICON_COLOR type: input_value check: Colour - name: DISPLAY_NAME type: input_value check: String - type: input_dummy - name: GETTER type: input_value check: String - type: input_dummy - name: SETTER type: input_statement - type: input_dummy message1: > **** POPUP **** %1 Popup Source Icon Color %2 %3 args1: - type: input_dummy - name: POPUP_ICON_COLOR type: input_value - type: input_dummy message2: > Slider Label %1 Slider Value %2 Slider Maximum %3 Set Speed (returnValue = [0-Max]) %12 %4 %5 Possible Modes (separate by '?') %6 Selected Mode %7 Set Mode %8 . (returnValue = (index) = [1-X]) %9 . (returnMode = 'Mode') %10 %11 args2: - name: LABEL type: input_value check: String - name: SPEED type: input_value check: Number - name: SPEED_MAX type: input_value check: Number - name: SET_SPEED type: input_statement - type: input_dummy - name: MODES type: input_value check: String - name: SELECTED_MODE type: input_value check: String - type: input_dummy - type: input_dummy - type: input_dummy - name: SET_SELECTED_MODE type: input_statement - type: input_dummy colour: 90 helpUrl: "https://github.com/absorb-it/openhab-blockly-nspanel/blob/main/docs/blockLibrary_nspanel_entities_fan.md" output: nspanel_entityFanString tooltip: >- Entity displaying some Icon and some Text. A Switch is displayed, the Switch State and the Switch Actions can be configured. Dependend on the usage, the supplied Value might be shown or not. Additionally to the Switch entity some Popup Page can be accessed to control more specific fan settings. type: absorb_it_nspanel_entityFan slots: code: - component: BlockCodeTemplate config: template: >- {{utility:absorb_it_nspanel_entityFan}}({{input:ICON}}, {{input:ICON_COLOR}}, {{input:DISPLAY_NAME}}, {{input:GETTER}}, `{{statements:SETTER}}`, {{input:POPUP_ICON_COLOR}}, {{input:LABEL}}, {{input:SPEED}}, {{input:SPEED_MAX}}, `{{statements:SET_SPEED}}`, {{input:MODES}}, {{input:SELECTED_MODE}}, `{{statements:SET_SELECTED_MODE}}`) toolbox: - component: PresetInput config: fields: TEXT: "*" name: ICON shadow: true type: text - component: PresetInput config: fields: COLOUR: "#0000ee" name: ICON_COLOR shadow: true type: colour_picker - component: PresetInput config: fields: TEXT: Fan name: DISPLAY_NAME shadow: true type: text - component: PresetInput config: fields: TEXT: 1 name: GETTER shadow: true type: text - component: PresetInput config: fields: COLOUR: "#0000ee" name: POPUP_ICON_COLOR shadow: true type: colour_picker - component: PresetInput config: fields: TEXT: Speed name: LABEL shadow: true type: text - component: PresetInput config: fields: NUM: 75 name: SPEED shadow: true type: math_number - component: PresetInput config: fields: NUM: 100 name: SPEED_MAX shadow: true type: math_number - component: PresetInput config: fields: TEXT: economy?comfort?luxary name: MODES shadow: true type: text - component: PresetInput config: fields: TEXT: economy name: SELECTED_MODE shadow: true type: text - component: BlockType config: message0: > ENTITY TIMER %1 Icon %2 Icon Color %3 Displayed Name %4 Displayed Value %5 %6 args0: - type: input_dummy align: CENTER - name: ICON type: input_value check: String - name: ICON_COLOR type: input_value check: Colour - name: DISPLAY_NAME type: input_value check: String - name: DISPLAY_VALUE type: input_value check: String - type: input_dummy message1: > **** POPUP **** %1 Popup Icon Color %2 %3 args1: - type: input_dummy - name: POPUP_ICON_COLOR type: input_value check: Colour - type: input_dummy message2: > Preset Timer Minutes %1 Preset Timer Seconds %2 Editable %3 %4 %5 args2: - name: MIN_REMAINING type: input_value check: Number - name: SEC_REMAINING type: input_value check: Number - name: EDITABLE type: field_checkbox - type: input_dummy - type: input_dummy message3: > Left Button %1 Left Button Id %2 Middle Button %3 Middle Button Id %4 Right Button %5 Right Button Id %6 args3: - name: LEFT_BTN type: input_value check: String - name: LEFT_BTN_ACTION type: input_statement - name: MID_BTN type: input_value check: String - name: MID_BTN_ACTION type: input_statement - name: RIGHT_BTN type: input_value check: String - name: RIGHT_BTN_ACTION type: input_statement colour: 90 helpUrl: "https://github.com/absorb-it/openhab-blockly-nspanel/blob/main/docs/blockLibrary_nspanel_entities_timer.md" inputsInline: false output: nspanel_entityTimerString tooltip: "Entity displaying some Icon and some Text. Additionally access to some Popup Page with a timer and more specific settings is given." type: absorb_it_nspanel_entityTimer slots: code: - component: BlockCodeTemplate config: template: >- {{utility:absorb_it_nspanel_entityTimer}}({{input:ICON}}, {{input:ICON_COLOR}}, {{input:DISPLAY_NAME}}, {{input:DISPLAY_VALUE}}, {{input:POPUP_ICON_COLOR}}, {{input:MIN_REMAINING}}, {{input:SEC_REMAINING}}, '{{field:EDITABLE}}', {{input:LEFT_BTN}}, `{{statements:LEFT_BTN_ACTION}}`, {{input:MID_BTN}}, `{{statements:MID_BTN_ACTION}}`, {{input:RIGHT_BTN}}, `{{statements:RIGHT_BTN_ACTION}}`) toolbox: - component: PresetInput config: fields: TEXT: "*" name: ICON shadow: true type: text - component: PresetInput config: fields: COLOUR: "#0000ee" name: ICON_COLOR shadow: true type: colour_picker - component: PresetInput config: fields: TEXT: Timer name: DISPLAY_NAME shadow: true type: text - component: PresetInput config: fields: TEXT: value name: DISPLAY_VALUE shadow: true type: text - component: PresetInput config: fields: COLOUR: "#0000ee" name: POPUP_ICON_COLOR shadow: true type: colour_picker - component: PresetInput config: fields: NUM: 42 name: MIN_REMAINING shadow: true type: math_number - component: PresetInput config: fields: NUM: 13 name: SEC_REMAINING shadow: true type: math_number - component: PresetInput config: fields: TEXT: left name: LEFT_BTN shadow: true type: text - component: PresetInput config: fields: TEXT: middle name: MID_BTN shadow: true type: text - component: PresetInput config: fields: TEXT: right name: RIGHT_BTN shadow: true type: text utilities: - 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_entities_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_entities_checkParam - component: UtilityFunction config: code: >- function {{name}}(command, returnValue = '', returnMode = '') { // evaluate command, use returnValue/returnMode as context let result = ""; // convert to returnValue to Number if possible if (parseFloat(returnValue) == returnValue) returnValue = parseFloat(returnValue); 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_entities_safeEval - component: UtilityFunction config: code: >- function {{name}}() { let ownEntityPos = cache.private.get('entity_pos'); // prepare Position for next entity cache.private.put('entity_pos', parseInt(ownEntityPos) + 1) return ownEntityPos; } name: absorb_it_nspanel_entities_getEntityPos - component: UtilityFunction config: code: >- function {{name}}(HSBarray) { let h = HSBarray[0]/360; let s = HSBarray[1]/100; let v = HSBarray[2]/100; // based on https://stackoverflow.com/questions/17242144/javascript-convert-hsb-hsv-color-to-rgb-accurately // CC BY-SA 4.0 Deed license - https://creativecommons.org/licenses/by-sa/4.0/ var r, g, b, i, f, p, q, t; i = Math.floor(h * 6); f = h * 6 - i; p = v * (1 - s); q = v * (1 - f * s); t = v * (1 - (1 - f) * s); switch (i % 6) { case 0: r = v, g = t, b = p; break; case 1: r = q, g = v, b = p; break; case 2: r = p, g = v, b = t; break; case 3: r = p, g = q, b = v; break; case 4: r = t, g = p, b = v; break; case 5: r = v, g = p, b = q; break; } let returnString = "#" + Math.round(r * 255).toString(16).padStart(2, '0') + Math.round(g * 255).toString(16).padStart(2, '0') + Math.round(b * 255).toString(16).padStart(2, '0'); console.debug("HSB[" + h + " " + s + " " + v + "] -> " + returnString); return returnString; } name: absorb_it_nspanel_HSBtoRGB - component: UtilityFunction config: code: >- function {{name}}(WheelPosString, colorWheelBrightness) { // based on https://github.com/joBr99/nspanel-lovelace-ui/blob/19050079d4168d9c9d23e4e7ea0d1cc5d8de9ca3/apps/nspanel-lovelace-ui/luibackend/helper.py#L15 // GPL-3.0 license let myArray = WheelPosString.split("|"); let r = myArray[2]/2; // 80 let x = myArray[0]; let y = myArray[1]; x = Math.round((x - r) / r * 100) / 100; y = Math.round((r - y) / r * 100) / 100; r = Math.sqrt(x*x + y*y); let sat = 0; if (r <= 1) sat = r; return [ (Math.atan2(y, x) > 0 ? Math.atan2(y, x) : (2*Math.PI + Math.atan2(y, x))) * 360 / (2*Math.PI), sat * 100, colorWheelBrightness ]; } name: absorb_it_nspanel_WheelPosToHSB - component: UtilityFunction config: code: >- function {{name}}(icon, iconColor, displayName, getState, setState) { var ownEntityPos = {{absorb_it_nspanel_entities_getEntityPos}}(); if (ctx.item == ownEntityPos && ctx.request == 'pageUpdate') { {{absorb_it_nspanel_entities_safeEval}}(setState, ctx.newState); return { "refreshPage": "1" }; } return { "resultString": '~switch~' + ctx.ruleUID + '?' + ownEntityPos + {{absorb_it_nspanel_entities_checkParam}}(icon, 1) + {{absorb_it_nspanel_entities_checkParam}}({{absorb_it_nspanel_entities_getRGB565}}(iconColor), 1) + {{absorb_it_nspanel_entities_checkParam}}(displayName, 1) + {{absorb_it_nspanel_entities_checkParam}}(getState, 1) } } name: absorb_it_nspanel_entitySwitch - component: UtilityFunction config: code: >- function {{name}}(icon, iconColor, displayName, getState) { var ownEntityPos = {{absorb_it_nspanel_entities_getEntityPos}}(); return { "resultString": '~text~' + ctx.ruleUID + '?' + ownEntityPos + {{absorb_it_nspanel_entities_checkParam}}(icon, 1) + {{absorb_it_nspanel_entities_checkParam}}({{absorb_it_nspanel_entities_getRGB565}}(iconColor), 1) + {{absorb_it_nspanel_entities_checkParam}}(displayName, 1) + {{absorb_it_nspanel_entities_checkParam}}(getState, 1) } } name: absorb_it_nspanel_entityLabel - component: UtilityFunction config: code: >- function {{name}}(icon, iconColor, displayName, getState, setState) { var ownEntityPos = {{absorb_it_nspanel_entities_getEntityPos}}(); if (ctx.item == ownEntityPos && ctx.request == 'pageUpdate') { {{absorb_it_nspanel_entities_safeEval}}(setState, ctx.newState); return { "refreshPage": "1" }; } return { "resultString": '~button~' + ctx.ruleUID + '?' + ownEntityPos + {{absorb_it_nspanel_entities_checkParam}}(icon, 1) + {{absorb_it_nspanel_entities_checkParam}}({{absorb_it_nspanel_entities_getRGB565}}(iconColor), 1) + {{absorb_it_nspanel_entities_checkParam}}(displayName, 1) + {{absorb_it_nspanel_entities_checkParam}}(getState, 1) } } name: absorb_it_nspanel_entityButton - component: UtilityFunction config: code: >- function {{name}}(icon, iconColor, displayName, getState, setState, colorWheel, colorWheelLabel, colorWheelBrightness, setColorWheel, colorTemp, colorTempLabel, getColorTemp, setColorTemp, brightness, brightnessLabel, getBrightness, setBrightness) { var ownEntityPos = {{absorb_it_nspanel_entities_getEntityPos}}(); if (ctx.item == ownEntityPos) { if (ctx.request == 'pageUpdate' && ctx["newState"] !== undefined && ctx.trigger == "OnOff") { {{absorb_it_nspanel_entities_safeEval}}(setState, ctx.newState); return { "refreshPage": "1" }; } if (ctx.request == 'pageOpenDetail') { if (ctx["newState"] !== undefined) { switch (ctx.trigger) { case "OnOff": {{absorb_it_nspanel_entities_safeEval}}(setState, ctx.newState); break; case "colorWheel": let HSBarray = {{absorb_it_nspanel_WheelPosToHSB}}(ctx.newState, colorWheelBrightness); let RGBstring = {{absorb_it_nspanel_HSBtoRGB}}(HSBarray); {{absorb_it_nspanel_entities_safeEval}}(setColorWheel, RGBstring); break; case "colorTempSlider": console.log("\n\n\n***\ncolorTempSlider action: " + ctx.newState); {{absorb_it_nspanel_entities_safeEval}}(setColorTemp, ctx.newState); break; case "brightnessSlider": {{absorb_it_nspanel_entities_safeEval}}(setBrightness, ctx.newState); break; } return { "refreshPage": "1" }; } else { let mqtt = 'entityUpdateDetail' + {{absorb_it_nspanel_entities_checkParam}}(ctx.ruleUID + '?' + ownEntityPos, 1) + '~' + {{absorb_it_nspanel_entities_checkParam}}({{absorb_it_nspanel_entities_getRGB565}}(iconColor), 1) + {{absorb_it_nspanel_entities_checkParam}}(getState, 1); mqtt += (brightness == "TRUE")?({{absorb_it_nspanel_entities_checkParam}}(getBrightness, 1)):'~disable'; mqtt += (colorTemp == "TRUE")?({{absorb_it_nspanel_entities_checkParam}}(getColorTemp, 1)):'~disable'; mqtt += (colorWheel == "TRUE")?'~enable':'~disable'; mqtt += {{absorb_it_nspanel_entities_checkParam}}(colorWheelLabel, 1) + {{absorb_it_nspanel_entities_checkParam}}(colorTempLabel, 1) + {{absorb_it_nspanel_entities_checkParam}}(brightnessLabel, 1); return { "sendNow": "1", "resultString": mqtt }; } } } return { "resultString": '~light~' + ctx.ruleUID + '?' + ownEntityPos + {{absorb_it_nspanel_entities_checkParam}}(icon, 1) + {{absorb_it_nspanel_entities_checkParam}}({{absorb_it_nspanel_entities_getRGB565}}(iconColor), 1) + {{absorb_it_nspanel_entities_checkParam}}(displayName, 1) + {{absorb_it_nspanel_entities_checkParam}}(getState, 1) } } name: absorb_it_nspanel_entityLight - component: UtilityFunction config: code: >- function {{name}}(icon, iconColor, displayName, popupIcon, popupSubtitle, upperLabel, upperUpEnable, upperUpIcon, upperStopEnable, upperStopIcon, upperDownEnable, upperDownIcon, upperGetter, upperSetter, lowerLabel, lowerLeftEnable, lowerLeftIcon, lowerStopEnable, lowerStopIcon, lowerRightEnable, lowerRightIcon, lowerGetter, lowerSetter) { var ownEntityPos = {{absorb_it_nspanel_entities_getEntityPos}}(); if (ctx.item == ownEntityPos) { if (ctx.request == 'pageUpdate' && ctx["newState"] !== undefined && (ctx.trigger == "up" || ctx.trigger == "stop" || ctx.trigger == "down")) { {{absorb_it_nspanel_entities_safeEval}}(upperSetter, ctx.trigger.toUpperCase()); return { "refreshPage": "1" }; } if (ctx.request == 'pageOpenDetail') { if (ctx["newState"] !== undefined) { switch (ctx.trigger) { case "tiltOpen": {{absorb_it_nspanel_entities_safeEval}}(lowerSetter, "OPEN"); break; case "tiltStop": {{absorb_it_nspanel_entities_safeEval}}(lowerSetter, "STOP"); break; case "tiltClose": {{absorb_it_nspanel_entities_safeEval}}(lowerSetter, "CLOSE"); break; case "tiltSlider": {{absorb_it_nspanel_entities_safeEval}}(upperSetter, ctx.newState); break; case "up": case "stop": case "down": {{absorb_it_nspanel_entities_safeEval}}(upperSetter, ctx.trigger.toUpperCase()); break; case "positionSlider": {{absorb_it_nspanel_entities_safeEval}}(upperSetter, ctx.newState); break; } return { "refreshPage": "1" }; } else { let mqtt = 'entityUpdateDetail' + {{absorb_it_nspanel_entities_checkParam}}(ctx.ruleUID + '?' + ownEntityPos, 1) + {{absorb_it_nspanel_entities_checkParam}}(upperGetter, 1) + {{absorb_it_nspanel_entities_checkParam}}(popupSubtitle, 1) + {{absorb_it_nspanel_entities_checkParam}}(upperLabel, 1) + {{absorb_it_nspanel_entities_checkParam}}(popupIcon, 1) + {{absorb_it_nspanel_entities_checkParam}}(upperUpIcon, 1) + {{absorb_it_nspanel_entities_checkParam}}(upperStopIcon, 1) + {{absorb_it_nspanel_entities_checkParam}}(upperDownIcon, 1); mqtt += (upperUpEnable == "TRUE")?'~enable':'~disable'; mqtt += (upperStopEnable == "TRUE")?'~enable':'~disable'; mqtt += (upperDownEnable == "TRUE")?'~enable':'~disable'; mqtt += {{absorb_it_nspanel_entities_checkParam}}(lowerLabel, 1) + {{absorb_it_nspanel_entities_checkParam}}(lowerLeftIcon, 1) + {{absorb_it_nspanel_entities_checkParam}}(lowerStopIcon, 1) + {{absorb_it_nspanel_entities_checkParam}}(lowerRightIcon, 1); mqtt += (lowerLeftEnable == "TRUE")?'~enable':'~disable'; mqtt += (lowerStopEnable == "TRUE")?'~enable':'~disable'; mqtt += (lowerRightEnable == "TRUE")?'~enable':'~disable'; mqtt += {{absorb_it_nspanel_entities_checkParam}}(lowerGetter, 1); return { "sendNow": "1", "resultString": mqtt }; } } } return { "resultString": '~shutter~' + ctx.ruleUID + '?' + ownEntityPos + {{absorb_it_nspanel_entities_checkParam}}(icon, 1) + {{absorb_it_nspanel_entities_checkParam}}({{absorb_it_nspanel_entities_getRGB565}}(iconColor), 1) + {{absorb_it_nspanel_entities_checkParam}}(displayName, 1) + '~' } } name: absorb_it_nspanel_entityShutter - component: UtilityFunction config: code: >- function {{name}}(icon, iconColor, displayName, popupIconColor, getOptions, getSelection, setOption, triggerChange) { var ownEntityPos = {{absorb_it_nspanel_entities_getEntityPos}}(); if (ctx.item == ownEntityPos) { if (ctx.request == 'pageUpdate' && ctx["newState"] !== undefined && ctx.trigger == "button") { {{absorb_it_nspanel_entities_safeEval}}(triggerChange); return { "refreshPage": "1" }; } if (ctx.request == 'pageOpenDetail') { if (ctx["newState"] !== undefined) { {{absorb_it_nspanel_entities_safeEval}}(setOption, parseInt(ctx.newState) + 1, getOptions.split('?')[ctx.newState]); return { "refreshPage": "1" }; } else { let mqtt = 'entityUpdateDetail2' + {{absorb_it_nspanel_entities_checkParam}}(ctx.ruleUID + '?' + ownEntityPos, 1) + '~' + {{absorb_it_nspanel_entities_checkParam}}({{absorb_it_nspanel_entities_getRGB565}}(popupIconColor), 1)+ '~' + {{absorb_it_nspanel_entities_checkParam}}(getSelection, 1) + {{absorb_it_nspanel_entities_checkParam}}(getOptions, 1); return { "sendNow": "1", "resultString": mqtt }; } } } return { "resultString": '~input_sel~' + ctx.ruleUID + '?' + ownEntityPos + {{absorb_it_nspanel_entities_checkParam}}(icon, 1) + {{absorb_it_nspanel_entities_checkParam}}({{absorb_it_nspanel_entities_getRGB565}}(iconColor), 1) + {{absorb_it_nspanel_entities_checkParam}}(displayName, 1) + {{absorb_it_nspanel_entities_checkParam}}(getSelection, 1) } } name: absorb_it_nspanel_entitySelector - component: UtilityFunction config: code: >- function {{name}}(icon, iconColor, displayName, getter, setter, popupIconColor, label, speed, speedMax, setSpeed, modes, selectedMode, setSelectedMode) { var ownEntityPos = {{absorb_it_nspanel_entities_getEntityPos}}(); if (ctx.item == ownEntityPos) { if (ctx.request == 'pageUpdate' && ctx["newState"] !== undefined && ctx.trigger == "OnOff") { {{absorb_it_nspanel_entities_safeEval}}(setter, ctx.newState); return { "refreshPage": "1" }; } if (ctx.request == 'pageOpenDetail') { if (ctx["newState"] !== undefined) { switch (ctx.trigger) { case "OnOff": {{absorb_it_nspanel_entities_safeEval}}(setter, ctx.newState); break; case "number-set": {{absorb_it_nspanel_entities_safeEval}}(setSpeed, ctx.newState); break; case "mode-preset_modes": {{absorb_it_nspanel_entities_safeEval}}(setSelectedMode, parseInt(ctx.newState) + 1, modes.split('?')[ctx.newState]); break; } return { "refreshPage": "1" }; } else { let mqtt = 'entityUpdateDetail' + {{absorb_it_nspanel_entities_checkParam}}(ctx.ruleUID + '?' + ownEntityPos, 1) + '~' + {{absorb_it_nspanel_entities_checkParam}}({{absorb_it_nspanel_entities_getRGB565}}(popupIconColor), 1)+ {{absorb_it_nspanel_entities_checkParam}}(getter, 1) + {{absorb_it_nspanel_entities_checkParam}}(speed, 1) + {{absorb_it_nspanel_entities_checkParam}}(speedMax, 1)+ {{absorb_it_nspanel_entities_checkParam}}(label, 1) + {{absorb_it_nspanel_entities_checkParam}}(selectedMode, 1) + {{absorb_it_nspanel_entities_checkParam}}(modes, 1) return { "sendNow": "1", "resultString": mqtt }; } } } return { "resultString": '~fan~' + ctx.ruleUID + '?' + ownEntityPos + {{absorb_it_nspanel_entities_checkParam}}(icon, 1) + {{absorb_it_nspanel_entities_checkParam}}({{absorb_it_nspanel_entities_getRGB565}}(iconColor), 1) + {{absorb_it_nspanel_entities_checkParam}}(displayName, 1) + {{absorb_it_nspanel_entities_checkParam}}(getter, 1) } } name: absorb_it_nspanel_entityFan - component: UtilityFunction config: code: >- function {{name}}(icon, iconColor, displayName, displayValue, popupIconColor, minRemaining, secRemaining, editable, leftBtn, leftBtnAction, midBtn, midBtnAction, rightBtn, rightBtnAction) { var ownEntityPos = {{absorb_it_nspanel_entities_getEntityPos}}(); if (ctx.item == ownEntityPos && ctx.request == 'pageOpenDetail') { if (ctx["newState"] !== undefined) { switch (ctx.trigger) { case "timer-left": {{absorb_it_nspanel_entities_safeEval}}(leftBtnAction, ctx.newState); break; case "timer-middle": {{absorb_it_nspanel_entities_safeEval}}(midBtnAction, ctx.newState); break; case "timer-right": {{absorb_it_nspanel_entities_safeEval}}(rightBtnAction, ctx.newState); break; } return { "refreshPage": "1" }; } else { let mqtt = 'entityUpdateDetail' + {{absorb_it_nspanel_entities_checkParam}}(ctx.ruleUID + '?' + ownEntityPos, 1) + '~' + {{absorb_it_nspanel_entities_checkParam}}({{absorb_it_nspanel_entities_getRGB565}}(iconColor), 1) + {{absorb_it_nspanel_entities_checkParam}}(ctx.ruleUID + '?' + ownEntityPos, 1) + {{absorb_it_nspanel_entities_checkParam}}(minRemaining, 1) + {{absorb_it_nspanel_entities_checkParam}}(secRemaining, 1); mqtt += (editable == "TRUE")?'~1':'~0'; mqtt += "~left~mid~right" + {{absorb_it_nspanel_entities_checkParam}}(leftBtn, 1) + {{absorb_it_nspanel_entities_checkParam}}(midBtn, 1) + {{absorb_it_nspanel_entities_checkParam}}(rightBtn, 1); return { "sendNow": "1", "resultString": mqtt }; } } return { "resultString": '~timer~' + ctx.ruleUID + '?' + ownEntityPos + {{absorb_it_nspanel_entities_checkParam}}(icon, 1) + {{absorb_it_nspanel_entities_checkParam}}({{absorb_it_nspanel_entities_getRGB565}}(iconColor), 1) + {{absorb_it_nspanel_entities_checkParam}}(displayName, 1) + {{absorb_it_nspanel_entities_checkParam}}(displayValue, 1) } } name: absorb_it_nspanel_entityTimer