From d2e953410ccdbb82acf95419c8da2b95d751cde7 Mon Sep 17 00:00:00 2001 From: Armilar <102996011+Armilar@users.noreply.github.com> Date: Tue, 28 Jan 2025 13:48:26 +0100 Subject: [PATCH] v4.5.0.2 - Update NsPanelTs.ts --- ioBroker/NsPanelTs.ts | 2895 ++++++++++++++++++++++------------------- 1 file changed, 1537 insertions(+), 1358 deletions(-) diff --git a/ioBroker/NsPanelTs.ts b/ioBroker/NsPanelTs.ts index 17160bc9..c9f6ebd2 100644 --- a/ioBroker/NsPanelTs.ts +++ b/ioBroker/NsPanelTs.ts @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------- -TypeScript v4.5.0.1 zur Steuerung des SONOFF NSPanel mit dem ioBroker by @Armilar / @TT-Tom / @ticaki / @Britzelpuf / @Sternmiere / @ravenS0ne +TypeScript v4.5.0.2 zur Steuerung des SONOFF NSPanel mit dem ioBroker by @Armilar / @TT-Tom / @ticaki / @Britzelpuf / @Sternmiere / @ravenS0ne - abgestimmt auf TFT 54 / v4.5.0 / BerryDriver 9 / Tasmota 14.4.1 @joBr99 Projekt: https://github.com/joBr99/nspanel-lovelace-ui/tree/main/ioBroker NsPanelTs.ts (dieses TypeScript in ioBroker) Stable: https://github.com/joBr99/nspanel-lovelace-ui/blob/main/ioBroker/NsPanelTs.ts @@ -141,6 +141,8 @@ ReleaseNotes: - 20.01.2025 - v4.4.0.14 icon3 added for use in blind for the state between 0-100 - 21.01.2025 - v4.5.0 TFT 54 / 4.5.0 - 23.01.2025 - v4.5.0.1 Change TFT URLs + - 23.01.2025 - v4.5.0.2 fix handleScreensaverUpdate => leftscreensaverEntity; fix Type leftscreensaverentitiy + - 23.01.2025 - v4.5.0.2 icon3 functionality also for thermometers and a function based on this in the screensaver Todo: - XX.12.2024 - v5.0.0 ioBroker Adapter @@ -148,8 +150,8 @@ ReleaseNotes: *************************************************************************************************************** * DE: Für die Erstellung der Aliase durch das Skript, muss in der JavaScript Instanz "setObject" gesetzt sein! * * EN: In order for the script to create the aliases, “setObject” must be set in the JavaScript instance! * -*************************************************************************************************************** - +***************************************************************************************************************{ + Wenn Rule definiert, dann können die Hardware-Tasten ebenfalls für Seitensteuerung (dann nicht mehr als Relais) genutzt werden Tasmota Konsole: @@ -253,174 +255,174 @@ var Debug: boolean = false; /***** 1. Tasmota-Config *****/ - // DE: Anpassen an die Verzeichnisse der MQTT-Adapter-Instanz - // EN: Adapt to the MQTT adapter instance directories - const NSPanelReceiveTopic: string = 'mqtt.0.SmartHome.NSPanel_1.tele.RESULT'; - const NSPanelSendTopic: string = 'mqtt.0.SmartHome.NSPanel_1.cmnd.CustomSend'; +// DE: Anpassen an die Verzeichnisse der MQTT-Adapter-Instanz +// EN: Adapt to the MQTT adapter instance directories +const NSPanelReceiveTopic: string = 'mqtt.0.SmartHome.NSPanel_1.tele.RESULT'; +const NSPanelSendTopic: string = 'mqtt.0.SmartHome.NSPanel_1.cmnd.CustomSend'; - // DE: nur ändern, falls der User im Tasmota vor dem Kompilieren umbenannt wurde (Standard Tasmota: admin) - // EN: only change if the user was renamed in Tasmota before compiling (default Tasmota: admin) - const tasmota_web_admin_user: string = 'admin'; - - // DE: setzten, falls "Web Admin Password" in Tasmota vergeben - // EN set if "Web Admin Password" is assigned in Tasmota - const tasmota_web_admin_password: string = ''; +// DE: nur ändern, falls der User im Tasmota vor dem Kompilieren umbenannt wurde (Standard Tasmota: admin) +// EN: only change if the user was renamed in Tasmota before compiling (default Tasmota: admin) +const tasmota_web_admin_user: string = 'admin'; - // DE: Setzen der bevorzugten Tasmota32-Version (für Updates) - // EN: Set preferred Tasmota32 version (for updates) - const tasmotaOtaVersion: string = 'tasmota32-DE.bin'; - // DE: Es können ebenfalls andere Versionen verwendet werden wie zum Beispiel: - // EN: Other versions can also be used, such as: - // 'tasmota32-nspanel.bin' or 'tasmota32.bin' or 'tasmota32-DE.bin' or etc. +// DE: setzten, falls "Web Admin Password" in Tasmota vergeben +// EN set if "Web Admin Password" is assigned in Tasmota +const tasmota_web_admin_password: string = ''; + +// DE: Setzen der bevorzugten Tasmota32-Version (für Updates) +// EN: Set preferred Tasmota32 version (for updates) +const tasmotaOtaVersion: string = 'tasmota32-DE.bin'; +// DE: Es können ebenfalls andere Versionen verwendet werden wie zum Beispiel: +// EN: Other versions can also be used, such as: +// 'tasmota32-nspanel.bin' or 'tasmota32.bin' or 'tasmota32-DE.bin' or etc. /***** 2. Directories in 0_userdata.0... *****/ - // DE: Anpassen an das jeweilige NSPanel - // EN: Adapt to the respective NSPanel - const NSPanel_Path = '0_userdata.0.NSPanel.1.'; +// DE: Anpassen an das jeweilige NSPanel +// EN: Adapt to the respective NSPanel +const NSPanel_Path = '0_userdata.0.NSPanel.1.'; - // DE: Pfad für gemeinsame Nutzung durch mehrere Panels (bei Nutzung der cardAlarm/cardUnlock) - // EN: Path for sharing between multiple panels (when using cardAlarm/cardUnlock) - const NSPanel_Alarm_Path = '0_userdata.0.NSPanel.'; +// DE: Pfad für gemeinsame Nutzung durch mehrere Panels (bei Nutzung der cardAlarm/cardUnlock) +// EN: Path for sharing between multiple panels (when using cardAlarm/cardUnlock) +const NSPanel_Alarm_Path = '0_userdata.0.NSPanel.'; /***** 3. Weather adapter Config *****/ - // DE: Mögliche Wetteradapter 'accuweather.0.' oder 'daswetter.0.' - // EN: Possible weather adapters 'accuweather.0.' or 'the weather.0.' - const weatherAdapterInstance: string = 'accuweather.0.'; +// DE: Mögliche Wetteradapter 'accuweather.0.' oder 'daswetter.0.' +// EN: Possible weather adapters 'accuweather.0.' or 'the weather.0.' +const weatherAdapterInstance: string = 'accuweather.0.'; - // DE: Mögliche Werte: 'Min', 'Max' oder 'MinMax' im Screensaver - // EN: Possible values: 'Min', 'Max' or 'MinMax' in the screensaver - const weatherScreensaverTempMinMax: string = 'MinMax'; +// DE: Mögliche Werte: 'Min', 'Max' oder 'MinMax' im Screensaver +// EN: Possible values: 'Min', 'Max' or 'MinMax' in the screensaver +const weatherScreensaverTempMinMax: string = 'MinMax'; - // DE: Dieser Alias wird automatisch für den gewählten Wetter erstellt und kann entsprechend angepasst werden - // EN: This alias is automatically created for the selected weather and can be adjusted accordingly - const weatherEntityPath: string = 'alias.0.Wetter'; +// DE: Dieser Alias wird automatisch für den gewählten Wetter erstellt und kann entsprechend angepasst werden +// EN: This alias is automatically created for the selected weather and can be adjusted accordingly +const weatherEntityPath: string = 'alias.0.Wetter'; /***** 4. Color constants for use in the PageItems *****/ - // DE: Bei Bedarf können weitere Farben definiert werden - // EN: If necessary, additional colors can be defined - const HMIOff: RGB = { red: 68, green: 115, blue: 158 }; // Blue-Off - Original Entity Off - const HMIOn: RGB = { red: 3, green: 169, blue: 244 }; // Blue-On - const HMIDark: RGB = { red: 29, green: 29, blue: 29 }; // Original Background Color - const Off: RGB = { red: 253, green: 128, blue: 0 }; // Orange-Off - nicer color transitions - const On: RGB = { red: 253, green: 216, blue: 53 }; - const MSRed: RGB = { red: 251, green: 105, blue: 98 }; - const MSYellow: RGB = { red: 255, green: 235, blue: 156 }; - const MSGreen: RGB = { red: 121, green: 222, blue: 121 }; - const Red: RGB = { red: 255, green: 0, blue: 0 }; - const White: RGB = { red: 255, green: 255, blue: 255 }; - const Yellow: RGB = { red: 255, green: 255, blue: 0 }; - const Green: RGB = { red: 0, green: 255, blue: 0 }; - const Blue: RGB = { red: 0, green: 0, blue: 255 }; - const DarkBlue: RGB = { red: 0, green: 0, blue: 136 }; - const Gray: RGB = { red: 136, green: 136, blue: 136 }; - const Black: RGB = { red: 0, green: 0, blue: 0 }; - const Cyan: RGB = { red: 0, green: 255, blue: 255 }; - const Magenta: RGB = { red: 255, green: 0, blue: 255 }; - const colorSpotify: RGB = { red: 30, green: 215, blue: 96 }; - const colorAlexa: RGB = { red: 49, green: 196, blue: 243 }; - const colorSonos: RGB = { red: 216, green: 161, blue: 88 }; - const colorRadio: RGB = { red: 255, green: 127, blue: 0 }; - const BatteryFull: RGB = { red: 96, green: 176, blue: 62 }; - const BatteryEmpty: RGB = { red: 179, green: 45, blue: 25 }; +// DE: Bei Bedarf können weitere Farben definiert werden +// EN: If necessary, additional colors can be defined +const HMIOff: RGB = {red: 68, green: 115, blue: 158}; // Blue-Off - Original Entity Off +const HMIOn: RGB = {red: 3, green: 169, blue: 244}; // Blue-On +const HMIDark: RGB = {red: 29, green: 29, blue: 29}; // Original Background Color +const Off: RGB = {red: 253, green: 128, blue: 0}; // Orange-Off - nicer color transitions +const On: RGB = {red: 253, green: 216, blue: 53}; +const MSRed: RGB = {red: 251, green: 105, blue: 98}; +const MSYellow: RGB = {red: 255, green: 235, blue: 156}; +const MSGreen: RGB = {red: 121, green: 222, blue: 121}; +const Red: RGB = {red: 255, green: 0, blue: 0}; +const White: RGB = {red: 255, green: 255, blue: 255}; +const Yellow: RGB = {red: 255, green: 255, blue: 0}; +const Green: RGB = {red: 0, green: 255, blue: 0}; +const Blue: RGB = {red: 0, green: 0, blue: 255}; +const DarkBlue: RGB = {red: 0, green: 0, blue: 136}; +const Gray: RGB = {red: 136, green: 136, blue: 136}; +const Black: RGB = {red: 0, green: 0, blue: 0}; +const Cyan: RGB = {red: 0, green: 255, blue: 255}; +const Magenta: RGB = {red: 255, green: 0, blue: 255}; +const colorSpotify: RGB = {red: 30, green: 215, blue: 96}; +const colorAlexa: RGB = {red: 49, green: 196, blue: 243}; +const colorSonos: RGB = {red: 216, green: 161, blue: 88}; +const colorRadio: RGB = {red: 255, green: 127, blue: 0}; +const BatteryFull: RGB = {red: 96, green: 176, blue: 62}; +const BatteryEmpty: RGB = {red: 179, green: 45, blue: 25}; - //Menu Icon Colors - const Menu: RGB = { red: 150, green: 150, blue: 100 }; - const MenuLowInd: RGB = { red: 255, green: 235, blue: 156 }; - const MenuHighInd: RGB = { red: 251, green: 105, blue: 98 }; +//Menu Icon Colors +const Menu: RGB = {red: 150, green: 150, blue: 100}; +const MenuLowInd: RGB = {red: 255, green: 235, blue: 156}; +const MenuHighInd: RGB = {red: 251, green: 105, blue: 98}; - //Dynamische Indikatoren (Abstufung grün nach gelb nach rot) - const colorScale0: RGB = { red: 99, green: 190, blue: 123 }; - const colorScale1: RGB = { red: 129, green: 199, blue: 126 }; - const colorScale2: RGB = { red: 161, green: 208, blue: 127 }; - const colorScale3: RGB = { red: 129, green: 217, blue: 126 }; - const colorScale4: RGB = { red: 222, green: 226, blue: 131 }; - const colorScale5: RGB = { red: 254, green: 235, blue: 132 }; - const colorScale6: RGB = { red: 255, green: 210, blue: 129 }; - const colorScale7: RGB = { red: 251, green: 185, blue: 124 }; - const colorScale8: RGB = { red: 251, green: 158, blue: 117 }; - const colorScale9: RGB = { red: 248, green: 131, blue: 111 }; - const colorScale10: RGB = { red: 248, green: 105, blue: 107 }; +//Dynamische Indikatoren (Abstufung grün nach gelb nach rot) +const colorScale0: RGB = {red: 99, green: 190, blue: 123}; +const colorScale1: RGB = {red: 129, green: 199, blue: 126}; +const colorScale2: RGB = {red: 161, green: 208, blue: 127}; +const colorScale3: RGB = {red: 129, green: 217, blue: 126}; +const colorScale4: RGB = {red: 222, green: 226, blue: 131}; +const colorScale5: RGB = {red: 254, green: 235, blue: 132}; +const colorScale6: RGB = {red: 255, green: 210, blue: 129}; +const colorScale7: RGB = {red: 251, green: 185, blue: 124}; +const colorScale8: RGB = {red: 251, green: 158, blue: 117}; +const colorScale9: RGB = {red: 248, green: 131, blue: 111}; +const colorScale10: RGB = {red: 248, green: 105, blue: 107}; - //Screensaver Default Theme Colors - const scbackground: RGB = { red: 0, green: 0, blue: 0}; - const scbackgroundInd1: RGB = { red: 255, green: 0, blue: 0}; - const scbackgroundInd2: RGB = { red: 121, green: 222, blue: 121}; - const scbackgroundInd3: RGB = { red: 255, green: 255, blue: 0}; - const sctime: RGB = { red: 255, green: 255, blue: 255}; - const sctimeAMPM: RGB = { red: 255, green: 255, blue: 255}; - const scdate: RGB = { red: 255, green: 255, blue: 255}; - const sctMainIcon: RGB = { red: 255, green: 255, blue: 255}; - const sctMainText: RGB = { red: 255, green: 255, blue: 255}; - const sctForecast1: RGB = { red: 255, green: 255, blue: 255}; - const sctForecast2: RGB = { red: 255, green: 255, blue: 255}; - const sctForecast3: RGB = { red: 255, green: 255, blue: 255}; - const sctForecast4: RGB = { red: 255, green: 255, blue: 255}; - const sctF1Icon: RGB = { red: 255, green: 235, blue: 156}; - const sctF2Icon: RGB = { red: 255, green: 235, blue: 156}; - const sctF3Icon: RGB = { red: 255, green: 235, blue: 156}; - const sctF4Icon: RGB = { red: 255, green: 235, blue: 156}; - const sctForecast1Val: RGB = { red: 255, green: 255, blue: 255}; - const sctForecast2Val: RGB = { red: 255, green: 255, blue: 255}; - const sctForecast3Val: RGB = { red: 255, green: 255, blue: 255}; - const sctForecast4Val: RGB = { red: 255, green: 255, blue: 255}; - const scbar: RGB = { red: 255, green: 255, blue: 255}; - const sctMainIconAlt: RGB = { red: 255, green: 255, blue: 255}; - const sctMainTextAlt: RGB = { red: 255, green: 255, blue: 255}; - const sctTimeAdd: RGB = { red: 255, green: 255, blue: 255}; +//Screensaver Default Theme Colors +const scbackground: RGB = {red: 0, green: 0, blue: 0}; +const scbackgroundInd1: RGB = {red: 255, green: 0, blue: 0}; +const scbackgroundInd2: RGB = {red: 121, green: 222, blue: 121}; +const scbackgroundInd3: RGB = {red: 255, green: 255, blue: 0}; +const sctime: RGB = {red: 255, green: 255, blue: 255}; +const sctimeAMPM: RGB = {red: 255, green: 255, blue: 255}; +const scdate: RGB = {red: 255, green: 255, blue: 255}; +const sctMainIcon: RGB = {red: 255, green: 255, blue: 255}; +const sctMainText: RGB = {red: 255, green: 255, blue: 255}; +const sctForecast1: RGB = {red: 255, green: 255, blue: 255}; +const sctForecast2: RGB = {red: 255, green: 255, blue: 255}; +const sctForecast3: RGB = {red: 255, green: 255, blue: 255}; +const sctForecast4: RGB = {red: 255, green: 255, blue: 255}; +const sctF1Icon: RGB = {red: 255, green: 235, blue: 156}; +const sctF2Icon: RGB = {red: 255, green: 235, blue: 156}; +const sctF3Icon: RGB = {red: 255, green: 235, blue: 156}; +const sctF4Icon: RGB = {red: 255, green: 235, blue: 156}; +const sctForecast1Val: RGB = {red: 255, green: 255, blue: 255}; +const sctForecast2Val: RGB = {red: 255, green: 255, blue: 255}; +const sctForecast3Val: RGB = {red: 255, green: 255, blue: 255}; +const sctForecast4Val: RGB = {red: 255, green: 255, blue: 255}; +const scbar: RGB = {red: 255, green: 255, blue: 255}; +const sctMainIconAlt: RGB = {red: 255, green: 255, blue: 255}; +const sctMainTextAlt: RGB = {red: 255, green: 255, blue: 255}; +const sctTimeAdd: RGB = {red: 255, green: 255, blue: 255}; - //Auto-Weather-Colors - const swClearNight: RGB = { red: 150, green: 150, blue: 100}; - const swCloudy: RGB = { red: 75, green: 75, blue: 75}; - const swExceptional: RGB = { red: 255, green: 50, blue: 50}; - const swFog: RGB = { red: 150, green: 150, blue: 150}; - const swHail: RGB = { red: 200, green: 200, blue: 200}; - const swLightning: RGB = { red: 200, green: 200, blue: 0}; - const swLightningRainy: RGB = { red: 200, green: 200, blue: 150}; - const swPartlycloudy: RGB = { red: 150, green: 150, blue: 150}; - const swPouring: RGB = { red: 50, green: 50, blue: 255}; - const swRainy: RGB = { red: 100, green: 100, blue: 255}; - const swSnowy: RGB = { red: 150, green: 150, blue: 150}; - const swSnowyRainy: RGB = { red: 150, green: 150, blue: 255}; - const swSunny: RGB = { red: 255, green: 255, blue: 0}; - const swWindy: RGB = { red: 150, green: 150, blue: 150}; +//Auto-Weather-Colors +const swClearNight: RGB = {red: 150, green: 150, blue: 100}; +const swCloudy: RGB = {red: 75, green: 75, blue: 75}; +const swExceptional: RGB = {red: 255, green: 50, blue: 50}; +const swFog: RGB = {red: 150, green: 150, blue: 150}; +const swHail: RGB = {red: 200, green: 200, blue: 200}; +const swLightning: RGB = {red: 200, green: 200, blue: 0}; +const swLightningRainy: RGB = {red: 200, green: 200, blue: 150}; +const swPartlycloudy: RGB = {red: 150, green: 150, blue: 150}; +const swPouring: RGB = {red: 50, green: 50, blue: 255}; +const swRainy: RGB = {red: 100, green: 100, blue: 255}; +const swSnowy: RGB = {red: 150, green: 150, blue: 150}; +const swSnowyRainy: RGB = {red: 150, green: 150, blue: 255}; +const swSunny: RGB = {red: 255, green: 255, blue: 0}; +const swWindy: RGB = {red: 150, green: 150, blue: 150}; /***** 5. Script - Parameters *****/ - - // DE: Für diese Option muss der Haken in setObjects in deiner javascript.X. Instanz gesetzt sein. - // EN: This option requires the check mark in setObjects in your javascript.X. instance must be set. - const autoCreateAlias = true; - // DE: Verzeichnis für Auto-Aliase (wird per Default aus dem NSPanel-Verzeichnis gebildet und muss nicht verändert werden) - // EN: Directory for auto aliases (is created by default from the NSPanel directory and does not need to be changed) - const AliasPath: string = 'alias.0.' + NSPanel_Path.substring(13, NSPanel_Path.length); +// DE: Für diese Option muss der Haken in setObjects in deiner javascript.X. Instanz gesetzt sein. +// EN: This option requires the check mark in setObjects in your javascript.X. instance must be set. +const autoCreateAlias = true; - // DE: Default-Farbe für Off-Zustände - // EN: Default color for off states - const defaultOffColorParam: any = Off; - - // DE: Default-Farbe für On-Zustände - // EN: Default color for on states - const defaultOnColorParam: any = On; +// DE: Verzeichnis für Auto-Aliase (wird per Default aus dem NSPanel-Verzeichnis gebildet und muss nicht verändert werden) +// EN: Directory for auto aliases (is created by default from the NSPanel directory and does not need to be changed) +const AliasPath: string = 'alias.0.' + NSPanel_Path.substring(13, NSPanel_Path.length); - const defaultColorParam: any = Off; - - // DE: Default-Hintergrundfarbe HMIDark oder Black - // EN: Default background color HMIDark or Black - const defaultBackgroundColorParam: any = HMIDark; +// DE: Default-Farbe für Off-Zustände +// EN: Default color for off states +const defaultOffColorParam: any = Off; + +// DE: Default-Farbe für On-Zustände +// EN: Default color for on states +const defaultOnColorParam: any = On; + +const defaultColorParam: any = Off; + +// DE: Default-Hintergrundfarbe HMIDark oder Black +// EN: Default background color HMIDark or Black +const defaultBackgroundColorParam: any = HMIDark; /******************************** End CONFIG Parameter ********************************/ //-- Anfang für eigene Seiten -- z.T. selbstdefinierte Aliase erforderlich ---------------- //-- Start for your own pages -- some self-defined aliases required ---------------- - //-- https://github.com/joBr99/nspanel-lovelace-ui/wiki/NSPanel-Page-%E2%80%90-Typen_How-2_Beispiele +//-- https://github.com/joBr99/nspanel-lovelace-ui/wiki/NSPanel-Page-%E2%80%90-Typen_How-2_Beispiele //-- ENDE für eigene Seiten -- z.T. selbstdefinierte Aliase erforderlich ------------------------- //-- END for your own pages -- some self-defined aliases required ------------------------ @@ -436,7 +438,7 @@ var Debug: boolean = false; Für diesen Fall ist folgende Vorgehensweise erforderlich: - cardUnlock Seite "Unlock_Service" in der Config unter pages auskommentieren ("//" entfernen) - Servicemenü aus pages "NSPanel_Service" unter pages kommentieren ("//" hinzufügen) -*/ +*/ /************************************************************************************************* ** Service pages with auto alias (subsequent pages are automatically created with alias) ** @@ -451,377 +453,383 @@ var Debug: boolean = false; */ //Level 0 (if service pages are used with cardUnlock) -let Unlock_Service: PageType = +let Unlock_Service: PageType = { 'type': 'cardUnlock', 'heading': findLocaleServMenu('service_pages'), 'useColor': true, - 'items': [/*PageItem*/{ id: 'alias.0.NSPanel.Unlock', - targetPage: 'NSPanel_Service_SubPage', - autoCreateALias: true } + 'items': [/*PageItem*/{ + id: 'alias.0.NSPanel.Unlock', + targetPage: 'NSPanel_Service_SubPage', + autoCreateALias: true + } ] }; //Level_0 (if service pages are used without cardUnlock) -let NSPanel_Service: PageType = +let NSPanel_Service: PageType = { 'type': 'cardEntities', 'heading': findLocaleServMenu('service_menu'), 'useColor': true, 'items': [ - /*PageItem*/{ navigate: true, id: 'NSPanel_Infos', icon: 'information-outline', offColor: Menu, onColor: Menu, name: findLocaleServMenu('infos'), buttonText: findLocaleServMenu('more')}, - /*PageItem*/{ navigate: true, id: 'NSPanel_Einstellungen', icon: 'monitor-edit', offColor: Menu, onColor: Menu, name: findLocaleServMenu('settings'), buttonText: findLocaleServMenu('more')}, - /*PageItem*/{ navigate: true, id: 'NSPanel_Firmware', icon: 'update', offColor: Menu, onColor: Menu, name: findLocaleServMenu('firmware'), buttonText: findLocaleServMenu('more')}, - /*PageItem*/{ id: AliasPath + 'Config.rebootNSPanel', name: findLocaleServMenu('reboot') ,icon: 'refresh', offColor: MSRed, onColor: MSGreen, buttonText: findLocaleServMenu('start')}, + /*PageItem*/{navigate: true, id: 'NSPanel_Infos', icon: 'information-outline', offColor: Menu, onColor: Menu, name: findLocaleServMenu('infos'), buttonText: findLocaleServMenu('more')}, + /*PageItem*/{navigate: true, id: 'NSPanel_Einstellungen', icon: 'monitor-edit', offColor: Menu, onColor: Menu, name: findLocaleServMenu('settings'), buttonText: findLocaleServMenu('more')}, + /*PageItem*/{navigate: true, id: 'NSPanel_Firmware', icon: 'update', offColor: Menu, onColor: Menu, name: findLocaleServMenu('firmware'), buttonText: findLocaleServMenu('more')}, + /*PageItem*/{id: AliasPath + 'Config.rebootNSPanel', name: findLocaleServMenu('reboot'), icon: 'refresh', offColor: MSRed, onColor: MSGreen, buttonText: findLocaleServMenu('start')}, ] }; //Level_0 (if service pages are used with cardUnlock) -let NSPanel_Service_SubPage: PageType = +let NSPanel_Service_SubPage: PageType = { 'type': 'cardEntities', 'heading': findLocaleServMenu('service_menu'), 'useColor': true, 'subPage': true, 'parent': Unlock_Service, - 'home': 'Unlock_Service', + 'home': 'Unlock_Service', 'items': [ - /*PageItem*/{ navigate: true, id: 'NSPanel_Infos', icon: 'information-outline', offColor: Menu, onColor: Menu, name: findLocaleServMenu('infos'), buttonText: findLocaleServMenu('more')}, - /*PageItem*/{ navigate: true, id: 'NSPanel_Einstellungen', icon: 'monitor-edit', offColor: Menu, onColor: Menu, name: findLocaleServMenu('settings'), buttonText: findLocaleServMenu('more')}, - /*PageItem*/{ navigate: true, id: 'NSPanel_Firmware', icon: 'update', offColor: Menu, onColor: Menu, name: findLocaleServMenu('firmware'), buttonText: findLocaleServMenu('more')}, - /*PageItem*/{ id: AliasPath + 'Config.rebootNSPanel', name: findLocaleServMenu('reboot') ,icon: 'refresh', offColor: MSRed, onColor: MSGreen, buttonText: findLocaleServMenu('start')}, + /*PageItem*/{navigate: true, id: 'NSPanel_Infos', icon: 'information-outline', offColor: Menu, onColor: Menu, name: findLocaleServMenu('infos'), buttonText: findLocaleServMenu('more')}, + /*PageItem*/{navigate: true, id: 'NSPanel_Einstellungen', icon: 'monitor-edit', offColor: Menu, onColor: Menu, name: findLocaleServMenu('settings'), buttonText: findLocaleServMenu('more')}, + /*PageItem*/{navigate: true, id: 'NSPanel_Firmware', icon: 'update', offColor: Menu, onColor: Menu, name: findLocaleServMenu('firmware'), buttonText: findLocaleServMenu('more')}, + /*PageItem*/{id: AliasPath + 'Config.rebootNSPanel', name: findLocaleServMenu('reboot'), icon: 'refresh', offColor: MSRed, onColor: MSGreen, buttonText: findLocaleServMenu('start')}, ] }; - //Level_1 - let NSPanel_Infos: PageType = - { - 'type': 'cardEntities', - 'heading': findLocaleServMenu('nspanel_infos'), - 'useColor': true, - 'subPage': true, - 'parent': NSPanel_Service, - 'home': 'NSPanel_Service', - 'items': [ - /*PageItem*/{ navigate: true, id: 'NSPanel_Wifi_Info_1', icon: 'wifi', offColor: Menu, onColor: Menu, name: findLocaleServMenu('wifi'), buttonText: findLocaleServMenu('more')}, - /*PageItem*/{ navigate: true, id: 'NSPanel_Sensoren', icon: 'memory', offColor: Menu, onColor: Menu, name: findLocaleServMenu('sensors_hardware'), buttonText: findLocaleServMenu('more')}, - /*PageItem*/{ navigate: true, id: 'NSPanel_IoBroker', icon: 'information-outline', offColor: Menu, onColor: Menu, name: findLocaleServMenu('info_iobroker'), buttonText: findLocaleServMenu('more')}, - /*PageItem*/{ id: AliasPath + 'Config.Update.UpdateMessage', name: findLocaleServMenu('update_message') ,icon: 'message-alert-outline', offColor: HMIOff, onColor: MSGreen}, - ] - }; - //Level_2 - let NSPanel_Wifi_Info_1: PageType = - { - 'type': 'cardEntities', - 'heading': findLocaleServMenu('nspanel_wifi1'), - 'useColor': true, - 'subPage': true, - 'parent': NSPanel_Infos, - 'next': 'NSPanel_Wifi_Info_2', - 'items': [ - /*PageItem*/{ id: AliasPath + 'ipAddress', name: findLocaleServMenu('ip_address'), icon: 'ip-network-outline', offColor: Menu, onColor: Menu }, - /*PageItem*/{ id: AliasPath + 'Tasmota.Wifi.BSSId', name: findLocaleServMenu('mac_address'), icon: 'check-network', offColor: Menu, onColor: Menu }, - /*PageItem*/{ id: AliasPath + 'Tasmota.Wifi.RSSI', name: findLocaleServMenu('rssi'), icon: 'signal', unit: '%', colorScale: {'val_min': 100, 'val_max': 0} }, - /*PageItem*/{ id: AliasPath + 'Tasmota.Wifi.Signal', name: findLocaleServMenu('wifi_signal'), icon: 'signal-distance-variant', unit: 'dBm', colorScale: {'val_min': 0, 'val_max': -100} }, - ] - }; +//Level_1 +let NSPanel_Infos: PageType = +{ + 'type': 'cardEntities', + 'heading': findLocaleServMenu('nspanel_infos'), + 'useColor': true, + 'subPage': true, + 'parent': NSPanel_Service, + 'home': 'NSPanel_Service', + 'items': [ + /*PageItem*/{navigate: true, id: 'NSPanel_Wifi_Info_1', icon: 'wifi', offColor: Menu, onColor: Menu, name: findLocaleServMenu('wifi'), buttonText: findLocaleServMenu('more')}, + /*PageItem*/{navigate: true, id: 'NSPanel_Sensoren', icon: 'memory', offColor: Menu, onColor: Menu, name: findLocaleServMenu('sensors_hardware'), buttonText: findLocaleServMenu('more')}, + /*PageItem*/{navigate: true, id: 'NSPanel_IoBroker', icon: 'information-outline', offColor: Menu, onColor: Menu, name: findLocaleServMenu('info_iobroker'), buttonText: findLocaleServMenu('more')}, + /*PageItem*/{id: AliasPath + 'Config.Update.UpdateMessage', name: findLocaleServMenu('update_message'), icon: 'message-alert-outline', offColor: HMIOff, onColor: MSGreen}, + ] +}; +//Level_2 +let NSPanel_Wifi_Info_1: PageType = +{ + 'type': 'cardEntities', + 'heading': findLocaleServMenu('nspanel_wifi1'), + 'useColor': true, + 'subPage': true, + 'parent': NSPanel_Infos, + 'next': 'NSPanel_Wifi_Info_2', + 'items': [ + /*PageItem*/{id: AliasPath + 'ipAddress', name: findLocaleServMenu('ip_address'), icon: 'ip-network-outline', offColor: Menu, onColor: Menu}, + /*PageItem*/{id: AliasPath + 'Tasmota.Wifi.BSSId', name: findLocaleServMenu('mac_address'), icon: 'check-network', offColor: Menu, onColor: Menu}, + /*PageItem*/{id: AliasPath + 'Tasmota.Wifi.RSSI', name: findLocaleServMenu('rssi'), icon: 'signal', unit: '%', colorScale: {'val_min': 100, 'val_max': 0}}, + /*PageItem*/{id: AliasPath + 'Tasmota.Wifi.Signal', name: findLocaleServMenu('wifi_signal'), icon: 'signal-distance-variant', unit: 'dBm', colorScale: {'val_min': 0, 'val_max': -100}}, + ] +}; - let NSPanel_Wifi_Info_2: PageType = - { - 'type': 'cardEntities', - 'heading': findLocaleServMenu('nspanel_wifi2'), - 'useColor': true, - 'subPage': true, - 'prev': 'NSPanel_Wifi_Info_1', - 'home': 'NSPanel_Service', - 'items': [ - /*PageItem*/{ id: AliasPath + 'Tasmota.Wifi.SSId', name: findLocaleServMenu('ssid'), icon: 'signal-distance-variant', offColor: Menu, onColor: Menu }, - /*PageItem*/{ id: AliasPath + 'Tasmota.Wifi.Mode', name: findLocaleServMenu('mode'), icon: 'signal-distance-variant', offColor: Menu, onColor: Menu }, - /*PageItem*/{ id: AliasPath + 'Tasmota.Wifi.Channel', name: findLocaleServMenu('channel'), icon: 'timeline-clock-outline', offColor: Menu, onColor: Menu }, - /*PageItem*/{ id: AliasPath + 'Tasmota.Wifi.AP', name: findLocaleServMenu('accesspoint'), icon: 'router-wireless-settings', offColor: Menu, onColor: Menu }, - ] - }; +let NSPanel_Wifi_Info_2: PageType = +{ + 'type': 'cardEntities', + 'heading': findLocaleServMenu('nspanel_wifi2'), + 'useColor': true, + 'subPage': true, + 'prev': 'NSPanel_Wifi_Info_1', + 'home': 'NSPanel_Service', + 'items': [ + /*PageItem*/{id: AliasPath + 'Tasmota.Wifi.SSId', name: findLocaleServMenu('ssid'), icon: 'signal-distance-variant', offColor: Menu, onColor: Menu}, + /*PageItem*/{id: AliasPath + 'Tasmota.Wifi.Mode', name: findLocaleServMenu('mode'), icon: 'signal-distance-variant', offColor: Menu, onColor: Menu}, + /*PageItem*/{id: AliasPath + 'Tasmota.Wifi.Channel', name: findLocaleServMenu('channel'), icon: 'timeline-clock-outline', offColor: Menu, onColor: Menu}, + /*PageItem*/{id: AliasPath + 'Tasmota.Wifi.AP', name: findLocaleServMenu('accesspoint'), icon: 'router-wireless-settings', offColor: Menu, onColor: Menu}, + ] +}; - let NSPanel_Sensoren: PageType = - { - 'type': 'cardEntities', - 'heading': findLocaleServMenu('sensors1'), - 'useColor': true, - 'subPage': true, - 'parent': NSPanel_Infos, - 'next': 'NSPanel_Hardware', - 'items': [ - /*PageItem*/{ id: AliasPath + 'Sensor.ANALOG.Temperature', name: findLocaleServMenu('room_temperature'), icon: 'home-thermometer-outline', unit: '°C', colorScale: {'val_min': 0, 'val_max': 40, 'val_best': 22 } }, - /*PageItem*/{ id: AliasPath + 'Sensor.ESP32.Temperature', name: findLocaleServMenu('esp_temperature'), icon: 'thermometer', unit: '°C', colorScale: {'val_min': 0, 'val_max': 100, 'val_best': 50 } }, - /*PageItem*/{ id: AliasPath + 'Sensor.TempUnit', name: findLocaleServMenu('temperature_unit'), icon: 'temperature-celsius', offColor: Menu, onColor: Menu }, - /*PageItem*/{ id: AliasPath + 'Sensor.Time', name: findLocaleServMenu('refresh'), icon: 'clock-check-outline', offColor: Menu, onColor: Menu }, - ] - }; +let NSPanel_Sensoren: PageType = +{ + 'type': 'cardEntities', + 'heading': findLocaleServMenu('sensors1'), + 'useColor': true, + 'subPage': true, + 'parent': NSPanel_Infos, + 'next': 'NSPanel_Hardware', + 'items': [ + /*PageItem*/{id: AliasPath + 'Sensor.ANALOG.Temperature', name: findLocaleServMenu('room_temperature'), icon: 'home-thermometer-outline', unit: '°C', colorScale: {'val_min': 0, 'val_max': 40, 'val_best': 22}}, + /*PageItem*/{id: AliasPath + 'Sensor.ESP32.Temperature', name: findLocaleServMenu('esp_temperature'), icon: 'thermometer', unit: '°C', colorScale: {'val_min': 0, 'val_max': 100, 'val_best': 50}}, + /*PageItem*/{id: AliasPath + 'Sensor.TempUnit', name: findLocaleServMenu('temperature_unit'), icon: 'temperature-celsius', offColor: Menu, onColor: Menu}, + /*PageItem*/{id: AliasPath + 'Sensor.Time', name: findLocaleServMenu('refresh'), icon: 'clock-check-outline', offColor: Menu, onColor: Menu}, + ] +}; - let NSPanel_Hardware: PageType = - { - 'type': 'cardEntities', - 'heading': findLocaleServMenu('hardware2'), - 'useColor': true, - 'subPage': true, - 'prev': 'NSPanel_Sensoren', - 'home': 'NSPanel_Service', - 'items': [ - /*PageItem*/{ id: AliasPath + 'Tasmota.Product', name: findLocaleServMenu('product'), icon: 'devices', offColor: Menu, onColor: Menu }, - /*PageItem*/{ id: AliasPath + 'Tasmota.Hardware', name: findLocaleServMenu('esp32_hardware'), icon: 'memory', offColor: Menu, onColor: Menu }, - /*PageItem*/{ id: AliasPath + 'Display.Model', name: findLocaleServMenu('nspanel_version'), offColor: Menu, onColor: Menu }, - /*PageItem*/{ id: AliasPath + 'Tasmota.Uptime', name: findLocaleServMenu('operating_time'), icon: 'timeline-clock-outline', offColor: Menu, onColor: Menu }, - ] - }; +let NSPanel_Hardware: PageType = +{ + 'type': 'cardEntities', + 'heading': findLocaleServMenu('hardware2'), + 'useColor': true, + 'subPage': true, + 'prev': 'NSPanel_Sensoren', + 'home': 'NSPanel_Service', + 'items': [ + /*PageItem*/{id: AliasPath + 'Tasmota.Product', name: findLocaleServMenu('product'), icon: 'devices', offColor: Menu, onColor: Menu}, + /*PageItem*/{id: AliasPath + 'Tasmota.Hardware', name: findLocaleServMenu('esp32_hardware'), icon: 'memory', offColor: Menu, onColor: Menu}, + /*PageItem*/{id: AliasPath + 'Display.Model', name: findLocaleServMenu('nspanel_version'), offColor: Menu, onColor: Menu}, + /*PageItem*/{id: AliasPath + 'Tasmota.Uptime', name: findLocaleServMenu('operating_time'), icon: 'timeline-clock-outline', offColor: Menu, onColor: Menu}, + ] +}; - let NSPanel_IoBroker: PageType = - { - 'type': 'cardEntities', - 'heading': findLocaleServMenu('info_iobroker'), - 'useColor': true, - 'subPage': true, - 'parent': NSPanel_Infos, - 'home': 'NSPanel_Service', - 'items': [ - /*PageItem*/{ id: AliasPath + 'IoBroker.ScriptVersion', name: findLocaleServMenu('script_version_nspanelts'), offColor: Menu, onColor: Menu }, - /*PageItem*/{ id: AliasPath + 'IoBroker.NodeJSVersion', name: findLocaleServMenu('nodejs_version'), offColor: Menu, onColor: Menu }, - /*PageItem*/{ id: AliasPath + 'IoBroker.JavaScriptVersion', name: findLocaleServMenu('instance_javascript'), offColor: Menu, onColor: Menu }, - /*PageItem*/{ id: AliasPath + 'IoBroker.ScriptName', name: findLocaleServMenu('scriptname'), offColor: Menu, onColor: Menu }, - ] - }; +let NSPanel_IoBroker: PageType = +{ + 'type': 'cardEntities', + 'heading': findLocaleServMenu('info_iobroker'), + 'useColor': true, + 'subPage': true, + 'parent': NSPanel_Infos, + 'home': 'NSPanel_Service', + 'items': [ + /*PageItem*/{id: AliasPath + 'IoBroker.ScriptVersion', name: findLocaleServMenu('script_version_nspanelts'), offColor: Menu, onColor: Menu}, + /*PageItem*/{id: AliasPath + 'IoBroker.NodeJSVersion', name: findLocaleServMenu('nodejs_version'), offColor: Menu, onColor: Menu}, + /*PageItem*/{id: AliasPath + 'IoBroker.JavaScriptVersion', name: findLocaleServMenu('instance_javascript'), offColor: Menu, onColor: Menu}, + /*PageItem*/{id: AliasPath + 'IoBroker.ScriptName', name: findLocaleServMenu('scriptname'), offColor: Menu, onColor: Menu}, + ] +}; - //Level_1 - let NSPanel_Einstellungen: PageType = - { - 'type': 'cardGrid', - 'heading': findLocaleServMenu('settings'), - 'useColor': true, - 'subPage': true, - 'parent': NSPanel_Service, - 'home': 'NSPanel_Service', - 'items': [ - /*PageItem*/{ navigate: true, id: 'NSPanel_Screensaver', icon: 'monitor-dashboard',offColor: Menu, onColor: Menu, name: findLocaleServMenu('screensaver'), buttonText: findLocaleServMenu('more')}, - /*PageItem*/{ navigate: true, id: 'NSPanel_Relays', icon: 'electric-switch', offColor: Menu, onColor: Menu, name: findLocaleServMenu('relays'), buttonText: findLocaleServMenu('more')}, - /*PageItem*/{ id:AliasPath + 'Config.temperatureUnitNumber', icon: 'gesture-double-tap', name: findLocaleServMenu('temp_unit'), offColor: Menu, onColor: Menu, - modeList: ['°C', '°F', 'K']}, - /*PageItem*/{ id: AliasPath + 'Config.localeNumber', icon: 'select-place', name: findLocaleServMenu('language'), offColor: Menu, onColor: Menu, - modeList: ['en-US', 'de-DE', 'nl-NL', 'da-DK', 'es-ES', 'fr-FR', 'it-IT', 'ru-RU', 'nb-NO', 'nn-NO', 'pl-PL', 'pt-PT', 'af-ZA', 'ar-SY', - 'bg-BG', 'ca-ES', 'cs-CZ', 'el-GR', 'et-EE', 'fa-IR', 'fi-FI', 'he-IL', 'hr-xx', 'hu-HU', 'hy-AM', 'id-ID', 'is-IS', 'lb-xx', - 'lt-LT', 'ro-RO', 'sk-SK', 'sl-SI', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA', 'vi-VN', 'zh-CN', 'zh-TW']}, - /*PageItem*/{ navigate: true, id: 'NSPanel_Script', icon: 'code-json',offColor: Menu, onColor: Menu, name: findLocaleServMenu('script'), buttonText: findLocaleServMenu('more')}, - ] - }; +//Level_1 +let NSPanel_Einstellungen: PageType = +{ + 'type': 'cardGrid', + 'heading': findLocaleServMenu('settings'), + 'useColor': true, + 'subPage': true, + 'parent': NSPanel_Service, + 'home': 'NSPanel_Service', + 'items': [ + /*PageItem*/{navigate: true, id: 'NSPanel_Screensaver', icon: 'monitor-dashboard', offColor: Menu, onColor: Menu, name: findLocaleServMenu('screensaver'), buttonText: findLocaleServMenu('more')}, + /*PageItem*/{navigate: true, id: 'NSPanel_Relays', icon: 'electric-switch', offColor: Menu, onColor: Menu, name: findLocaleServMenu('relays'), buttonText: findLocaleServMenu('more')}, + /*PageItem*/{ + id: AliasPath + 'Config.temperatureUnitNumber', icon: 'gesture-double-tap', name: findLocaleServMenu('temp_unit'), offColor: Menu, onColor: Menu, + modeList: ['°C', '°F', 'K'] + }, + /*PageItem*/{ + id: AliasPath + 'Config.localeNumber', icon: 'select-place', name: findLocaleServMenu('language'), offColor: Menu, onColor: Menu, + modeList: ['en-US', 'de-DE', 'nl-NL', 'da-DK', 'es-ES', 'fr-FR', 'it-IT', 'ru-RU', 'nb-NO', 'nn-NO', 'pl-PL', 'pt-PT', 'af-ZA', 'ar-SY', + 'bg-BG', 'ca-ES', 'cs-CZ', 'el-GR', 'et-EE', 'fa-IR', 'fi-FI', 'he-IL', 'hr-xx', 'hu-HU', 'hy-AM', 'id-ID', 'is-IS', 'lb-xx', + 'lt-LT', 'ro-RO', 'sk-SK', 'sl-SI', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA', 'vi-VN', 'zh-CN', 'zh-TW'] + }, + /*PageItem*/{navigate: true, id: 'NSPanel_Script', icon: 'code-json', offColor: Menu, onColor: Menu, name: findLocaleServMenu('script'), buttonText: findLocaleServMenu('more')}, + ] +}; - //Level_2 - let NSPanel_Screensaver: PageType = - { - 'type': 'cardGrid', - 'heading': findLocaleServMenu('screensaver'), - 'useColor': true, - 'subPage': true, - 'parent': NSPanel_Einstellungen, - 'home': 'NSPanel_Service', - 'items': [ - /*PageItem*/{ navigate: true, id: 'NSPanel_ScreensaverDimmode', icon: 'sun-clock', offColor: Menu, onColor: Menu, name: findLocaleServMenu('dimmode')}, - /*PageItem*/{ navigate: true, id: 'NSPanel_ScreensaverBrightness', icon: 'brightness-5', offColor: Menu, onColor: Menu, name: findLocaleServMenu('brightness')}, - /*PageItem*/{ navigate: true, id: 'NSPanel_ScreensaverLayout', icon: 'page-next-outline', offColor: Menu, onColor: Menu, name: findLocaleServMenu('layout')}, - /*PageItem*/{ navigate: true, id: 'NSPanel_ScreensaverWeather', icon: 'weather-partly-rainy', offColor: Menu, onColor: Menu, name: findLocaleServMenu('weather')}, - /*PageItem*/{ navigate: true, id: 'NSPanel_ScreensaverDateformat', icon: 'calendar-expand-horizontal', offColor: Menu, onColor: Menu, name: findLocaleServMenu('date_format')}, - /*PageItem*/{ navigate: true, id: 'NSPanel_ScreensaverIndicators', icon: 'monitor-edit', offColor: Menu, onColor: Menu, name: findLocaleServMenu('indicators')} - ] - }; - - //Level_3 - let NSPanel_ScreensaverDimmode: PageType = - { - 'type': 'cardEntities', - 'heading': findLocaleServMenu('dimmode'), - 'useColor': true, - 'subPage': true, - 'parent': NSPanel_Screensaver, - 'home': 'NSPanel_Service', - 'items': [ - /*PageItem*/{ id: AliasPath + 'Dimmode.brightnessDay', name: findLocaleServMenu('brightness_day'), icon: 'brightness-5', offColor: Menu, onColor: Menu, minValue: 5, maxValue: 10}, - /*PageItem*/{ id: AliasPath + 'Dimmode.brightnessNight', name: findLocaleServMenu('brightness_night'), icon: 'brightness-4', offColor: Menu, onColor: Menu, minValue: 0, maxValue: 4}, - /*PageItem*/{ id: AliasPath + 'Dimmode.hourDay', name: findLocaleServMenu('hour_day'), icon: 'sun-clock', offColor: Menu, onColor: Menu, minValue: 0, maxValue: 23}, - /*PageItem*/{ id: AliasPath + 'Dimmode.hourNight', name: findLocaleServMenu('hour_night'), icon: 'sun-clock-outline', offColor: Menu, onColor: Menu, minValue: 0, maxValue: 23} - ] - }; +//Level_2 +let NSPanel_Screensaver: PageType = +{ + 'type': 'cardGrid', + 'heading': findLocaleServMenu('screensaver'), + 'useColor': true, + 'subPage': true, + 'parent': NSPanel_Einstellungen, + 'home': 'NSPanel_Service', + 'items': [ + /*PageItem*/{navigate: true, id: 'NSPanel_ScreensaverDimmode', icon: 'sun-clock', offColor: Menu, onColor: Menu, name: findLocaleServMenu('dimmode')}, + /*PageItem*/{navigate: true, id: 'NSPanel_ScreensaverBrightness', icon: 'brightness-5', offColor: Menu, onColor: Menu, name: findLocaleServMenu('brightness')}, + /*PageItem*/{navigate: true, id: 'NSPanel_ScreensaverLayout', icon: 'page-next-outline', offColor: Menu, onColor: Menu, name: findLocaleServMenu('layout')}, + /*PageItem*/{navigate: true, id: 'NSPanel_ScreensaverWeather', icon: 'weather-partly-rainy', offColor: Menu, onColor: Menu, name: findLocaleServMenu('weather')}, + /*PageItem*/{navigate: true, id: 'NSPanel_ScreensaverDateformat', icon: 'calendar-expand-horizontal', offColor: Menu, onColor: Menu, name: findLocaleServMenu('date_format')}, + /*PageItem*/{navigate: true, id: 'NSPanel_ScreensaverIndicators', icon: 'monitor-edit', offColor: Menu, onColor: Menu, name: findLocaleServMenu('indicators')} + ] +}; - //Level_3 - let NSPanel_ScreensaverBrightness: PageType = - { - 'type': 'cardEntities', - 'heading': findLocaleServMenu('brightness'), - 'useColor': true, - 'subPage': true, - 'parent': NSPanel_Screensaver, - 'home': 'NSPanel_Service', - 'items': [ - /*PageItem*/{ id: AliasPath + 'ScreensaverInfo.activeBrightness', name: findLocaleServMenu('brightness_activ'), icon: 'brightness-5', offColor: Menu, onColor: Menu, minValue: 20, maxValue: 100}, - /*PageItem*/{ id: AliasPath + 'Config.Screensaver.timeoutScreensaver', name: findLocaleServMenu('screensaver_timeout'), icon: 'clock-end', offColor: Menu, onColor: Menu, minValue: 0, maxValue: 60}, - /*PageItem*/{ id: AliasPath + 'Config.Screensaver.screenSaverDoubleClick', name: findLocaleServMenu('wakeup_doublecklick') ,icon: 'gesture-two-double-tap', offColor: HMIOff, onColor: HMIOn} - ] - }; +//Level_3 +let NSPanel_ScreensaverDimmode: PageType = +{ + 'type': 'cardEntities', + 'heading': findLocaleServMenu('dimmode'), + 'useColor': true, + 'subPage': true, + 'parent': NSPanel_Screensaver, + 'home': 'NSPanel_Service', + 'items': [ + /*PageItem*/{id: AliasPath + 'Dimmode.brightnessDay', name: findLocaleServMenu('brightness_day'), icon: 'brightness-5', offColor: Menu, onColor: Menu, minValue: 5, maxValue: 10}, + /*PageItem*/{id: AliasPath + 'Dimmode.brightnessNight', name: findLocaleServMenu('brightness_night'), icon: 'brightness-4', offColor: Menu, onColor: Menu, minValue: 0, maxValue: 4}, + /*PageItem*/{id: AliasPath + 'Dimmode.hourDay', name: findLocaleServMenu('hour_day'), icon: 'sun-clock', offColor: Menu, onColor: Menu, minValue: 0, maxValue: 23}, + /*PageItem*/{id: AliasPath + 'Dimmode.hourNight', name: findLocaleServMenu('hour_night'), icon: 'sun-clock-outline', offColor: Menu, onColor: Menu, minValue: 0, maxValue: 23} + ] +}; - //Level_3 - let NSPanel_ScreensaverLayout: PageType = - { - 'type': 'cardEntities', - 'heading': findLocaleServMenu('layout'), - 'useColor': true, - 'subPage': true, - 'parent': NSPanel_Screensaver, - 'home': 'NSPanel_Service', - 'items': [ - /*PageItem*/{ id: AliasPath + 'Config.Screensaver.alternativeScreensaverLayout', name: findLocaleServMenu('alternative_layout') ,icon: 'page-previous-outline', offColor: HMIOff, onColor: HMIOn}, - /*PageItem*/{ id: AliasPath + 'Config.Screensaver.ScreensaverAdvanced', name: findLocaleServMenu('advanced_layout') ,icon: 'page-next-outline', offColor: HMIOff, onColor: HMIOn}, - /*PageItem*/{ id: AliasPath + 'Config.Screensaver.ScreensaverEasyView', name: findLocaleServMenu('easyview_layout') ,icon: 'page-next-outline', offColor: HMIOff, onColor: HMIOn}, - ] - }; +//Level_3 +let NSPanel_ScreensaverBrightness: PageType = +{ + 'type': 'cardEntities', + 'heading': findLocaleServMenu('brightness'), + 'useColor': true, + 'subPage': true, + 'parent': NSPanel_Screensaver, + 'home': 'NSPanel_Service', + 'items': [ + /*PageItem*/{id: AliasPath + 'ScreensaverInfo.activeBrightness', name: findLocaleServMenu('brightness_activ'), icon: 'brightness-5', offColor: Menu, onColor: Menu, minValue: 20, maxValue: 100}, + /*PageItem*/{id: AliasPath + 'Config.Screensaver.timeoutScreensaver', name: findLocaleServMenu('screensaver_timeout'), icon: 'clock-end', offColor: Menu, onColor: Menu, minValue: 0, maxValue: 60}, + /*PageItem*/{id: AliasPath + 'Config.Screensaver.screenSaverDoubleClick', name: findLocaleServMenu('wakeup_doublecklick'), icon: 'gesture-two-double-tap', offColor: HMIOff, onColor: HMIOn} + ] +}; - //Level_3 - let NSPanel_ScreensaverWeather: PageType = - { - 'type': 'cardEntities', - 'heading': findLocaleServMenu('weather_parameters'), - 'useColor': true, - 'subPage': true, - 'parent': NSPanel_Screensaver, - 'home': 'NSPanel_Service', - 'items': [ - /*PageItem*/{ id: AliasPath + 'ScreensaverInfo.weatherForecast', name: findLocaleServMenu('weather_forecast_offon') ,icon: 'weather-sunny-off', offColor: HMIOff, onColor: HMIOn}, - /*PageItem*/{ id: AliasPath + 'ScreensaverInfo.weatherForecastTimer', name: findLocaleServMenu('weather_forecast_change_switch') ,icon: 'devices', offColor: HMIOff, onColor: HMIOn}, - /*PageItem*/{ id: AliasPath + 'ScreensaverInfo.entityChangeTime', name: findLocaleServMenu('weather_forecast_change_time'), icon: 'cog-sync', offColor: Menu, onColor: Menu, minValue: 15, maxValue: 60}, - /*PageItem*/{ id: AliasPath + 'Config.Screensaver.autoWeatherColorScreensaverLayout', name: findLocaleServMenu('weather_forecast_icon_colors') ,icon: 'format-color-fill', offColor: HMIOff, onColor: HMIOn}, - ] - }; +//Level_3 +let NSPanel_ScreensaverLayout: PageType = +{ + 'type': 'cardEntities', + 'heading': findLocaleServMenu('layout'), + 'useColor': true, + 'subPage': true, + 'parent': NSPanel_Screensaver, + 'home': 'NSPanel_Service', + 'items': [ + /*PageItem*/{id: AliasPath + 'Config.Screensaver.alternativeScreensaverLayout', name: findLocaleServMenu('alternative_layout'), icon: 'page-previous-outline', offColor: HMIOff, onColor: HMIOn}, + /*PageItem*/{id: AliasPath + 'Config.Screensaver.ScreensaverAdvanced', name: findLocaleServMenu('advanced_layout'), icon: 'page-next-outline', offColor: HMIOff, onColor: HMIOn}, + /*PageItem*/{id: AliasPath + 'Config.Screensaver.ScreensaverEasyView', name: findLocaleServMenu('easyview_layout'), icon: 'page-next-outline', offColor: HMIOff, onColor: HMIOn}, + ] +}; - //Level_3 - let NSPanel_ScreensaverDateformat: PageType = - { - 'type': 'cardEntities', - 'heading': findLocaleServMenu('date_format'), - 'useColor': true, - 'subPage': true, - 'parent': NSPanel_Screensaver, - 'home': 'NSPanel_Service', - 'items': [ - /*PageItem*/{ id: AliasPath + 'Config.Dateformat.Switch.weekday', name: findLocaleServMenu('weekday_large') ,icon: 'calendar-expand-horizontal', offColor: HMIOff, onColor: HMIOn}, - /*PageItem*/{ id: AliasPath + 'Config.Dateformat.Switch.month', name: findLocaleServMenu('month_large') ,icon: 'calendar-expand-horizontal', offColor: HMIOff, onColor: HMIOn}, - ] - }; +//Level_3 +let NSPanel_ScreensaverWeather: PageType = +{ + 'type': 'cardEntities', + 'heading': findLocaleServMenu('weather_parameters'), + 'useColor': true, + 'subPage': true, + 'parent': NSPanel_Screensaver, + 'home': 'NSPanel_Service', + 'items': [ + /*PageItem*/{id: AliasPath + 'ScreensaverInfo.weatherForecast', name: findLocaleServMenu('weather_forecast_offon'), icon: 'weather-sunny-off', offColor: HMIOff, onColor: HMIOn}, + /*PageItem*/{id: AliasPath + 'ScreensaverInfo.weatherForecastTimer', name: findLocaleServMenu('weather_forecast_change_switch'), icon: 'devices', offColor: HMIOff, onColor: HMIOn}, + /*PageItem*/{id: AliasPath + 'ScreensaverInfo.entityChangeTime', name: findLocaleServMenu('weather_forecast_change_time'), icon: 'cog-sync', offColor: Menu, onColor: Menu, minValue: 15, maxValue: 60}, + /*PageItem*/{id: AliasPath + 'Config.Screensaver.autoWeatherColorScreensaverLayout', name: findLocaleServMenu('weather_forecast_icon_colors'), icon: 'format-color-fill', offColor: HMIOff, onColor: HMIOn}, + ] +}; - //Level_3 - let NSPanel_ScreensaverIndicators: PageType = - { - 'type': 'cardEntities', - 'heading': findLocaleServMenu('indicators'), - 'useColor': true, - 'subPage': true, - 'parent': NSPanel_Screensaver, - 'home': 'NSPanel_Service', - 'items': [ - /*PageItem*/{ id: AliasPath + 'Config.MRIcons.alternateMRIconSize.1', name: findLocaleServMenu('mr_icon1_size') ,icon: 'format-size', offColor: HMIOff, onColor: HMIOn}, - /*PageItem*/{ id: AliasPath + 'Config.MRIcons.alternateMRIconSize.2', name: findLocaleServMenu('mr_icon2_size') ,icon: 'format-size', offColor: HMIOff, onColor: HMIOn}, - ] - }; +//Level_3 +let NSPanel_ScreensaverDateformat: PageType = +{ + 'type': 'cardEntities', + 'heading': findLocaleServMenu('date_format'), + 'useColor': true, + 'subPage': true, + 'parent': NSPanel_Screensaver, + 'home': 'NSPanel_Service', + 'items': [ + /*PageItem*/{id: AliasPath + 'Config.Dateformat.Switch.weekday', name: findLocaleServMenu('weekday_large'), icon: 'calendar-expand-horizontal', offColor: HMIOff, onColor: HMIOn}, + /*PageItem*/{id: AliasPath + 'Config.Dateformat.Switch.month', name: findLocaleServMenu('month_large'), icon: 'calendar-expand-horizontal', offColor: HMIOff, onColor: HMIOn}, + ] +}; - //Level_2 - let NSPanel_Relays: PageType = - { - 'type': 'cardEntities', - 'heading': findLocaleServMenu('relays'), - 'useColor': true, - 'subPage': true, - 'parent': NSPanel_Einstellungen, - 'home': 'NSPanel_Service', - 'items': [ - /*PageItem*/{ id: AliasPath + 'Relay.1', name: findLocaleServMenu('relay1_onoff'), icon: 'power', offColor: HMIOff, onColor: HMIOn}, - /*PageItem*/{ id: AliasPath + 'Relay.2', name: findLocaleServMenu('relay2_onoff'), icon: 'power', offColor: HMIOff, onColor: HMIOn}, - ] - }; +//Level_3 +let NSPanel_ScreensaverIndicators: PageType = +{ + 'type': 'cardEntities', + 'heading': findLocaleServMenu('indicators'), + 'useColor': true, + 'subPage': true, + 'parent': NSPanel_Screensaver, + 'home': 'NSPanel_Service', + 'items': [ + /*PageItem*/{id: AliasPath + 'Config.MRIcons.alternateMRIconSize.1', name: findLocaleServMenu('mr_icon1_size'), icon: 'format-size', offColor: HMIOff, onColor: HMIOn}, + /*PageItem*/{id: AliasPath + 'Config.MRIcons.alternateMRIconSize.2', name: findLocaleServMenu('mr_icon2_size'), icon: 'format-size', offColor: HMIOff, onColor: HMIOn}, + ] +}; - //Level_2 - let NSPanel_Script: PageType = - { - 'type': 'cardEntities', - 'heading': findLocaleServMenu('script'), - 'useColor': true, - 'subPage': true, - 'parent': NSPanel_Einstellungen, - 'home': 'NSPanel_Service', - 'items': [ - /*PageItem*/{ id: AliasPath + 'Config.ScripgtDebugStatus', name: findLocaleServMenu('debugmode_offon') ,icon: 'code-tags-check', offColor: HMIOff, onColor: HMIOn}, - /*PageItem*/{ id: AliasPath + 'Config.MQTT.portCheck', name: findLocaleServMenu('port_check_offon') ,icon: 'check-network', offColor: HMIOff, onColor: HMIOn}, - /*PageItem*/{ id: AliasPath + 'Config.hiddenCards', name: findLocaleServMenu('hiddencards_offon'), icon: 'check-network', offColor: HMIOff, onColor: HMIOn }, - ] - }; +//Level_2 +let NSPanel_Relays: PageType = +{ + 'type': 'cardEntities', + 'heading': findLocaleServMenu('relays'), + 'useColor': true, + 'subPage': true, + 'parent': NSPanel_Einstellungen, + 'home': 'NSPanel_Service', + 'items': [ + /*PageItem*/{id: AliasPath + 'Relay.1', name: findLocaleServMenu('relay1_onoff'), icon: 'power', offColor: HMIOff, onColor: HMIOn}, + /*PageItem*/{id: AliasPath + 'Relay.2', name: findLocaleServMenu('relay2_onoff'), icon: 'power', offColor: HMIOff, onColor: HMIOn}, + ] +}; - //Level_1 - let NSPanel_Firmware: PageType = - { - 'type': 'cardEntities', - 'heading': findLocaleServMenu('firmware'), - 'useColor': true, - 'subPage': true, - 'parent': NSPanel_Service, - 'home': 'NSPanel_Service', - 'items': [ - /*PageItem*/{ id: AliasPath + 'autoUpdate', name: findLocaleServMenu('automatically_updates') ,icon: 'power', offColor: HMIOff, onColor: HMIOn}, - /*PageItem*/{ navigate: true, id: 'NSPanel_FirmwareTasmota', icon: 'usb-flash-drive', offColor: Menu, onColor: Menu, name: findLocaleServMenu('tasmota_firmware'), buttonText: findLocaleServMenu('more')}, - /*PageItem*/{ navigate: true, id: 'NSPanel_FirmwareBerry', icon: 'usb-flash-drive', offColor: Menu, onColor: Menu, name: findLocaleServMenu('berry_driver'), buttonText: findLocaleServMenu('more')}, - /*PageItem*/{ navigate: true, id: 'NSPanel_FirmwareNextion', icon: 'cellphone-cog', offColor: Menu, onColor: Menu, name: findLocaleServMenu('nextion_tft_firmware'), buttonText: findLocaleServMenu('more')} - ] - }; +//Level_2 +let NSPanel_Script: PageType = +{ + 'type': 'cardEntities', + 'heading': findLocaleServMenu('script'), + 'useColor': true, + 'subPage': true, + 'parent': NSPanel_Einstellungen, + 'home': 'NSPanel_Service', + 'items': [ + /*PageItem*/{id: AliasPath + 'Config.ScripgtDebugStatus', name: findLocaleServMenu('debugmode_offon'), icon: 'code-tags-check', offColor: HMIOff, onColor: HMIOn}, + /*PageItem*/{id: AliasPath + 'Config.MQTT.portCheck', name: findLocaleServMenu('port_check_offon'), icon: 'check-network', offColor: HMIOff, onColor: HMIOn}, + /*PageItem*/{id: AliasPath + 'Config.hiddenCards', name: findLocaleServMenu('hiddencards_offon'), icon: 'check-network', offColor: HMIOff, onColor: HMIOn}, + ] +}; - let NSPanel_FirmwareTasmota: PageType = - { - 'type': 'cardEntities', - 'heading': findLocaleServMenu('tasmota'), - 'useColor': true, - 'subPage': true, - 'parent': NSPanel_Firmware, - 'home': 'NSPanel_Service', - 'items': [ - /*PageItem*/{ id: AliasPath + 'Tasmota.Version', name: findLocaleServMenu('installed_release'), offColor: Menu, onColor: Menu }, - /*PageItem*/{ id: AliasPath + 'Tasmota_Firmware.onlineVersion', name: findLocaleServMenu('available_release'), offColor: Menu, onColor: Menu }, - /*PageItem*/{ id: 'Divider' }, - /*PageItem*/{ id: AliasPath + 'Config.Update.UpdateTasmota', name: findLocaleServMenu('update_tasmota') ,icon: 'refresh', offColor: HMIOff, onColor: MSGreen, buttonText: findLocaleServMenu('start')}, - ] - }; +//Level_1 +let NSPanel_Firmware: PageType = +{ + 'type': 'cardEntities', + 'heading': findLocaleServMenu('firmware'), + 'useColor': true, + 'subPage': true, + 'parent': NSPanel_Service, + 'home': 'NSPanel_Service', + 'items': [ + /*PageItem*/{id: AliasPath + 'autoUpdate', name: findLocaleServMenu('automatically_updates'), icon: 'power', offColor: HMIOff, onColor: HMIOn}, + /*PageItem*/{navigate: true, id: 'NSPanel_FirmwareTasmota', icon: 'usb-flash-drive', offColor: Menu, onColor: Menu, name: findLocaleServMenu('tasmota_firmware'), buttonText: findLocaleServMenu('more')}, + /*PageItem*/{navigate: true, id: 'NSPanel_FirmwareBerry', icon: 'usb-flash-drive', offColor: Menu, onColor: Menu, name: findLocaleServMenu('berry_driver'), buttonText: findLocaleServMenu('more')}, + /*PageItem*/{navigate: true, id: 'NSPanel_FirmwareNextion', icon: 'cellphone-cog', offColor: Menu, onColor: Menu, name: findLocaleServMenu('nextion_tft_firmware'), buttonText: findLocaleServMenu('more')} + ] +}; - let NSPanel_FirmwareBerry: PageType = - { - 'type': 'cardEntities', - 'heading': findLocaleServMenu('berry_driver'), - 'useColor': true, - 'subPage': true, - 'parent': NSPanel_Firmware, - 'home': 'NSPanel_Service', - 'items': [ - /*PageItem*/{ id: AliasPath + 'Display.BerryDriver', name: findLocaleServMenu('installed_release'), offColor: Menu, onColor: Menu }, - /*PageItem*/{ id: AliasPath + 'Berry_Driver.onlineVersion', name: findLocaleServMenu('available_release'), offColor: Menu, onColor: Menu}, - /*PageItem*/{ id: 'Divider' }, - /*PageItem*/{ id: AliasPath + 'Config.Update.UpdateBerry', name: findLocaleServMenu('update_berry_driver') ,icon: 'refresh', offColor: HMIOff, onColor: MSGreen, buttonText: findLocaleServMenu('start')}, - ] - }; +let NSPanel_FirmwareTasmota: PageType = +{ + 'type': 'cardEntities', + 'heading': findLocaleServMenu('tasmota'), + 'useColor': true, + 'subPage': true, + 'parent': NSPanel_Firmware, + 'home': 'NSPanel_Service', + 'items': [ + /*PageItem*/{id: AliasPath + 'Tasmota.Version', name: findLocaleServMenu('installed_release'), offColor: Menu, onColor: Menu}, + /*PageItem*/{id: AliasPath + 'Tasmota_Firmware.onlineVersion', name: findLocaleServMenu('available_release'), offColor: Menu, onColor: Menu}, + /*PageItem*/{id: 'Divider'}, + /*PageItem*/{id: AliasPath + 'Config.Update.UpdateTasmota', name: findLocaleServMenu('update_tasmota'), icon: 'refresh', offColor: HMIOff, onColor: MSGreen, buttonText: findLocaleServMenu('start')}, + ] +}; - let NSPanel_FirmwareNextion: PageType = - { - 'type': 'cardEntities', - 'heading': findLocaleServMenu('nextion_tft'), - 'useColor': true, - 'subPage': true, - 'parent': NSPanel_Firmware, - 'home': 'NSPanel_Service', - 'items': [ - /*PageItem*/{ id: AliasPath + 'Display_Firmware.TFT.currentVersion', name: findLocaleServMenu('installed_release'), offColor: Menu, onColor: Menu }, - /*PageItem*/{ id: AliasPath + 'Display_Firmware.TFT.desiredVersion', name: findLocaleServMenu('desired_release'), offColor: Menu, onColor: Menu }, - /*PageItem*/{ id: AliasPath + 'Display.Model', name: findLocaleServMenu('nspanel_model'), offColor: Menu, onColor: Menu }, - /*PageItem*/{ id: AliasPath + 'Config.Update.UpdateNextion', name: 'Nextion TFT Update' ,icon: 'refresh', offColor: HMIOff, onColor: MSGreen, buttonText: findLocaleServMenu('start')}, - ] - }; +let NSPanel_FirmwareBerry: PageType = +{ + 'type': 'cardEntities', + 'heading': findLocaleServMenu('berry_driver'), + 'useColor': true, + 'subPage': true, + 'parent': NSPanel_Firmware, + 'home': 'NSPanel_Service', + 'items': [ + /*PageItem*/{id: AliasPath + 'Display.BerryDriver', name: findLocaleServMenu('installed_release'), offColor: Menu, onColor: Menu}, + /*PageItem*/{id: AliasPath + 'Berry_Driver.onlineVersion', name: findLocaleServMenu('available_release'), offColor: Menu, onColor: Menu}, + /*PageItem*/{id: 'Divider'}, + /*PageItem*/{id: AliasPath + 'Config.Update.UpdateBerry', name: findLocaleServMenu('update_berry_driver'), icon: 'refresh', offColor: HMIOff, onColor: MSGreen, buttonText: findLocaleServMenu('start')}, + ] +}; + +let NSPanel_FirmwareNextion: PageType = +{ + 'type': 'cardEntities', + 'heading': findLocaleServMenu('nextion_tft'), + 'useColor': true, + 'subPage': true, + 'parent': NSPanel_Firmware, + 'home': 'NSPanel_Service', + 'items': [ + /*PageItem*/{id: AliasPath + 'Display_Firmware.TFT.currentVersion', name: findLocaleServMenu('installed_release'), offColor: Menu, onColor: Menu}, + /*PageItem*/{id: AliasPath + 'Display_Firmware.TFT.desiredVersion', name: findLocaleServMenu('desired_release'), offColor: Menu, onColor: Menu}, + /*PageItem*/{id: AliasPath + 'Display.Model', name: findLocaleServMenu('nspanel_model'), offColor: Menu, onColor: Menu}, + /*PageItem*/{id: AliasPath + 'Config.Update.UpdateNextion', name: 'Nextion TFT Update', icon: 'refresh', offColor: HMIOff, onColor: MSGreen, buttonText: findLocaleServMenu('start')}, + ] +}; // End of Service Pages @@ -873,7 +881,7 @@ export const config: Config = { leftScreensaverEntity: [ // Examples for Advanced-Screensaver: https://github.com/joBr99/nspanel-lovelace-ui/wiki/ioBroker-Config-Screensaver#entity-status-icons-ab-v400 ], - + bottomScreensaverEntity: [ // bottomScreensaverEntity 1 { @@ -969,11 +977,11 @@ export const config: Config = { ScreensaverEntityOnColor: On, ScreensaverEntityOffColor: HMIOff }, -// ------ DE: Ende der Screensaver Einstellungen -------------------- -// ------ EN: End of screensaver settings --------------------------- + // ------ DE: Ende der Screensaver Einstellungen -------------------- + // ------ EN: End of screensaver settings --------------------------- -//-------DE: Anfang Einstellungen für Hardware Button, wenn Sie softwareseitig genutzt werden (Rule2) ------------- -//-------EN: Start Settings for Hardware Button, if used in software (Rule2) -------------------------------------- + //-------DE: Anfang Einstellungen für Hardware Button, wenn Sie softwareseitig genutzt werden (Rule2) ------------- + //-------EN: Start Settings for Hardware Button, if used in software (Rule2) -------------------------------------- // DE: Konfiguration des linken Schalters des NSPanels // EN: Configuration of the left switch of the NSPanel button1: { @@ -1000,8 +1008,8 @@ export const config: Config = { setValue: null }, -//--------- DE: Ende - Einstellungen für Hardware Button, wenn Sie softwareseitig genutzt werden (Rule2) ------------- -//--------- EN: End - settings for hardware button if they are used in software (Rule2) ------------------------------ + //--------- DE: Ende - Einstellungen für Hardware Button, wenn Sie softwareseitig genutzt werden (Rule2) ------------- + //--------- EN: End - settings for hardware button if they are used in software (Rule2) ------------------------------ // DE: WICHTIG !! Parameter nicht ändern WICHTIG!! // EN: IMPORTANT !! Do not change parameters IMPORTANT!! @@ -1017,7 +1025,7 @@ export const config: Config = { // _________________________________ DE: Ab hier keine Konfiguration mehr _____________________________________ // _________________________________ EN: No more configuration from here _____________________________________ -const scriptVersion: string = 'v4.5.0.1'; +const scriptVersion: string = 'v4.5.0.2'; const tft_version: string = 'v4.5.0'; const desired_display_firmware_version = 54; const berry_driver_version = 9; @@ -1031,24 +1039,24 @@ let weatherForecast: boolean; let pageCounter: number = 0; let alwaysOn: boolean = false; let valueHiddenCards: boolean = false; -if ( existsState(NSPanel_Path + 'Config.hiddenCards')) { +if (existsState(NSPanel_Path + 'Config.hiddenCards')) { valueHiddenCards = getState(NSPanel_Path + 'Config.hiddenCards').val; } -let buttonToggleState: { [key: string]: boolean } = {}; +let buttonToggleState: {[key: string]: boolean} = {}; const axios = require('axios'); const moment = require('moment'); const parseFormat = require('moment-parseformat'); let firstRun: boolean = false; -if ( existsState(NSPanel_Path + 'Config.locale')) { +if (existsState(NSPanel_Path + 'Config.locale')) { moment.locale(getState(NSPanel_Path + 'Config.locale').val); } else { moment.locale('en-US'); firstRun = true; } -const scheduleList: { [key: string]: any } = {}; +const scheduleList: {[key: string]: any} = {}; const globalTextColor: any = White; const Sliders2: number = 0; @@ -1056,7 +1064,7 @@ let checkBlindActive: boolean = false; log('--- start of NsPanelTs: ' + NSPanel_Path + ' ---', 'info'); -async function Init_momentjs() { +async function Init_momentjs () { try { moment.locale(`'${getMomentjsLocale()}'`); @@ -1084,7 +1092,7 @@ let scheduleInitDimModeNight: any; const ScreensaverAdvancedEndPath = 'Config.Screensaver.ScreensaverAdvanced'; const ScreensaverEasyViewEndPath = 'Config.Screensaver.ScreensaverEasyView'; -onStop(function scriptStop() { +onStop(function scriptStop () { if (scheduleSendTime != null) _clearSchedule(scheduleSendTime); if (scheduleSendDate != null) _clearSchedule(scheduleSendDate); if (scheduleSwichScreensaver != null) _clearSchedule(scheduleSwichScreensaver); @@ -1100,7 +1108,7 @@ onStop(function scriptStop() { * If one is not reachable, an error message is written to the log. * @function */ -async function CheckConfigParameters() { +async function CheckConfigParameters () { try { if (existsObject(config.panelRecvTopic) == false) { log('Config-Parameter: << config.panelRecvTopic - ' + config.panelRecvTopic + ' >> is not reachable. Please Check Parameters!', 'error'); @@ -1108,14 +1116,14 @@ async function CheckConfigParameters() { if (config.panelRecvTopic.indexOf('.tele.') < 0) { log('Config-Parameter: << config.panelRecvTopic - ' + config.panelRecvTopic + ' >> does not refer to the prefix .tele. Please Check Parameters!', 'error'); } - + if (existsObject(config.panelSendTopic) == false) { const n = config.panelSendTopic.split('.'); const a = n.shift(); const i = n.shift(); if (a && a.substring(0, 4) === 'mqtt' && !isNaN(Number(i))) { - sendTo(`${a}.${i}`, 'sendMessage2Client', { topic: n.join('/'), message: buildNSPanelString('time', '12:00') }); + sendTo(`${a}.${i}`, 'sendMessage2Client', {topic: n.join('/'), message: buildNSPanelString('time', '12:00')}); await sleep(500); } if ((await existsObjectAsync(config.panelSendTopic)) == false) { @@ -1167,10 +1175,10 @@ async function CheckConfigParameters() { } }); if (config.mrIcon1ScreensaverEntity.ScreensaverEntity != null && existsObject(config.mrIcon1ScreensaverEntity.ScreensaverEntity) == false) { - if ( existsState(NSPanel_Path + 'Config')) log('mrIcon1ScreensaverEntity data point in the config not available - please adjust', 'warn'); + if (existsState(NSPanel_Path + 'Config')) log('mrIcon1ScreensaverEntity data point in the config not available - please adjust', 'warn'); } if (config.mrIcon2ScreensaverEntity.ScreensaverEntity != null && existsObject(config.mrIcon2ScreensaverEntity.ScreensaverEntity) == false) { - if ( existsState(NSPanel_Path + 'Config')) log('mrIcon2ScreensaverEntity data point in the config not available - please adjust', 'warn'); + if (existsState(NSPanel_Path + 'Config')) log('mrIcon2ScreensaverEntity data point in the config not available - please adjust', 'warn'); } if (CheckEnableSetObject()) { log('setObjects enabled - create Alias Channels possible', 'info'); @@ -1192,29 +1200,29 @@ CheckConfigParameters(); * The data points are set to read only. * @function */ -async function InitIoBrokerInfo() { +async function InitIoBrokerInfo () { try { if (isSetOptionActive) { // Script Version - await createStateAsync(NSPanel_Path + 'IoBroker.ScriptVersion', scriptVersion, { type: 'string', write: false }); - setObject(AliasPath + 'IoBroker.ScriptVersion', { type: 'channel', common: { role: 'info', name: 'Version NSPanelTS' }, native: {} }); - await createAliasAsync(AliasPath + 'IoBroker.ScriptVersion.ACTUAL', NSPanel_Path + 'IoBroker.ScriptVersion', true, { type: 'string', role: 'state', name: 'ACTUAL' }); + await createStateAsync(NSPanel_Path + 'IoBroker.ScriptVersion', scriptVersion, {type: 'string', write: false}); + setObject(AliasPath + 'IoBroker.ScriptVersion', {type: 'channel', common: {role: 'info', name: 'Version NSPanelTS'}, native: {}}); + await createAliasAsync(AliasPath + 'IoBroker.ScriptVersion.ACTUAL', NSPanel_Path + 'IoBroker.ScriptVersion', true, {type: 'string', role: 'state', name: 'ACTUAL'}); // NodeJS Verion - await createStateAsync(NSPanel_Path + 'IoBroker.NodeJSVersion', 'v' + nodeVersion, { type: 'string', write: false }); - setObject(AliasPath + 'IoBroker.NodeJSVersion', { type: 'channel', common: { role: 'info', name: 'Version NodeJS' }, native: {} }); - await createAliasAsync(AliasPath + 'IoBroker.NodeJSVersion.ACTUAL', NSPanel_Path + 'IoBroker.NodeJSVersion', true, { type: 'string', role: 'state', name: 'ACTUAL' }); + await createStateAsync(NSPanel_Path + 'IoBroker.NodeJSVersion', 'v' + nodeVersion, {type: 'string', write: false}); + setObject(AliasPath + 'IoBroker.NodeJSVersion', {type: 'channel', common: {role: 'info', name: 'Version NodeJS'}, native: {}}); + await createAliasAsync(AliasPath + 'IoBroker.NodeJSVersion.ACTUAL', NSPanel_Path + 'IoBroker.NodeJSVersion', true, {type: 'string', role: 'state', name: 'ACTUAL'}); // JavaScript Version - await createStateAsync(NSPanel_Path + 'IoBroker.JavaScriptVersion', 'v' + javaScriptVersion, { type: 'string', write: false }); - setObject(AliasPath + 'IoBroker.JavaScriptVersion', { type: 'channel', common: { role: 'info', name: 'Version JavaScript Instanz' }, native: {} }); - await createAliasAsync(AliasPath + 'IoBroker.JavaScriptVersion.ACTUAL', NSPanel_Path + 'IoBroker.JavaScriptVersion', true, { + await createStateAsync(NSPanel_Path + 'IoBroker.JavaScriptVersion', 'v' + javaScriptVersion, {type: 'string', write: false}); + setObject(AliasPath + 'IoBroker.JavaScriptVersion', {type: 'channel', common: {role: 'info', name: 'Version JavaScript Instanz'}, native: {}}); + await createAliasAsync(AliasPath + 'IoBroker.JavaScriptVersion.ACTUAL', NSPanel_Path + 'IoBroker.JavaScriptVersion', true, { type: 'string', role: 'state', name: 'ACTUAL', }); // ScriptName - await createStateAsync(NSPanel_Path + 'IoBroker.ScriptName', 'v' + NSPanel_Path + 'IoBroker.ScriptName', { type: 'string', write: false }); - setObject(AliasPath + 'IoBroker.ScriptName', { type: 'channel', common: { role: 'info', name: 'Scriptname' }, native: {} }); - await createAliasAsync(AliasPath + 'IoBroker.ScriptName.ACTUAL', NSPanel_Path + 'IoBroker.ScriptName', true, { type: 'string', role: 'state', name: 'ACTUAL' }); + await createStateAsync(NSPanel_Path + 'IoBroker.ScriptName', 'v' + NSPanel_Path + 'IoBroker.ScriptName', {type: 'string', write: false}); + setObject(AliasPath + 'IoBroker.ScriptName', {type: 'channel', common: {role: 'info', name: 'Scriptname'}, native: {}}); + await createAliasAsync(AliasPath + 'IoBroker.ScriptName.ACTUAL', NSPanel_Path + 'IoBroker.ScriptName', true, {type: 'string', role: 'state', name: 'ACTUAL'}); } setIfExists(NSPanel_Path + 'IoBroker.ScriptVersion', scriptVersion, null, true); } catch (err: any) { @@ -1232,17 +1240,17 @@ InitIoBrokerInfo(); * The state is also used to set the Debug variable to true or false. * If an error occurs, a warning is logged. */ -async function CheckDebugMode() { +async function CheckDebugMode () { try { if (isSetOptionActive) { - await createStateAsync(NSPanel_Path + 'Config.ScripgtDebugStatus', false, { type: 'boolean', write: true }); - setObject(AliasPath + 'Config.ScripgtDebugStatus', { type: 'channel', common: { role: 'socket', name: 'ScripgtDebugStatus' }, native: {} }); - await createAliasAsync(AliasPath + 'Config.ScripgtDebugStatus.ACTUAL', NSPanel_Path + 'Config.ScripgtDebugStatus', true, { + await createStateAsync(NSPanel_Path + 'Config.ScripgtDebugStatus', false, {type: 'boolean', write: true}); + setObject(AliasPath + 'Config.ScripgtDebugStatus', {type: 'channel', common: {role: 'socket', name: 'ScripgtDebugStatus'}, native: {}}); + await createAliasAsync(AliasPath + 'Config.ScripgtDebugStatus.ACTUAL', NSPanel_Path + 'Config.ScripgtDebugStatus', true, { type: 'boolean', role: 'switch', name: 'ACTUAL', }); - await createAliasAsync(AliasPath + 'Config.ScripgtDebugStatus.SET', NSPanel_Path + 'Config.ScripgtDebugStatus', true, { type: 'boolean', role: 'switch', name: 'SET' }); + await createAliasAsync(AliasPath + 'Config.ScripgtDebugStatus.SET', NSPanel_Path + 'Config.ScripgtDebugStatus', true, {type: 'boolean', role: 'switch', name: 'SET'}); } if (getState(NSPanel_Path + 'Config.ScripgtDebugStatus').val) { @@ -1263,15 +1271,15 @@ CheckDebugMode(); * If the debug mode is activated, the result of the iobroker command is logged. * If an error occurs, a warning is logged. */ -async function CheckMQTTPorts() { +async function CheckMQTTPorts () { try { let instanceName: string = (config.panelRecvTopic).split('.')[0] + "." + (config.panelRecvTopic).split('.')[1]; if (isSetOptionActive) { - await createStateAsync(NSPanel_Path + 'Config.MQTT.portCheck', true, { type: 'boolean', write: true }); - setObject(AliasPath + 'Config.MQTT.portCheck', { type: 'channel', common: { role: 'socket', name: 'mqttPortCheck' }, native: {} }); - await createAliasAsync(AliasPath + 'Config.MQTT.portCheck.ACTUAL', NSPanel_Path + 'Config.MQTT.portCheck', true, { type: 'boolean', role: 'switch', name: 'ACTUAL' }); - await createAliasAsync(AliasPath + 'Config.MQTT.portCheck.SET', NSPanel_Path + 'Config.MQTT.portCheck', true, { type: 'boolean', role: 'switch', name: 'SET' }); + await createStateAsync(NSPanel_Path + 'Config.MQTT.portCheck', true, {type: 'boolean', write: true}); + setObject(AliasPath + 'Config.MQTT.portCheck', {type: 'channel', common: {role: 'socket', name: 'mqttPortCheck'}, native: {}}); + await createAliasAsync(AliasPath + 'Config.MQTT.portCheck.ACTUAL', NSPanel_Path + 'Config.MQTT.portCheck', true, {type: 'boolean', role: 'switch', name: 'ACTUAL'}); + await createAliasAsync(AliasPath + 'Config.MQTT.portCheck.SET', NSPanel_Path + 'Config.MQTT.portCheck', true, {type: 'boolean', role: 'switch', name: 'SET'}); } if (getState(NSPanel_Path + 'Config.MQTT.portCheck').val) { @@ -1325,17 +1333,17 @@ async function CheckMQTTPorts() { } CheckMQTTPorts(); - /** - * Creates states for the current and desired TFT firmware version. - * - * @since 4.4.0 - */ -async function Init_Release() { - const FWVersion = [ 0 , 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56]; +/** + * Creates states for the current and desired TFT firmware version. + * + * @since 4.4.0 + */ +async function Init_Release () { + const FWVersion = [0, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56]; const FWRelease = ['0', '3.3.1', '3.4.0', '3.5.0', '3.5.X', '3.6.0', '3.7.3', '3.8.0', '3.8.3', '3.9.4', '4.0.5', '4.1.4', '4.2.1', '4.4.0', '4.5.0', '4.6.0', '4.6.1']; - try{ + try { if (existsObject(NSPanel_Path + 'Display_Firmware.desiredVersion') == false) { - await createStateAsync(NSPanel_Path + 'Display_Firmware.desiredVersion', desired_display_firmware_version, { type: 'number', write: false }); + await createStateAsync(NSPanel_Path + 'Display_Firmware.desiredVersion', desired_display_firmware_version, {type: 'number', write: false}); // if 'desiredVersion' as a string: await createStateAsync(NSPanel_Path + 'Display_Firmware.desiredVersion', String(desired_display_firmware_version), { type: 'string', write: false }); } else { await setStateAsync(NSPanel_Path + 'Display_Firmware.desiredVersion', desired_display_firmware_version, true); @@ -1343,7 +1351,7 @@ async function Init_Release() { } if (existsObject(NSPanel_Path + 'Config.Update.activ') == false) { - await createStateAsync(NSPanel_Path + 'Config.Update.activ', 1, { type: 'number', write: false }); + await createStateAsync(NSPanel_Path + 'Config.Update.activ', 1, {type: 'number', write: false}); } else { await setStateAsync(NSPanel_Path + 'Config.Update.activ', 0, true); } @@ -1360,16 +1368,16 @@ async function Init_Release() { if (existsObject(NSPanel_Path + 'Display_Firmware.TFT.desiredVersion') == false) { //Create TFT DP's if (isSetOptionActive) { - await createStateAsync(NSPanel_Path + 'Display_Firmware.TFT.currentVersion', currentFW + ' / v' + FWRelease[findFWIndex], { type: 'string', write: false }); - await createStateAsync(NSPanel_Path + 'Display_Firmware.TFT.desiredVersion', String(desired_display_firmware_version), { type: 'string', write: false }); - setObject(AliasPath + 'Display_Firmware.TFT.currentVersion', { type: 'channel', common: { role: 'info', name: 'current TFT-Version' }, native: {} }); - setObject(AliasPath + 'Display_Firmware.TFT.desiredVersion', { type: 'channel', common: { role: 'info', name: 'desired TFT-Version' }, native: {} }); - await createAliasAsync(AliasPath + 'Display_Firmware.TFT.currentVersion.ACTUAL', NSPanel_Path + 'Display_Firmware.TFT.currentVersion', true, { + await createStateAsync(NSPanel_Path + 'Display_Firmware.TFT.currentVersion', currentFW + ' / v' + FWRelease[findFWIndex], {type: 'string', write: false}); + await createStateAsync(NSPanel_Path + 'Display_Firmware.TFT.desiredVersion', String(desired_display_firmware_version), {type: 'string', write: false}); + setObject(AliasPath + 'Display_Firmware.TFT.currentVersion', {type: 'channel', common: {role: 'info', name: 'current TFT-Version'}, native: {}}); + setObject(AliasPath + 'Display_Firmware.TFT.desiredVersion', {type: 'channel', common: {role: 'info', name: 'desired TFT-Version'}, native: {}}); + await createAliasAsync(AliasPath + 'Display_Firmware.TFT.currentVersion.ACTUAL', NSPanel_Path + 'Display_Firmware.TFT.currentVersion', true, { type: 'string', role: 'state', name: 'ACTUAL', }); - await createAliasAsync(AliasPath + 'Display_Firmware.TFT.desiredVersion.ACTUAL', NSPanel_Path + 'Display_Firmware.TFT.desiredVersion', true, { + await createAliasAsync(AliasPath + 'Display_Firmware.TFT.desiredVersion.ACTUAL', NSPanel_Path + 'Display_Firmware.TFT.desiredVersion', true, { type: 'string', role: 'state', name: 'ACTUAL', @@ -1401,82 +1409,82 @@ Init_Release(); * - hiddenCards (socket) * @function InitConfigParameters */ -async function InitConfigParameters() { +async function InitConfigParameters () { try { if (isSetOptionActive) { // alternativeScreensaverLayout (socket) - await createStateAsync(NSPanel_Path + 'Config.Screensaver.alternativeScreensaverLayout', false, { type: 'boolean', write: true }); - setObject(AliasPath + 'Config.Screensaver.alternativeScreensaverLayout', { type: 'channel', common: { role: 'socket', name: 'alternativeScreensaverLayout' }, native: {} }); - await createAliasAsync(AliasPath + 'Config.Screensaver.alternativeScreensaverLayout.ACTUAL', NSPanel_Path + 'Config.Screensaver.alternativeScreensaverLayout', true, { + await createStateAsync(NSPanel_Path + 'Config.Screensaver.alternativeScreensaverLayout', false, {type: 'boolean', write: true}); + setObject(AliasPath + 'Config.Screensaver.alternativeScreensaverLayout', {type: 'channel', common: {role: 'socket', name: 'alternativeScreensaverLayout'}, native: {}}); + await createAliasAsync(AliasPath + 'Config.Screensaver.alternativeScreensaverLayout.ACTUAL', NSPanel_Path + 'Config.Screensaver.alternativeScreensaverLayout', true, { type: 'boolean', role: 'switch', name: 'ACTUAL', }); - await createAliasAsync(AliasPath + 'Config.Screensaver.alternativeScreensaverLayout.SET', NSPanel_Path + 'Config.Screensaver.alternativeScreensaverLayout', true, { + await createAliasAsync(AliasPath + 'Config.Screensaver.alternativeScreensaverLayout.SET', NSPanel_Path + 'Config.Screensaver.alternativeScreensaverLayout', true, { type: 'boolean', role: 'switch', name: 'SET', }); - await createStateAsync(`${NSPanel_Path}${ScreensaverAdvancedEndPath}`, false, { type: 'boolean', write: true }); - setObject(AliasPath + ScreensaverAdvancedEndPath, { type: 'channel', common: { role: 'socket', name: 'ScreensaverAdvanced' }, native: {} }); - await createAliasAsync(`${AliasPath}${ScreensaverAdvancedEndPath}.ACTUAL`, `${NSPanel_Path}${ScreensaverAdvancedEndPath}`, true, { + await createStateAsync(`${NSPanel_Path}${ScreensaverAdvancedEndPath}`, false, {type: 'boolean', write: true}); + setObject(AliasPath + ScreensaverAdvancedEndPath, {type: 'channel', common: {role: 'socket', name: 'ScreensaverAdvanced'}, native: {}}); + await createAliasAsync(`${AliasPath}${ScreensaverAdvancedEndPath}.ACTUAL`, `${NSPanel_Path}${ScreensaverAdvancedEndPath}`, true, { type: 'boolean', role: 'switch', name: 'ACTUAL', }); - await createAliasAsync(`${AliasPath}${ScreensaverAdvancedEndPath}.SET`, `${NSPanel_Path}${ScreensaverAdvancedEndPath}`, true, { + await createAliasAsync(`${AliasPath}${ScreensaverAdvancedEndPath}.SET`, `${NSPanel_Path}${ScreensaverAdvancedEndPath}`, true, { type: 'boolean', role: 'switch', name: 'SET', }); - await createStateAsync(NSPanel_Path + ScreensaverEasyViewEndPath, false, { type: 'boolean', write: true }); - setObject(AliasPath + ScreensaverEasyViewEndPath, { type: 'channel', common: { role: 'socket', name: 'Easy-View Screensaver' }, native: {} }); - await createAliasAsync(`${AliasPath}${ScreensaverEasyViewEndPath}.ACTUAL`, NSPanel_Path + ScreensaverEasyViewEndPath, true, { + await createStateAsync(NSPanel_Path + ScreensaverEasyViewEndPath, false, {type: 'boolean', write: true}); + setObject(AliasPath + ScreensaverEasyViewEndPath, {type: 'channel', common: {role: 'socket', name: 'Easy-View Screensaver'}, native: {}}); + await createAliasAsync(`${AliasPath}${ScreensaverEasyViewEndPath}.ACTUAL`, NSPanel_Path + ScreensaverEasyViewEndPath, true, { type: 'boolean', role: 'switch', name: 'ACTUAL', }); - await createAliasAsync(`${AliasPath}${ScreensaverEasyViewEndPath}.SET`, NSPanel_Path + ScreensaverEasyViewEndPath, true, { + await createAliasAsync(`${AliasPath}${ScreensaverEasyViewEndPath}.SET`, NSPanel_Path + ScreensaverEasyViewEndPath, true, { type: 'boolean', role: 'switch', name: 'SET', }); // autoWeatherColorScreensaverLayout (socket) - await createStateAsync(NSPanel_Path + 'Config.Screensaver.autoWeatherColorScreensaverLayout', true, { type: 'boolean', write: true }); - setObject(AliasPath + 'Config.Screensaver.autoWeatherColorScreensaverLayout', { type: 'channel', common: { role: 'socket', name: 'alternativeScreensaverLayout' }, native: {} }); + await createStateAsync(NSPanel_Path + 'Config.Screensaver.autoWeatherColorScreensaverLayout', true, {type: 'boolean', write: true}); + setObject(AliasPath + 'Config.Screensaver.autoWeatherColorScreensaverLayout', {type: 'channel', common: {role: 'socket', name: 'alternativeScreensaverLayout'}, native: {}}); await createAliasAsync(AliasPath + 'Config.Screensaver.autoWeatherColorScreensaverLayout.ACTUAL', NSPanel_Path + 'Config.Screensaver.autoWeatherColorScreensaverLayout', true, < iobJS.StateCommon - >{ type: 'boolean', role: 'switch', name: 'ACTUAL' }); + > {type: 'boolean', role: 'switch', name: 'ACTUAL'}); await createAliasAsync(AliasPath + 'Config.Screensaver.autoWeatherColorScreensaverLayout.SET', NSPanel_Path + 'Config.Screensaver.autoWeatherColorScreensaverLayout', true, < iobJS.StateCommon - >{ type: 'boolean', role: 'switch', name: 'SET' }); + > {type: 'boolean', role: 'switch', name: 'SET'}); // timeoutScreensaver 0-60 (Slider) - await createStateAsync(NSPanel_Path + 'Config.Screensaver.timeoutScreensaver', 10, { type: 'number', write: true }); - setObject(AliasPath + 'Config.Screensaver.timeoutScreensaver', { type: 'channel', common: { role: 'slider', name: 'timeoutScreensaver' }, native: {} }); - await createAliasAsync(AliasPath + 'Config.Screensaver.timeoutScreensaver.ACTUAL', NSPanel_Path + 'Config.Screensaver.timeoutScreensaver', true, { + await createStateAsync(NSPanel_Path + 'Config.Screensaver.timeoutScreensaver', 10, {type: 'number', write: true}); + setObject(AliasPath + 'Config.Screensaver.timeoutScreensaver', {type: 'channel', common: {role: 'slider', name: 'timeoutScreensaver'}, native: {}}); + await createAliasAsync(AliasPath + 'Config.Screensaver.timeoutScreensaver.ACTUAL', NSPanel_Path + 'Config.Screensaver.timeoutScreensaver', true, { type: 'number', role: 'value', name: 'ACTUAL', }); - await createAliasAsync(AliasPath + 'Config.Screensaver.timeoutScreensaver.SET', NSPanel_Path + 'Config.Screensaver.timeoutScreensaver', true, { + await createAliasAsync(AliasPath + 'Config.Screensaver.timeoutScreensaver.SET', NSPanel_Path + 'Config.Screensaver.timeoutScreensaver', true, { type: 'number', role: 'level', name: 'SET', }); // screenSaverDoubleClick (socket) - await createStateAsync(NSPanel_Path + 'Config.Screensaver.screenSaverDoubleClick', true, { type: 'boolean', write: true }); - setObject(AliasPath + 'Config.Screensaver.screenSaverDoubleClick', { type: 'channel', common: { role: 'socket', name: 'screenSaverDoubleClick' }, native: {} }); - await createAliasAsync(AliasPath + 'Config.Screensaver.screenSaverDoubleClick.ACTUAL', NSPanel_Path + 'Config.Screensaver.screenSaverDoubleClick', true, { + await createStateAsync(NSPanel_Path + 'Config.Screensaver.screenSaverDoubleClick', true, {type: 'boolean', write: true}); + setObject(AliasPath + 'Config.Screensaver.screenSaverDoubleClick', {type: 'channel', common: {role: 'socket', name: 'screenSaverDoubleClick'}, native: {}}); + await createAliasAsync(AliasPath + 'Config.Screensaver.screenSaverDoubleClick.ACTUAL', NSPanel_Path + 'Config.Screensaver.screenSaverDoubleClick', true, { type: 'boolean', role: 'switch', name: 'ACTUAL', }); - await createAliasAsync(AliasPath + 'Config.Screensaver.screenSaverDoubleClick.SET', NSPanel_Path + 'Config.Screensaver.screenSaverDoubleClick', true, { + await createAliasAsync(AliasPath + 'Config.Screensaver.screenSaverDoubleClick.SET', NSPanel_Path + 'Config.Screensaver.screenSaverDoubleClick', true, { type: 'boolean', role: 'switch', name: 'SET', @@ -1484,26 +1492,26 @@ async function InitConfigParameters() { if (existsObject(NSPanel_Path + 'Config.locale') == false) { // en-US, de-DE, nl-NL, da-DK, es-ES, fr-FR, it-IT, ru-RU, etc. - await createStateAsync(NSPanel_Path + 'Config.locale', 'de-DE', { type: 'string', write: true }); + await createStateAsync(NSPanel_Path + 'Config.locale', 'de-DE', {type: 'string', write: true}); setStateAsync(NSPanel_Path + 'Config.locale', 'de-DE'); } if (existsObject(NSPanel_Path + 'Config.temperatureUnit') == false) { // '°C', '°F', 'K' - await createStateAsync(NSPanel_Path + 'Config.temperatureUnit', '°C', { type: 'string', write: true }); + await createStateAsync(NSPanel_Path + 'Config.temperatureUnit', '°C', {type: 'string', write: true}); } // locale Tastensensor popupInSel buttonSensor if (existsObject(NSPanel_Path + 'Config.localeNumber') == false) { - await createStateAsync(NSPanel_Path + 'Config.localeNumber', 1, { type: 'number', write: true }); - setObject(AliasPath + 'Config.localeNumber', { type: 'channel', common: { role: 'buttonSensor', name: 'localeNumber' }, native: {} }); - await createAliasAsync(AliasPath + 'Config.localeNumber.VALUE', NSPanel_Path + 'Config.localeNumber', true, { type: 'number', role: 'state', name: 'VALUE' }); + await createStateAsync(NSPanel_Path + 'Config.localeNumber', 1, {type: 'number', write: true}); + setObject(AliasPath + 'Config.localeNumber', {type: 'channel', common: {role: 'buttonSensor', name: 'localeNumber'}, native: {}}); + await createAliasAsync(AliasPath + 'Config.localeNumber.VALUE', NSPanel_Path + 'Config.localeNumber', true, {type: 'number', role: 'state', name: 'VALUE'}); } // temperatureUnit popupInSel buttonSensor if (existsObject(NSPanel_Path + 'Config.temperatureUnitNumber') == false) { - await createStateAsync(NSPanel_Path + 'Config.temperatureUnitNumber', 0, { type: 'number', write: true }); - setObject(AliasPath + 'Config.temperatureUnitNumber', { type: 'channel', common: { role: 'buttonSensor', name: 'temperatureUnitNumber' }, native: {} }); - await createAliasAsync(AliasPath + 'Config.temperatureUnitNumber.VALUE', NSPanel_Path + 'Config.temperatureUnitNumber', true, { + await createStateAsync(NSPanel_Path + 'Config.temperatureUnitNumber', 0, {type: 'number', write: true}); + setObject(AliasPath + 'Config.temperatureUnitNumber', {type: 'channel', common: {role: 'buttonSensor', name: 'temperatureUnitNumber'}, native: {}}); + await createAliasAsync(AliasPath + 'Config.temperatureUnitNumber.VALUE', NSPanel_Path + 'Config.temperatureUnitNumber', true, { type: 'number', role: 'state', name: 'VALUE', @@ -1511,14 +1519,14 @@ async function InitConfigParameters() { } // Trigger DP for hiddenCards (with hiddenByTrigger) if (existsObject(NSPanel_Path + 'Config.hiddenCards') == false) { - await createStateAsync(NSPanel_Path + 'Config.hiddenCards', false, { type: 'boolean', write: true }); - setObject(AliasPath + 'Config.hiddenCards', { type: 'channel', common: { role: 'socket', name: 'hiddenCards' }, native: {} }); - await createAliasAsync(AliasPath + 'Config.hiddenCards.ACTUAL', NSPanel_Path + 'Config.hiddenCards', true, { + await createStateAsync(NSPanel_Path + 'Config.hiddenCards', false, {type: 'boolean', write: true}); + setObject(AliasPath + 'Config.hiddenCards', {type: 'channel', common: {role: 'socket', name: 'hiddenCards'}, native: {}}); + await createAliasAsync(AliasPath + 'Config.hiddenCards.ACTUAL', NSPanel_Path + 'Config.hiddenCards', true, { type: 'boolean', role: 'switch', name: 'ACTUAL', }); - await createAliasAsync(AliasPath + 'Config.hiddenCards.SET', NSPanel_Path + 'Config.hiddenCards', true, { + await createAliasAsync(AliasPath + 'Config.hiddenCards.SET', NSPanel_Path + 'Config.hiddenCards', true, { type: 'boolean', role: 'switch', name: 'SET', @@ -1545,7 +1553,7 @@ InitConfigParameters(); * @param {boolean} obj.state.val - The new value of the triggering state. * @returns {Promise} - A Promise that resolves when the function completes. */ -on({ id: [NSPanel_Path + 'Config.hiddenCards'], change: 'ne' }, async function (obj) { +on({id: [NSPanel_Path + 'Config.hiddenCards'], change: 'ne'}, async function (obj) { try { obj.state.val ? log('hidden Cards activated', 'info') : log('hidden Cards disabled', 'info'); valueHiddenCards = obj.state.val; @@ -1570,7 +1578,7 @@ on({ id: [NSPanel_Path + 'Config.hiddenCards'], change: 'ne' }, async function ( * @param {boolean} obj.state.val - The new state value. * @returns {Promise} - A Promise that resolves when the function completes. */ -on({ id: [NSPanel_Path + 'Config.ScripgtDebugStatus'], change: 'ne' }, async function (obj) { +on({id: [NSPanel_Path + 'Config.ScripgtDebugStatus'], change: 'ne'}, async function (obj) { try { obj.state.val ? log('Debug mode activated', 'info') : log('Debug mode disabled', 'info'); Debug = obj.state.val; @@ -1588,7 +1596,7 @@ on({ id: [NSPanel_Path + 'Config.ScripgtDebugStatus'], change: 'ne' }, async fun * @param {number} obj.state.val - The new state value. * @returns {Promise} - A Promise that resolves when the function completes. */ -on({ id: [NSPanel_Path + 'Config.localeNumber', NSPanel_Path + 'Config.temperatureUnitNumber'], change: 'ne' }, async function (obj) { +on({id: [NSPanel_Path + 'Config.localeNumber', NSPanel_Path + 'Config.temperatureUnitNumber'], change: 'ne'}, async function (obj) { try { if (obj.id == NSPanel_Path + 'Config.localeNumber') { /** @@ -1668,13 +1676,13 @@ on({ id: [NSPanel_Path + 'Config.localeNumber', NSPanel_Path + 'Config.temperatu * Screensaver 1 and Screensaver 2 * @function Init_ScreensaverAdvanced */ -async function Init_ScreensaverAdvanced() { +async function Init_ScreensaverAdvanced () { try { if (existsState(`${NSPanel_Path}${ScreensaverAdvancedEndPath}`) == false) { - await createStateAsync(`${NSPanel_Path}${ScreensaverAdvancedEndPath}`, false, true, { type: 'boolean', write: true }); + await createStateAsync(`${NSPanel_Path}${ScreensaverAdvancedEndPath}`, false, true, {type: 'boolean', write: true}); } if (existsState(`${NSPanel_Path}${ScreensaverEasyViewEndPath}`) == false) { - await createStateAsync(`${NSPanel_Path}${ScreensaverEasyViewEndPath}`, false, true, { type: 'boolean', write: true }); + await createStateAsync(`${NSPanel_Path}${ScreensaverEasyViewEndPath}`, false, true, {type: 'boolean', write: true}); } } catch (err: any) { log('error at function Init_ScreensaverAdvanced: ' + err.message, 'warn'); @@ -1687,7 +1695,7 @@ Init_ScreensaverAdvanced(); * Checks whether setObjects() is available for the instance (true/false) * @returns {boolean} result of the check */ -function CheckEnableSetObject() { +function CheckEnableSetObject () { var enableSetObject = getObject('system.adapter.javascript.' + instance).native.enableSetObject; return enableSetObject; } @@ -1700,16 +1708,16 @@ function CheckEnableSetObject() { * These states are used to store the heading, type and id0 of the active page. * @function Init_ActivePageData */ -async function Init_ActivePageData() { +async function Init_ActivePageData () { try { if (existsState(NSPanel_Path + 'ActivePage.heading') == false) { - await createStateAsync(NSPanel_Path + 'ActivePage.heading', '', true, { type: 'string', write: false }); + await createStateAsync(NSPanel_Path + 'ActivePage.heading', '', true, {type: 'string', write: false}); } if (existsState(NSPanel_Path + 'ActivePage.type') == false) { - await createStateAsync(NSPanel_Path + 'ActivePage.type', '', true, { type: 'string', write: false }); + await createStateAsync(NSPanel_Path + 'ActivePage.type', '', true, {type: 'string', write: false}); } if (existsState(NSPanel_Path + 'ActivePage.id0') == false) { - await createStateAsync(NSPanel_Path + 'ActivePage.id0', '', true, { type: 'string', write: false }); + await createStateAsync(NSPanel_Path + 'ActivePage.id0', '', true, {type: 'string', write: false}); } } catch (err: any) { log('error at function Init_ActivePageData: ' + err.message, 'warn'); @@ -1722,7 +1730,7 @@ Init_ActivePageData(); * This state is used to switch between different background colors for the screensaver. * @function Init_Screensaver_Backckground_Color_Switch */ -async function Init_Screensaver_Backckground_Color_Switch() { +async function Init_Screensaver_Backckground_Color_Switch () { try { const objDef: iobJS.StateObject = { _id: '', @@ -1731,7 +1739,7 @@ async function Init_Screensaver_Backckground_Color_Switch() { type: 'number', name: 'Color Indicator', role: 'level', - states: { 0: 'black', 1: 'red', 2: 'green', 3: 'attention', 4: 'pink', 5: 'dark red' }, + states: {0: 'black', 1: 'red', 2: 'green', 3: 'attention', 4: 'pink', 5: 'dark red'}, read: true, write: true, }, @@ -1764,7 +1772,7 @@ Init_Screensaver_Backckground_Color_Switch(); * @async * @throws {Error} If an error occurs while updating the `bgColorScrSaver` variable or calling `HandleScreensaverUpdate`. */ -on({ id: NSPanel_Path + 'ScreensaverInfo.bgColorIndicator', change: 'ne' }, async function (obj) { +on({id: NSPanel_Path + 'ScreensaverInfo.bgColorIndicator', change: 'ne'}, async function (obj) { try { bgColorScrSaver = obj.state.val; if (bgColorScrSaver < 6) { @@ -1787,7 +1795,7 @@ on({ id: NSPanel_Path + 'ScreensaverInfo.bgColorIndicator', change: 'ne' }, asyn * @async * @throws {Error} If an error occurs while updating the state of the `alternativeScreensaverLayout` object. */ -on({ id: `${NSPanel_Path}${ScreensaverAdvancedEndPath}`, change: 'ne' }, async function (obj) { +on({id: `${NSPanel_Path}${ScreensaverAdvancedEndPath}`, change: 'ne'}, async function (obj) { try { if (obj.state.val) setState(`${NSPanel_Path}Config.Screensaver.alternativeScreensaverLayout`, false, true); if (obj.state.val) setState(`${NSPanel_Path}${ScreensaverEasyViewEndPath}`, false, true); @@ -1797,7 +1805,7 @@ on({ id: `${NSPanel_Path}${ScreensaverAdvancedEndPath}`, change: 'ne' }, async f log('error at trigger Screensaver Advanced: ' + err.message, 'warn'); } }); -on({ id: `${NSPanel_Path}${ScreensaverEasyViewEndPath}`, change: 'ne' }, async function (obj) { +on({id: `${NSPanel_Path}${ScreensaverEasyViewEndPath}`, change: 'ne'}, async function (obj) { try { if (obj.state.val) setState(`${NSPanel_Path}Config.Screensaver.alternativeScreensaverLayout`, false, true); if (obj.state.val) setState(`${NSPanel_Path}${ScreensaverAdvancedEndPath}`, false, true); @@ -1823,12 +1831,12 @@ on({ id: `${NSPanel_Path}${ScreensaverEasyViewEndPath}`, change: 'ne' }, async f * @note This function appears to be a toggle with the `ScreensaverAdvanced` configuration. * When `alternativeScreensaverLayout` is true, `ScreensaverAdvanced` is set to false. */ -on({ id: NSPanel_Path + 'Config.Screensaver.alternativeScreensaverLayout', change: 'ne' }, async function (obj) { +on({id: NSPanel_Path + 'Config.Screensaver.alternativeScreensaverLayout', change: 'ne'}, async function (obj) { try { if (obj.state.val) setState(`${NSPanel_Path}${ScreensaverAdvancedEndPath}`, false, true); if (obj.state.val) setState(`${NSPanel_Path}${ScreensaverEasyViewEndPath}`, false, true); if (obj.id) await setStateAsync(obj.id, obj.state.val, true); - + //setState(config.panelSendTopic, 'pageType~pageStartup'); } catch (err: any) { log('error at trigger Screensaver Alternativ: ' + err.message, 'warn'); @@ -1843,12 +1851,12 @@ on({ id: NSPanel_Path + 'Config.Screensaver.alternativeScreensaverLayout', chang * @async * @throws {Error} If an error occurs while creating the `bExitPage` state object. */ -async function Init_bExit_Page_Change() { +async function Init_bExit_Page_Change () { try { alwaysOn = false; pageCounter = 0; if (existsState(NSPanel_Path + 'ScreensaverInfo.bExitPage') == false) { - await createStateAsync(NSPanel_Path + 'ScreensaverInfo.bExitPage', -1, true, { type: 'number', write: true }); + await createStateAsync(NSPanel_Path + 'ScreensaverInfo.bExitPage', -1, true, {type: 'number', write: true}); } } catch (err: any) { log('error at function Init_bExit_Page_Change: ' + err.message, 'warn'); @@ -1866,10 +1874,10 @@ Init_bExit_Page_Change(); * @async * @throws {Error} If an error occurs while creating the `Trigger_Dimmode` state. */ -async function Init_Dimmode_Trigger() { +async function Init_Dimmode_Trigger () { try { if (existsState(NSPanel_Path + 'ScreensaverInfo.Trigger_Dimmode') == false) { - await createStateAsync(NSPanel_Path + 'ScreensaverInfo.Trigger_Dimmode', false, true, { type: 'boolean', write: true }); + await createStateAsync(NSPanel_Path + 'ScreensaverInfo.Trigger_Dimmode', false, true, {type: 'boolean', write: true}); } } catch (err: any) { log('error at function Init_Dimmode_Trigger: ' + err.message, 'warn'); @@ -1887,21 +1895,21 @@ Init_Dimmode_Trigger(); * @async * @throws {Error} If an error occurs while creating the state objects or aliases. */ -async function InitActiveBrightness() { +async function InitActiveBrightness () { try { if (isSetOptionActive) { if (existsState(NSPanel_Path + 'ScreensaverInfo.activeBrightness') == false || existsState(NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness') == false) { - await createStateAsync(NSPanel_Path + 'ScreensaverInfo.activeBrightness', 100, { type: 'number', write: true }); - await createStateAsync(NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness', -1, { type: 'number', write: true }); + await createStateAsync(NSPanel_Path + 'ScreensaverInfo.activeBrightness', 100, {type: 'number', write: true}); + await createStateAsync(NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness', -1, {type: 'number', write: true}); } //Create Alias activeBrightness - setObject(AliasPath + 'ScreensaverInfo.activeBrightness', { type: 'channel', common: { role: 'slider', name: 'activeBrightness' }, native: {} }); - await createAliasAsync(AliasPath + 'ScreensaverInfo.activeBrightness.ACTUAL', NSPanel_Path + 'ScreensaverInfo.activeBrightness', true, { + setObject(AliasPath + 'ScreensaverInfo.activeBrightness', {type: 'channel', common: {role: 'slider', name: 'activeBrightness'}, native: {}}); + await createAliasAsync(AliasPath + 'ScreensaverInfo.activeBrightness.ACTUAL', NSPanel_Path + 'ScreensaverInfo.activeBrightness', true, { type: 'number', role: 'value', name: 'ACTUAL', }); - await createAliasAsync(AliasPath + 'ScreensaverInfo.activeBrightness.SET', NSPanel_Path + 'ScreensaverInfo.activeBrightness', true, { + await createAliasAsync(AliasPath + 'ScreensaverInfo.activeBrightness.SET', NSPanel_Path + 'ScreensaverInfo.activeBrightness', true, { type: 'number', role: 'level', name: 'SET', @@ -1926,16 +1934,16 @@ InitActiveBrightness(); * @async * @throws {Error} If an error occurs while retrieving the dimmode brightness value or sending the message to the panel. */ -on({ id: [NSPanel_Path + 'ScreensaverInfo.activeBrightness'], change: 'ne' }, async function (obj) { +on({id: [NSPanel_Path + 'ScreensaverInfo.activeBrightness'], change: 'ne'}, async function (obj) { try { - let dimBrightness:number = -1; + let dimBrightness: number = -1; if (existsState(NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness')) { dimBrightness = getState(NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness').val; } let active = dimBrightness ?? -1; if (obj.state.val >= 0 || obj.state.val <= 100) { log('action at trigger activeBrightness: ' + obj.state.val + ' - activeDimmodeBrightness: ' + active, 'info'); - SendToPanel({ payload: 'dimmode~' + active + '~' + obj.state.val + '~' + rgb_dec565(config.defaultBackgroundColor) + '~' + rgb_dec565(globalTextColor) + '~' + Sliders2 }); + SendToPanel({payload: 'dimmode~' + active + '~' + obj.state.val + '~' + rgb_dec565(config.defaultBackgroundColor) + '~' + rgb_dec565(globalTextColor) + '~' + Sliders2}); InitDimmode(); } } catch (err: any) { @@ -1956,9 +1964,9 @@ on({ id: [NSPanel_Path + 'ScreensaverInfo.activeBrightness'], change: 'ne' }, as * @async * @throws {Error} If an error occurs while retrieving the brightness value or sending the message to the panel. */ -on({ id: [NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness'], change: 'ne' }, async function (obj) { +on({id: [NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness'], change: 'ne'}, async function (obj) { try { - let brightness:number = 100; + let brightness: number = 100; if (existsState(NSPanel_Path + 'ScreensaverInfo.activeBrightness')) { brightness = getState(NSPanel_Path + 'ScreensaverInfo.activeBrightness').val; } @@ -1974,8 +1982,8 @@ on({ id: [NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness'], change: 'ne InitDimmode(); //HandleMessage('event', 'startup', undefined, undefined); } else { - if (Debug) log('action at trigger activeDimmodeBrightness: ' + obj.state.val + ' - activeBrightness: ' + active, 'info'); - SendToPanel({ payload: 'dimmode~' + obj.state.val + '~' + active + '~' + rgb_dec565(config.defaultBackgroundColor) + '~' + rgb_dec565(globalTextColor) + '~' + Sliders2 }); + if (Debug) log('action at trigger activeDimmodeBrightness: ' + obj.state.val + ' - activeBrightness: ' + active, 'info'); + SendToPanel({payload: 'dimmode~' + obj.state.val + '~' + active + '~' + rgb_dec565(config.defaultBackgroundColor) + '~' + rgb_dec565(globalTextColor) + '~' + Sliders2}); } } else { alwaysOn = false; @@ -2003,15 +2011,15 @@ on({ id: [NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness'], change: 'ne * @async * @throws {Error} If an error occurs while retrieving the brightness value or sending the message to the panel. */ -on({ id: String(NSPanel_Path) + 'ScreensaverInfo.Trigger_Dimmode', change: 'ne' }, async function (obj) { +on({id: String(NSPanel_Path) + 'ScreensaverInfo.Trigger_Dimmode', change: 'ne'}, async function (obj) { try { - let brightness:number = 100; + let brightness: number = 100; if (existsState(NSPanel_Path + 'ScreensaverInfo.activeBrightness')) { brightness = getState(NSPanel_Path + 'ScreensaverInfo.activeBrightness').val; } let active = brightness ?? 80; if (obj.state.val) { - SendToPanel({ payload: 'dimmode~' + 100 + '~' + active + '~' + rgb_dec565(config.defaultBackgroundColor) + '~' + rgb_dec565(globalTextColor) + '~' + Sliders2 }); + SendToPanel({payload: 'dimmode~' + 100 + '~' + active + '~' + rgb_dec565(config.defaultBackgroundColor) + '~' + rgb_dec565(globalTextColor) + '~' + Sliders2}); } else { InitDimmode(); } @@ -2028,12 +2036,12 @@ on({ id: String(NSPanel_Path) + 'ScreensaverInfo.Trigger_Dimmode', change: 'ne' * @async * @throws {Error} If an error occurs while creating the state or alias. */ -async function InitRebootPanel() { +async function InitRebootPanel () { try { if (existsState(NSPanel_Path + 'Config.rebootNSPanel') == false) { - await createStateAsync(NSPanel_Path + 'Config.rebootNSPanel', false, { type: 'boolean', write: true }); - setObject(AliasPath + 'Config.rebootNSPanel', { type: 'channel', common: { role: 'button', name: 'Reboot NSPanel' }, native: {} }); - await createAliasAsync(AliasPath + 'Config.rebootNSPanel.SET', NSPanel_Path + 'Config.rebootNSPanel', true, { type: 'boolean', role: 'state', name: 'SET' }); + await createStateAsync(NSPanel_Path + 'Config.rebootNSPanel', false, {type: 'boolean', write: true}); + setObject(AliasPath + 'Config.rebootNSPanel', {type: 'channel', common: {role: 'button', name: 'Reboot NSPanel'}, native: {}}); + await createAliasAsync(AliasPath + 'Config.rebootNSPanel.SET', NSPanel_Path + 'Config.rebootNSPanel', true, {type: 'boolean', role: 'state', name: 'SET'}); } } catch (err: any) { log('error at function InitRebootPanel: ' + err.message, 'warn'); @@ -2053,7 +2061,7 @@ InitRebootPanel(); * @async * @throws {Error} If an error occurs while sending the request to the Tasmota device. */ -on({ id: AliasPath + 'Config.rebootNSPanel.SET', change: 'any' }, async function (obj) { +on({id: AliasPath + 'Config.rebootNSPanel.SET', change: 'any'}, async function (obj) { if (obj.state.val) { try { let urlString = `http://${get_current_tasmota_ip_address()}/cm?cmnd=Backlog Restart 1`; @@ -2061,10 +2069,10 @@ on({ id: AliasPath + 'Config.rebootNSPanel.SET', change: 'any' }, async function urlString = `http://${get_current_tasmota_ip_address()}/cm?user=${tasmota_web_admin_user}&password=${tasmota_web_admin_password}&cmnd=Backlog Restart 1;`; } axios - .get(urlString, { headers: { 'User-Agent': 'ioBroker' } }) + .get(urlString, {headers: {'User-Agent': 'ioBroker'}}) .then(async function (response) { if (response.status === 200) { - SendToPanel({ payload: 'pageType~pageStartup' }); + SendToPanel({payload: 'pageType~pageStartup'}); log('Tasmota Reboot', 'info'); setStateAsync(AliasPath + 'Config.rebootNSPanel.SET', false); log('Name: ' + name, 'info'); @@ -2118,27 +2126,27 @@ on({ id: AliasPath + 'Config.rebootNSPanel.SET', change: 'any' }, async function * * @throws {Error} If an error occurs while creating the datapoints or aliases. */ -async function InitUpdateDatapoints() { +async function InitUpdateDatapoints () { try { if (existsState(NSPanel_Path + 'Config.Update.UpdateTasmota') == false) { if (isSetOptionActive) { - await createStateAsync(NSPanel_Path + 'Config.Update.UpdateTasmota', false, { type: 'boolean', write: true }); - await createStateAsync(NSPanel_Path + 'Config.Update.UpdateBerry', false, { type: 'boolean', write: true }); - await createStateAsync(NSPanel_Path + 'Config.Update.UpdateNextion', false, { type: 'boolean', write: true }); - setObject(AliasPath + 'Config.Update.UpdateTasmota', { type: 'channel', common: { role: 'button', name: 'Tassmota update' }, native: {} }); - setObject(AliasPath + 'Config.Update.UpdateBerry', { type: 'channel', common: { role: 'button', name: 'Berry-Driver update' }, native: {} }); - setObject(AliasPath + 'Config.Update.UpdateNextion', { type: 'channel', common: { role: 'button', name: 'Nextion TFT update' }, native: {} }); - await createAliasAsync(AliasPath + 'Config.Update.UpdateTasmota.SET', NSPanel_Path + 'Config.Update.UpdateTasmota', true, { + await createStateAsync(NSPanel_Path + 'Config.Update.UpdateTasmota', false, {type: 'boolean', write: true}); + await createStateAsync(NSPanel_Path + 'Config.Update.UpdateBerry', false, {type: 'boolean', write: true}); + await createStateAsync(NSPanel_Path + 'Config.Update.UpdateNextion', false, {type: 'boolean', write: true}); + setObject(AliasPath + 'Config.Update.UpdateTasmota', {type: 'channel', common: {role: 'button', name: 'Tassmota update'}, native: {}}); + setObject(AliasPath + 'Config.Update.UpdateBerry', {type: 'channel', common: {role: 'button', name: 'Berry-Driver update'}, native: {}}); + setObject(AliasPath + 'Config.Update.UpdateNextion', {type: 'channel', common: {role: 'button', name: 'Nextion TFT update'}, native: {}}); + await createAliasAsync(AliasPath + 'Config.Update.UpdateTasmota.SET', NSPanel_Path + 'Config.Update.UpdateTasmota', true, { type: 'boolean', role: 'state', name: 'SET', }); - await createAliasAsync(AliasPath + 'Config.Update.UpdateBerry.SET', NSPanel_Path + 'Config.Update.UpdateBerry', true, { + await createAliasAsync(AliasPath + 'Config.Update.UpdateBerry.SET', NSPanel_Path + 'Config.Update.UpdateBerry', true, { type: 'boolean', role: 'state', name: 'SET', }); - await createAliasAsync(AliasPath + 'Config.Update.UpdateNextion.SET', NSPanel_Path + 'Config.Update.UpdateNextion', true, { + await createAliasAsync(AliasPath + 'Config.Update.UpdateNextion.SET', NSPanel_Path + 'Config.Update.UpdateNextion', true, { type: 'boolean', role: 'state', name: 'SET', @@ -2163,7 +2171,7 @@ InitUpdateDatapoints(); * @async * @throws {Error} If an error occurs while performing the firmware update action. */ -on({ id: [NSPanel_Path + 'Config.Update.UpdateTasmota', NSPanel_Path + 'Config.Update.UpdateBerry', NSPanel_Path + 'Config.Update.UpdateNextion'], change: 'any' }, async function (obj) { +on({id: [NSPanel_Path + 'Config.Update.UpdateTasmota', NSPanel_Path + 'Config.Update.UpdateBerry', NSPanel_Path + 'Config.Update.UpdateNextion'], change: 'any'}, async function (obj) { try { switch (obj.id) { case NSPanel_Path + 'Config.Update.UpdateTasmota': @@ -2199,20 +2207,20 @@ on({ id: [NSPanel_Path + 'Config.Update.UpdateTasmota', NSPanel_Path + 'Config.U * @async * @throws {Error} Logs an error message if any error occurs during the initialization. */ -async function Init_Relays() { +async function Init_Relays () { try { if (isSetOptionActive) { if (existsState(NSPanel_Path + 'Relay.1') == false || existsState(NSPanel_Path + 'Relay.2') == false) { - await createStateAsync(NSPanel_Path + 'Relay.1', true, { type: 'boolean', write: true }); - await createStateAsync(NSPanel_Path + 'Relay.2', true, { type: 'boolean', write: true }); + await createStateAsync(NSPanel_Path + 'Relay.1', true, {type: 'boolean', write: true}); + await createStateAsync(NSPanel_Path + 'Relay.2', true, {type: 'boolean', write: true}); } - setObject(AliasPath + 'Relay.1', { type: 'channel', common: { role: 'socket', name: 'Relay.1' }, native: {} }); - await createAliasAsync(AliasPath + 'Relay.1.ACTUAL', NSPanel_Path + 'Relay.1', true, { type: 'boolean', role: 'switch', name: 'ACTUAL' }); - await createAliasAsync(AliasPath + 'Relay.1.SET', NSPanel_Path + 'Relay.1', true, { type: 'boolean', role: 'switch', name: 'SET' }); + setObject(AliasPath + 'Relay.1', {type: 'channel', common: {role: 'socket', name: 'Relay.1'}, native: {}}); + await createAliasAsync(AliasPath + 'Relay.1.ACTUAL', NSPanel_Path + 'Relay.1', true, {type: 'boolean', role: 'switch', name: 'ACTUAL'}); + await createAliasAsync(AliasPath + 'Relay.1.SET', NSPanel_Path + 'Relay.1', true, {type: 'boolean', role: 'switch', name: 'SET'}); //Create Alias alternateMRIconSize 2 - setObject(AliasPath + 'Relay.2', { type: 'channel', common: { role: 'socket', name: 'Relay.2' }, native: {} }); - await createAliasAsync(AliasPath + 'Relay.2.ACTUAL', NSPanel_Path + 'Relay.2', true, { type: 'boolean', role: 'switch', name: 'ACTUAL' }); - await createAliasAsync(AliasPath + 'Relay.2.SET', NSPanel_Path + 'Relay.2', true, { type: 'boolean', role: 'switch', name: 'SET' }); + setObject(AliasPath + 'Relay.2', {type: 'channel', common: {role: 'socket', name: 'Relay.2'}, native: {}}); + await createAliasAsync(AliasPath + 'Relay.2.ACTUAL', NSPanel_Path + 'Relay.2', true, {type: 'boolean', role: 'switch', name: 'ACTUAL'}); + await createAliasAsync(AliasPath + 'Relay.2.SET', NSPanel_Path + 'Relay.2', true, {type: 'boolean', role: 'switch', name: 'SET'}); } } catch (err: any) { log('error at function Init_Relays: ' + err.message, 'warn'); @@ -2235,33 +2243,33 @@ Init_Relays(); * @async * @throws {Error} Logs an error message if any error occurs during the initialization. */ -async function InitAlternateMRIconsSize() { +async function InitAlternateMRIconsSize () { try { if (isSetOptionActive) { if (existsState(NSPanel_Path + 'Config.MRIcons.alternateMRIconSize.1') == false || existsState(NSPanel_Path + 'Config.MRIcons.alternateMRIconSize.2') == false) { - await createStateAsync(NSPanel_Path + 'Config.MRIcons.alternateMRIconSize.1', false, { type: 'boolean', write: true }); - await createStateAsync(NSPanel_Path + 'Config.MRIcons.alternateMRIconSize.2', false, { type: 'boolean', write: true }); + await createStateAsync(NSPanel_Path + 'Config.MRIcons.alternateMRIconSize.1', false, {type: 'boolean', write: true}); + await createStateAsync(NSPanel_Path + 'Config.MRIcons.alternateMRIconSize.2', false, {type: 'boolean', write: true}); } //Create Alias alternateMRIconSize 1 - setObject(AliasPath + 'Config.MRIcons.alternateMRIconSize.1', { type: 'channel', common: { role: 'socket', name: 'alternateMRIconSize.1' }, native: {} }); - await createAliasAsync(AliasPath + 'Config.MRIcons.alternateMRIconSize.1.ACTUAL', NSPanel_Path + 'Config.MRIcons.alternateMRIconSize.1', true, { + setObject(AliasPath + 'Config.MRIcons.alternateMRIconSize.1', {type: 'channel', common: {role: 'socket', name: 'alternateMRIconSize.1'}, native: {}}); + await createAliasAsync(AliasPath + 'Config.MRIcons.alternateMRIconSize.1.ACTUAL', NSPanel_Path + 'Config.MRIcons.alternateMRIconSize.1', true, { type: 'boolean', role: 'switch', name: 'ACTUAL', }); - await createAliasAsync(AliasPath + 'Config.MRIcons.alternateMRIconSize.1.SET', NSPanel_Path + 'Config.MRIcons.alternateMRIconSize.1', true, { + await createAliasAsync(AliasPath + 'Config.MRIcons.alternateMRIconSize.1.SET', NSPanel_Path + 'Config.MRIcons.alternateMRIconSize.1', true, { type: 'boolean', role: 'switch', name: 'SET', }); //Create Alias alternateMRIconSize 2 - setObject(AliasPath + 'Config.MRIcons.alternateMRIconSize.2', { type: 'channel', common: { role: 'socket', name: 'alternateMRIconSize.2' }, native: {} }); - await createAliasAsync(AliasPath + 'Config.MRIcons.alternateMRIconSize.2.ACTUAL', NSPanel_Path + 'Config.MRIcons.alternateMRIconSize.2', true, { + setObject(AliasPath + 'Config.MRIcons.alternateMRIconSize.2', {type: 'channel', common: {role: 'socket', name: 'alternateMRIconSize.2'}, native: {}}); + await createAliasAsync(AliasPath + 'Config.MRIcons.alternateMRIconSize.2.ACTUAL', NSPanel_Path + 'Config.MRIcons.alternateMRIconSize.2', true, { type: 'boolean', role: 'switch', name: 'ACTUAL', }); - await createAliasAsync(AliasPath + 'Config.MRIcons.alternateMRIconSize.2.SET', NSPanel_Path + 'Config.MRIcons.alternateMRIconSize.2', true, { + await createAliasAsync(AliasPath + 'Config.MRIcons.alternateMRIconSize.2.SET', NSPanel_Path + 'Config.MRIcons.alternateMRIconSize.2', true, { type: 'boolean', role: 'switch', name: 'SET', @@ -2278,7 +2286,7 @@ InitAlternateMRIconsSize(); * Creates all necessary states for the dateformat settings. * If the user option is set, it creates the states for the weekday and month format and the corresponding aliases. */ -async function InitDateformat() { +async function InitDateformat () { try { if (isSetOptionActive) { if ( @@ -2286,31 +2294,31 @@ async function InitDateformat() { existsState(NSPanel_Path + 'Config.Dateformat.month') == false || existsState(NSPanel_Path + 'Config.Dateformat.customFormat') == false ) { - await createStateAsync(NSPanel_Path + 'Config.Dateformat.weekday', 'long', { type: 'string', write: true }); - await createStateAsync(NSPanel_Path + 'Config.Dateformat.month', 'long', { type: 'string', write: true }); - await createStateAsync(NSPanel_Path + 'Config.Dateformat.customFormat', '', { type: 'string', write: true }); + await createStateAsync(NSPanel_Path + 'Config.Dateformat.weekday', 'long', {type: 'string', write: true}); + await createStateAsync(NSPanel_Path + 'Config.Dateformat.month', 'long', {type: 'string', write: true}); + await createStateAsync(NSPanel_Path + 'Config.Dateformat.customFormat', '', {type: 'string', write: true}); } if (existsState(NSPanel_Path + 'Config.Dateformat.Switch.weekday') == false || existsState(NSPanel_Path + 'Config.Dateformat.Switch.month') == false) { - await createStateAsync(NSPanel_Path + 'Config.Dateformat.Switch.weekday', true, { type: 'boolean', write: true }); - await createStateAsync(NSPanel_Path + 'Config.Dateformat.Switch.month', true, { type: 'boolean', write: true }); - setObject(AliasPath + 'Config.Dateformat.Switch.weekday', { type: 'channel', common: { role: 'socket', name: 'Dateformat Switch weekday' }, native: {} }); - await createAliasAsync(AliasPath + 'Config.Dateformat.Switch.weekday.ACTUAL', NSPanel_Path + 'Config.Dateformat.Switch.weekday', true, { + await createStateAsync(NSPanel_Path + 'Config.Dateformat.Switch.weekday', true, {type: 'boolean', write: true}); + await createStateAsync(NSPanel_Path + 'Config.Dateformat.Switch.month', true, {type: 'boolean', write: true}); + setObject(AliasPath + 'Config.Dateformat.Switch.weekday', {type: 'channel', common: {role: 'socket', name: 'Dateformat Switch weekday'}, native: {}}); + await createAliasAsync(AliasPath + 'Config.Dateformat.Switch.weekday.ACTUAL', NSPanel_Path + 'Config.Dateformat.Switch.weekday', true, { type: 'boolean', role: 'switch', name: 'ACTUAL', }); - await createAliasAsync(AliasPath + 'Config.Dateformat.Switch.weekday.SET', NSPanel_Path + 'Config.Dateformat.Switch.weekday', true, { + await createAliasAsync(AliasPath + 'Config.Dateformat.Switch.weekday.SET', NSPanel_Path + 'Config.Dateformat.Switch.weekday', true, { type: 'boolean', role: 'switch', name: 'SET', }); - setObject(AliasPath + 'Config.Dateformat.Switch.month', { type: 'channel', common: { role: 'socket', name: 'Dateformat Switch month' }, native: {} }); - await createAliasAsync(AliasPath + 'Config.Dateformat.Switch.month.ACTUAL', NSPanel_Path + 'Config.Dateformat.Switch.month', true, { + setObject(AliasPath + 'Config.Dateformat.Switch.month', {type: 'channel', common: {role: 'socket', name: 'Dateformat Switch month'}, native: {}}); + await createAliasAsync(AliasPath + 'Config.Dateformat.Switch.month.ACTUAL', NSPanel_Path + 'Config.Dateformat.Switch.month', true, { type: 'boolean', role: 'switch', name: 'ACTUAL', }); - await createAliasAsync(AliasPath + 'Config.Dateformat.Switch.month.SET', NSPanel_Path + 'Config.Dateformat.Switch.month', true, { + await createAliasAsync(AliasPath + 'Config.Dateformat.Switch.month.SET', NSPanel_Path + 'Config.Dateformat.Switch.month', true, { type: 'boolean', role: 'switch', name: 'SET', @@ -2335,7 +2343,7 @@ InitDateformat(); * @async * @throws {Error} If an error occurs while updating the date format state. */ -on({ id: [String(NSPanel_Path) + 'Config.Dateformat.Switch.weekday', String(NSPanel_Path) + 'Config.Dateformat.Switch.month'], change: 'ne' }, async function (obj) { +on({id: [String(NSPanel_Path) + 'Config.Dateformat.Switch.weekday', String(NSPanel_Path) + 'Config.Dateformat.Switch.month'], change: 'ne'}, async function (obj) { try { if (obj.id == NSPanel_Path + 'Config.Dateformat.Switch.weekday') { if (getState(NSPanel_Path + 'Config.Dateformat.Switch.weekday').val) { @@ -2371,7 +2379,7 @@ const NSPanelStatTopic = NSPanelSendTopic.replace('.cmnd.', '.stat.').replace(/\ * * @returns {void} */ -on({ id: [String(NSPanelStatTopic) + 'POWER1', String(NSPanelStatTopic) + 'POWER2'], change: 'ne' }, (obj) => { +on({id: [String(NSPanelStatTopic) + 'POWER1', String(NSPanelStatTopic) + 'POWER2'], change: 'ne'}, (obj) => { if (!obj || !obj.id) return; const n = obj.id.substring(obj.id.length - 1); if (n === '1' || n === '2') { @@ -2395,7 +2403,7 @@ on({ id: [String(NSPanelStatTopic) + 'POWER1', String(NSPanelStatTopic) + 'POWER * @async * @throws {Error} If an error occurs while sending the request to the Tasmota device. */ -on({ id: [String(NSPanel_Path) + 'Relay.1', String(NSPanel_Path) + 'Relay.2'], change: 'ne', ack: false }, async function (obj) { +on({id: [String(NSPanel_Path) + 'Relay.1', String(NSPanel_Path) + 'Relay.2'], change: 'ne', ack: false}, async function (obj) { try { let Button = obj.id!.split('.'); let urlString: string = ['http://', get_current_tasmota_ip_address(), '/cm?cmnd=Power', Button[Button.length - 1], ' ', obj.state ? obj.state.val : ''].join(''); @@ -2428,16 +2436,16 @@ on({ id: [String(NSPanel_Path) + 'Relay.1', String(NSPanel_Path) + 'Relay.2'], c * * @throws {Error} If an error occurs while subscribing to the MQTT entities. */ -async function SubscribeMRIcons() { +async function SubscribeMRIcons () { try { const mrEntities = [config.mrIcon1ScreensaverEntity, config.mrIcon2ScreensaverEntity]; let arr: string[] = [] for (const mrEntity of mrEntities) { arr = typeof mrEntity.ScreensaverEntity == 'string' && mrEntity.ScreensaverEntity !== '' ? [mrEntity.ScreensaverEntity] : []; - arr = typeof mrEntity.ScreensaverEntityValue == 'string' && mrEntity.ScreensaverEntityValue !== '' ? [...arr, mrEntity.ScreensaverEntityValue] : arr; + arr = typeof mrEntity.ScreensaverEntityValue == 'string' && mrEntity.ScreensaverEntityValue !== '' ? [...arr, mrEntity.ScreensaverEntityValue] : arr; } if (arr.length > 0) { - on({ id: arr, change: 'ne' }, async function (obj) { + on({id: arr, change: 'ne'}, async function (obj) { if (obj.id && obj.id.substring(0, 4) == 'mqtt') { let Button = obj.id.split('.'); if (getState(NSPanel_Path + 'Relay.' + Button[Button.length - 1].substring(5, 6)).val != obj.state.val) { @@ -2448,7 +2456,7 @@ async function SubscribeMRIcons() { } }); } - + } catch (err: any) { log('error at function SubscribeMRIcons: ' + err.message, 'warn'); } @@ -2461,7 +2469,7 @@ SubscribeMRIcons(); * @async * @function CreateWeatherAlias */ -async function CreateWeatherAlias() { +async function CreateWeatherAlias () { try { if (autoCreateAlias) { if (weatherAdapterInstance == 'daswetter.' + weatherAdapterInstanceNumber + '.') { @@ -2469,19 +2477,19 @@ async function CreateWeatherAlias() { if (isSetOptionActive) { if (!existsState(config.weatherEntity + '.ICON') && existsState('daswetter.' + weatherAdapterInstanceNumber + '.NextHours.Location_1.Day_1.current.symbol_value')) { log('Weather alias for daswetter.' + weatherAdapterInstanceNumber + '. does not exist yet, will be created now', 'info'); - setObject(config.weatherEntity, { _id: config.weatherEntity, type: 'channel', common: { role: 'weatherCurrent', name: 'media' }, native: {} }); + setObject(config.weatherEntity, {_id: config.weatherEntity, type: 'channel', common: {role: 'weatherCurrent', name: 'media'}, native: {}}); await createAliasAsync(config.weatherEntity + '.ICON', 'daswetter.' + weatherAdapterInstanceNumber + '.NextHours.Location_1.Day_1.current.symbol_value', true, < iobJS.StateCommon - >{ type: 'number', role: 'value', name: 'ICON' }); + > {type: 'number', role: 'value', name: 'ICON'}); await createAliasAsync(config.weatherEntity + '.TEMP', 'daswetter.' + weatherAdapterInstanceNumber + '.NextHours.Location_1.Day_1.current.temp_value', true, < iobJS.StateCommon - >{ type: 'number', role: 'value.temperature', name: 'TEMP' }); + > {type: 'number', role: 'value.temperature', name: 'TEMP'}); await createAliasAsync(config.weatherEntity + '.TEMP_MIN', 'daswetter.' + weatherAdapterInstanceNumber + '.NextDays.Location_1.Day_1.Minimale_Temperatur_value', true, < iobJS.StateCommon - >{ type: 'number', role: 'value.temperature.forecast.0', name: 'TEMP_MIN' }); + > {type: 'number', role: 'value.temperature.forecast.0', name: 'TEMP_MIN'}); await createAliasAsync(config.weatherEntity + '.TEMP_MAX', 'daswetter.' + weatherAdapterInstanceNumber + '.NextDays.Location_1.Day_1.Maximale_Temperatur_value', true, < iobJS.StateCommon - >{ type: 'number', role: 'value.temperature.max.forecast.0', name: 'TEMP_MAX' }); + > {type: 'number', role: 'value.temperature.max.forecast.0', name: 'TEMP_MAX'}); } else { log('weather alias for daswetter.' + weatherAdapterInstanceNumber + '. already exists', 'info'); } @@ -2494,23 +2502,23 @@ async function CreateWeatherAlias() { if (isSetOptionActive) { if (!existsState(config.weatherEntity + '.ICON') && existsState('accuweather.' + weatherAdapterInstanceNumber + '.Current.WeatherIcon')) { log('Weather alias for accuweather.' + weatherAdapterInstanceNumber + '. does not exist yet, will be created now', 'info'); - setObject(config.weatherEntity, { _id: config.weatherEntity, type: 'channel', common: { role: 'weatherCurrent', name: 'media' }, native: {} }); - await createAliasAsync(config.weatherEntity + '.ICON', 'accuweather.' + weatherAdapterInstanceNumber + '.Current.WeatherIcon', true, { + setObject(config.weatherEntity, {_id: config.weatherEntity, type: 'channel', common: {role: 'weatherCurrent', name: 'media'}, native: {}}); + await createAliasAsync(config.weatherEntity + '.ICON', 'accuweather.' + weatherAdapterInstanceNumber + '.Current.WeatherIcon', true, { type: 'number', role: 'value', name: 'ICON', }); - await createAliasAsync(config.weatherEntity + '.TEMP', 'accuweather.' + weatherAdapterInstanceNumber + '.Current.Temperature', true, { + await createAliasAsync(config.weatherEntity + '.TEMP', 'accuweather.' + weatherAdapterInstanceNumber + '.Current.Temperature', true, { type: 'number', role: 'value.temperature', name: 'TEMP', }); - await createAliasAsync(config.weatherEntity + '.TEMP_MIN', 'accuweather.' + weatherAdapterInstanceNumber + '.Daily.Day1.Temperature.Minimum', true, { + await createAliasAsync(config.weatherEntity + '.TEMP_MIN', 'accuweather.' + weatherAdapterInstanceNumber + '.Daily.Day1.Temperature.Minimum', true, { type: 'number', role: 'value.temperature.forecast.0', name: 'TEMP_MIN', }); - await createAliasAsync(config.weatherEntity + '.TEMP_MAX', 'accuweather.' + weatherAdapterInstanceNumber + '.Daily.Day1.Temperature.Maximum', true, { + await createAliasAsync(config.weatherEntity + '.TEMP_MAX', 'accuweather.' + weatherAdapterInstanceNumber + '.Daily.Day1.Temperature.Maximum', true, { type: 'number', role: 'value.temperature.max.forecast.0', name: 'TEMP_MAX', @@ -2538,11 +2546,11 @@ CreateWeatherAlias(); * * @returns {Promise} - A Promise that resolves when the state is created and set successfully. */ -async function InitPageNavi() { +async function InitPageNavi () { try { if (!existsState(NSPanel_Path + 'PageNavi')) { - await createStateAsync(NSPanel_Path + 'PageNavi', { type: 'string', write: true }); - await setStateAsync(NSPanel_Path + 'PageNavi', { val: "{ pagetype: 'page', pageId: 0 }", ack: true }); + await createStateAsync(NSPanel_Path + 'PageNavi', {type: 'string', write: true}); + await setStateAsync(NSPanel_Path + 'PageNavi', {val: "{ pagetype: 'page', pageId: 0 }", ack: true}); } } catch (err: any) { log('error at function InitPageNavi: ' + err.message, 'warn'); @@ -2562,7 +2570,7 @@ InitPageNavi(); * @async * @throws {Error} If an error occurs while parsing the JSON value or generating the page. */ -on({ id: [NSPanel_Path + 'PageNavi'], change: 'any' }, async function (obj) { +on({id: [NSPanel_Path + 'PageNavi'], change: 'any'}, async function (obj) { try { if (existsState(NSPanel_Path + 'PageNavi')) { try { @@ -2588,10 +2596,10 @@ on({ id: [NSPanel_Path + 'PageNavi'], change: 'any' }, async function (obj) { * @returns {void} * @throws {Error} If an error occurs while sending the payload to the panel. */ -function ScreensaverDimmode(timeDimMode: NSPanel.DimMode) { +function ScreensaverDimmode (timeDimMode: NSPanel.DimMode) { try { - let brightness:number = 100; - let dimBrightness:number = -1; + let brightness: number = 100; + let dimBrightness: number = -1; if (existsState(NSPanel_Path + 'ScreensaverInfo.activeBrightness')) { brightness = getState(NSPanel_Path + 'ScreensaverInfo.activeBrightness').val; } @@ -2608,7 +2616,7 @@ function ScreensaverDimmode(timeDimMode: NSPanel.DimMode) { } if (timeDimMode.dimmodeOn != undefined ? timeDimMode.dimmodeOn : false) { if (compareTime(timeDimMode.timeNight != undefined ? timeDimMode.timeNight : '22:00', timeDimMode.timeDay != undefined ? timeDimMode.timeDay : '07:00', 'not between', undefined)) { - SendToPanel({ payload: 'dimmode~' + timeDimMode.brightnessDay + '~' + active + '~' + rgb_dec565(config.defaultBackgroundColor) + '~' + rgb_dec565(globalTextColor) + '~' + Sliders2 }); + SendToPanel({payload: 'dimmode~' + timeDimMode.brightnessDay + '~' + active + '~' + rgb_dec565(config.defaultBackgroundColor) + '~' + rgb_dec565(globalTextColor) + '~' + Sliders2}); if (Debug) { log('function ScreensaverDimmode -> Day NSPanel.Payload: ' + 'dimmode~' + timeDimMode.brightnessDay + '~' + active, 'info'); } @@ -2621,7 +2629,7 @@ function ScreensaverDimmode(timeDimMode: NSPanel.DimMode) { } } } else { - SendToPanel({ payload: 'dimmode~' + dimmode + '~' + active + '~' + rgb_dec565(config.defaultBackgroundColor) + '~' + rgb_dec565(globalTextColor) + '~' + Sliders2 }); + SendToPanel({payload: 'dimmode~' + dimmode + '~' + active + '~' + rgb_dec565(config.defaultBackgroundColor) + '~' + rgb_dec565(globalTextColor) + '~' + Sliders2}); } } catch (err: any) { log('error at function ScreensaverDimmode: ' + err.message, 'warn'); @@ -2637,7 +2645,7 @@ function ScreensaverDimmode(timeDimMode: NSPanel.DimMode) { * * @returns {Promise} - A Promise that resolves when the states are created and set successfully. */ -async function InitWeatherForecast() { +async function InitWeatherForecast () { try { if (isSetOptionActive) { //----Ability to choose between Accu-Weather Forecast or self-defined values in the screensaver--------------------------------- @@ -2646,42 +2654,42 @@ async function InitWeatherForecast() { existsState(NSPanel_Path + 'ScreensaverInfo.weatherForecastTimer') == false || existsState(NSPanel_Path + 'ScreensaverInfo.entityChangeTime') == false ) { - await createStateAsync(NSPanel_Path + 'ScreensaverInfo.weatherForecast', true, { type: 'boolean', write: true }); - await createStateAsync(NSPanel_Path + 'ScreensaverInfo.weatherForecastTimer', true, { type: 'boolean', write: true }); - await createStateAsync(NSPanel_Path + 'ScreensaverInfo.entityChangeTime', 60, { type: 'number', write: true }); + await createStateAsync(NSPanel_Path + 'ScreensaverInfo.weatherForecast', true, {type: 'boolean', write: true}); + await createStateAsync(NSPanel_Path + 'ScreensaverInfo.weatherForecastTimer', true, {type: 'boolean', write: true}); + await createStateAsync(NSPanel_Path + 'ScreensaverInfo.entityChangeTime', 60, {type: 'number', write: true}); } //Create Alias weatherForecast - setObject(AliasPath + 'ScreensaverInfo.weatherForecast', { type: 'channel', common: { role: 'socket', name: 'weatherForecast' }, native: {} }); - await createAliasAsync(AliasPath + 'ScreensaverInfo.weatherForecast.ACTUAL', NSPanel_Path + 'ScreensaverInfo.weatherForecast', true, { + setObject(AliasPath + 'ScreensaverInfo.weatherForecast', {type: 'channel', common: {role: 'socket', name: 'weatherForecast'}, native: {}}); + await createAliasAsync(AliasPath + 'ScreensaverInfo.weatherForecast.ACTUAL', NSPanel_Path + 'ScreensaverInfo.weatherForecast', true, { type: 'boolean', role: 'switch', name: 'ACTUAL', }); - await createAliasAsync(AliasPath + 'ScreensaverInfo.weatherForecast.SET', NSPanel_Path + 'ScreensaverInfo.weatherForecast', true, { + await createAliasAsync(AliasPath + 'ScreensaverInfo.weatherForecast.SET', NSPanel_Path + 'ScreensaverInfo.weatherForecast', true, { type: 'boolean', role: 'switch', name: 'SET', }); //Create Alias weatherForecastTimer - setObject(AliasPath + 'ScreensaverInfo.weatherForecastTimer', { type: 'channel', common: { role: 'socket', name: 'weatherForecastTimer' }, native: {} }); - await createAliasAsync(AliasPath + 'ScreensaverInfo.weatherForecastTimer.ACTUAL', NSPanel_Path + 'ScreensaverInfo.weatherForecastTimer', true, { + setObject(AliasPath + 'ScreensaverInfo.weatherForecastTimer', {type: 'channel', common: {role: 'socket', name: 'weatherForecastTimer'}, native: {}}); + await createAliasAsync(AliasPath + 'ScreensaverInfo.weatherForecastTimer.ACTUAL', NSPanel_Path + 'ScreensaverInfo.weatherForecastTimer', true, { type: 'boolean', role: 'switch', name: 'ACTUAL', }); - await createAliasAsync(AliasPath + 'ScreensaverInfo.weatherForecastTimer.SET', NSPanel_Path + 'ScreensaverInfo.weatherForecastTimer', true, { + await createAliasAsync(AliasPath + 'ScreensaverInfo.weatherForecastTimer.SET', NSPanel_Path + 'ScreensaverInfo.weatherForecastTimer', true, { type: 'boolean', role: 'switch', name: 'SET', }); //Create Alias entityChangeTime - setObject(AliasPath + 'ScreensaverInfo.entityChangeTime', { type: 'channel', common: { role: 'slider', name: 'entityChangeTime' }, native: {} }); - await createAliasAsync(AliasPath + 'ScreensaverInfo.entityChangeTime.ACTUAL', NSPanel_Path + 'ScreensaverInfo.entityChangeTime', true, { + setObject(AliasPath + 'ScreensaverInfo.entityChangeTime', {type: 'channel', common: {role: 'slider', name: 'entityChangeTime'}, native: {}}); + await createAliasAsync(AliasPath + 'ScreensaverInfo.entityChangeTime.ACTUAL', NSPanel_Path + 'ScreensaverInfo.entityChangeTime', true, { type: 'number', role: 'value', name: 'ACTUAL', }); - await createAliasAsync(AliasPath + 'ScreensaverInfo.entityChangeTime.SET', NSPanel_Path + 'ScreensaverInfo.entityChangeTime', true, { + await createAliasAsync(AliasPath + 'ScreensaverInfo.entityChangeTime.SET', NSPanel_Path + 'ScreensaverInfo.entityChangeTime', true, { type: 'number', role: 'level', name: 'SET', @@ -2702,53 +2710,53 @@ InitWeatherForecast(); * * @returns {Promise} - A Promise that resolves when the states are created and set successfully. */ -async function InitDimmode() { +async function InitDimmode () { try { if (isSetOptionActive) { // Screensaver on dark at night ("brightnessNight: e.g. 2") or off ("brightnessNight:0") if (!existsState(NSPanel_Path + 'NSPanel_Dimmode_brightnessDay')) { - await createStateAsync(NSPanel_Path + 'NSPanel_Dimmode_brightnessDay', { type: 'number', write: true }); - await setStateAsync(NSPanel_Path + 'NSPanel_Dimmode_brightnessDay', { val: 8, ack: true }); - setObject(AliasPath + 'Dimmode.brightnessDay', { type: 'channel', common: { role: 'slider', name: 'brightnessDay' }, native: {} }); - await createAliasAsync(AliasPath + 'Dimmode.brightnessDay.ACTUAL', NSPanel_Path + 'NSPanel_Dimmode_brightnessDay', true, { + await createStateAsync(NSPanel_Path + 'NSPanel_Dimmode_brightnessDay', {type: 'number', write: true}); + await setStateAsync(NSPanel_Path + 'NSPanel_Dimmode_brightnessDay', {val: 8, ack: true}); + setObject(AliasPath + 'Dimmode.brightnessDay', {type: 'channel', common: {role: 'slider', name: 'brightnessDay'}, native: {}}); + await createAliasAsync(AliasPath + 'Dimmode.brightnessDay.ACTUAL', NSPanel_Path + 'NSPanel_Dimmode_brightnessDay', true, { type: 'number', role: 'value', name: 'ACTUAL', }); - await createAliasAsync(AliasPath + 'Dimmode.brightnessDay.SET', NSPanel_Path + 'NSPanel_Dimmode_brightnessDay', true, { + await createAliasAsync(AliasPath + 'Dimmode.brightnessDay.SET', NSPanel_Path + 'NSPanel_Dimmode_brightnessDay', true, { type: 'number', role: 'level', name: 'SET', }); } if (!existsState(NSPanel_Path + 'NSPanel_Dimmode_hourDay')) { - await createStateAsync(NSPanel_Path + 'NSPanel_Dimmode_hourDay', { type: 'number', write: true }); - await setStateAsync(NSPanel_Path + 'NSPanel_Dimmode_hourDay', { val: 7, ack: true }); - setObject(AliasPath + 'Dimmode.hourDay', { type: 'channel', common: { role: 'slider', name: 'hourDay' }, native: {} }); - await createAliasAsync(AliasPath + 'Dimmode.hourDay.ACTUAL', NSPanel_Path + 'NSPanel_Dimmode_hourDay', true, { type: 'number', role: 'value', name: 'ACTUAL' }); - await createAliasAsync(AliasPath + 'Dimmode.hourDay.SET', NSPanel_Path + 'NSPanel_Dimmode_hourDay', true, { type: 'number', role: 'level', name: 'SET' }); + await createStateAsync(NSPanel_Path + 'NSPanel_Dimmode_hourDay', {type: 'number', write: true}); + await setStateAsync(NSPanel_Path + 'NSPanel_Dimmode_hourDay', {val: 7, ack: true}); + setObject(AliasPath + 'Dimmode.hourDay', {type: 'channel', common: {role: 'slider', name: 'hourDay'}, native: {}}); + await createAliasAsync(AliasPath + 'Dimmode.hourDay.ACTUAL', NSPanel_Path + 'NSPanel_Dimmode_hourDay', true, {type: 'number', role: 'value', name: 'ACTUAL'}); + await createAliasAsync(AliasPath + 'Dimmode.hourDay.SET', NSPanel_Path + 'NSPanel_Dimmode_hourDay', true, {type: 'number', role: 'level', name: 'SET'}); } if (!existsState(NSPanel_Path + 'NSPanel_Dimmode_brightnessNight')) { - await createStateAsync(NSPanel_Path + 'NSPanel_Dimmode_brightnessNight', { type: 'number', write: true }); - await setStateAsync(NSPanel_Path + 'NSPanel_Dimmode_brightnessNight', { val: 1, ack: true }); - setObject(AliasPath + 'Dimmode.brightnessNight', { type: 'channel', common: { role: 'slider', name: 'brightnessNight' }, native: {} }); - await createAliasAsync(AliasPath + 'Dimmode.brightnessNight.ACTUAL', NSPanel_Path + 'NSPanel_Dimmode_brightnessNight', true, { + await createStateAsync(NSPanel_Path + 'NSPanel_Dimmode_brightnessNight', {type: 'number', write: true}); + await setStateAsync(NSPanel_Path + 'NSPanel_Dimmode_brightnessNight', {val: 1, ack: true}); + setObject(AliasPath + 'Dimmode.brightnessNight', {type: 'channel', common: {role: 'slider', name: 'brightnessNight'}, native: {}}); + await createAliasAsync(AliasPath + 'Dimmode.brightnessNight.ACTUAL', NSPanel_Path + 'NSPanel_Dimmode_brightnessNight', true, { type: 'number', role: 'value', name: 'ACTUAL', }); - await createAliasAsync(AliasPath + 'Dimmode.brightnessNight.SET', NSPanel_Path + 'NSPanel_Dimmode_brightnessNight', true, { + await createAliasAsync(AliasPath + 'Dimmode.brightnessNight.SET', NSPanel_Path + 'NSPanel_Dimmode_brightnessNight', true, { type: 'number', role: 'level', name: 'SET', }); } if (!existsState(NSPanel_Path + 'NSPanel_Dimmode_hourNight')) { - await createStateAsync(NSPanel_Path + 'NSPanel_Dimmode_hourNight', { type: 'number', write: true }); - await setStateAsync(NSPanel_Path + 'NSPanel_Dimmode_hourNight', { val: 22, ack: true }); - setObject(AliasPath + 'Dimmode.hourNight', { type: 'channel', common: { role: 'slider', name: 'hourNight' }, native: {} }); - await createAliasAsync(AliasPath + 'Dimmode.hourNight.ACTUAL', NSPanel_Path + 'NSPanel_Dimmode_hourNight', true, { type: 'number', role: 'value', name: 'ACTUAL' }); - await createAliasAsync(AliasPath + 'Dimmode.hourNight.SET', NSPanel_Path + 'NSPanel_Dimmode_hourNight', true, { type: 'number', role: 'level', name: 'SET' }); + await createStateAsync(NSPanel_Path + 'NSPanel_Dimmode_hourNight', {type: 'number', write: true}); + await setStateAsync(NSPanel_Path + 'NSPanel_Dimmode_hourNight', {val: 22, ack: true}); + setObject(AliasPath + 'Dimmode.hourNight', {type: 'channel', common: {role: 'slider', name: 'hourNight'}, native: {}}); + await createAliasAsync(AliasPath + 'Dimmode.hourNight.ACTUAL', NSPanel_Path + 'NSPanel_Dimmode_hourNight', true, {type: 'number', role: 'value', name: 'ACTUAL'}); + await createAliasAsync(AliasPath + 'Dimmode.hourNight.SET', NSPanel_Path + 'NSPanel_Dimmode_hourNight', true, {type: 'number', role: 'level', name: 'SET'}); } const vTimeDay = getState(NSPanel_Path + 'NSPanel_Dimmode_hourDay').val; const vTimeNight = getState(NSPanel_Path + 'NSPanel_Dimmode_hourNight').val; @@ -2760,13 +2768,13 @@ async function InitDimmode() { timeNight: vTimeNight < 10 ? `0${vTimeNight}:00` : `${vTimeNight}:00`, }; // timeDimMode Day - scheduleInitDimModeDay = adapterSchedule({ hour: getState(NSPanel_Path + 'NSPanel_Dimmode_hourDay').val, minute: 0 }, 24 * 60 * 60, () => { + scheduleInitDimModeDay = adapterSchedule({hour: getState(NSPanel_Path + 'NSPanel_Dimmode_hourDay').val, minute: 0}, 24 * 60 * 60, () => { if (getState(NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness').val != null && getState(NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness').val == -1) { ScreensaverDimmode(timeDimMode); } }); // timeDimMode Night - scheduleInitDimModeNight = adapterSchedule({ hour: getState(NSPanel_Path + 'NSPanel_Dimmode_hourNight').val, minute: 0 }, 24 * 60 * 60, () => { + scheduleInitDimModeNight = adapterSchedule({hour: getState(NSPanel_Path + 'NSPanel_Dimmode_hourNight').val, minute: 0}, 24 * 60 * 60, () => { if (getState(NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness').val != null && getState(NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness').val == -1) { ScreensaverDimmode(timeDimMode); } @@ -2774,21 +2782,21 @@ async function InitDimmode() { if (getState(NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness').val != null && getState(NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness').val != -1) { SendToPanel({ payload: - 'dimmode~' + getState(NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness').val + '~' + (getState(NSPanel_Path + 'ScreensaverInfo.activeBrightness').val ?? '80') + '~' + - (getState(NSPanel_Path + 'ScreensaverInfo.activeBrightness').val ?? '80')+ '~' + rgb_dec565(config.defaultBackgroundColor) + '~' + rgb_dec565(globalTextColor) + '~' + Sliders2, + 'dimmode~' + getState(NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness').val + '~' + (getState(NSPanel_Path + 'ScreensaverInfo.activeBrightness').val ?? '80') + '~' + + (getState(NSPanel_Path + 'ScreensaverInfo.activeBrightness').val ?? '80') + '~' + rgb_dec565(config.defaultBackgroundColor) + '~' + rgb_dec565(globalTextColor) + '~' + Sliders2, }); } else { if (isDimTimeInRange(timeDimMode.timeDay, timeDimMode.timeNight)) { SendToPanel({ payload: 'dimmode~' + timeDimMode.brightnessDay + '~' + (getState(NSPanel_Path + 'ScreensaverInfo.activeBrightness').val ?? - '80') + '~' + rgb_dec565(config.defaultBackgroundColor) + '~' + rgb_dec565(globalTextColor) + '~' + Sliders2, + '80') + '~' + rgb_dec565(config.defaultBackgroundColor) + '~' + rgb_dec565(globalTextColor) + '~' + Sliders2, }); } else { SendToPanel({ payload: 'dimmode~' + timeDimMode.brightnessNight + '~' + (getState(NSPanel_Path + 'ScreensaverInfo.activeBrightness').val ?? - '80') + '~' + rgb_dec565(config.defaultBackgroundColor) + '~' + rgb_dec565(globalTextColor) + '~' + Sliders2, + '80') + '~' + rgb_dec565(config.defaultBackgroundColor) + '~' + rgb_dec565(globalTextColor) + '~' + Sliders2, }); } ScreensaverDimmode(timeDimMode); @@ -2805,7 +2813,7 @@ InitDimmode(); * This is used to compare with the Dimmode dates. * @returns {Date} The current date as a Date object. */ -function currentDimDate() { +function currentDimDate () { let d = new Date(); return new Date(d.getFullYear(), d.getMonth(), d.getDate()); } @@ -2815,7 +2823,7 @@ function currentDimDate() { * @param {string} strTime - The time string to add to the current date. * @returns {Date} The resulting date object. */ -function addDimTime(strTime) { +function addDimTime (strTime) { let time = strTime.split(':'); let d = currentDimDate(); d.setHours(time[0]); @@ -2834,7 +2842,7 @@ function addDimTime(strTime) { * @param {string} strUpper - The upper bound of the range. * @returns {boolean} true if the current time is within the range, false otherwise. */ -function isDimTimeInRange(strLower, strUpper) { +function isDimTimeInRange (strLower, strUpper) { let now = new Date(); let lower = addDimTime(strLower); let upper = addDimTime(strUpper); @@ -2860,7 +2868,7 @@ function isDimTimeInRange(strLower, strUpper) { * @param {number|undefined} [Relays] - The number of relays that are currently on. If undefined, it is assumed to be 0. * @returns {number|undefined} The calculated consumption in Watts, or undefined if an error occurs. */ -async function Calc_Consumption(Brightness: number, Relays: number|undefined) { +async function Calc_Consumption (Brightness: number, Relays: number | undefined) { try { if (Relays == undefined) Relays = 0; return parseFloat((Relays * 0.25 + (0.0086 * Brightness + 0.7429)).toFixed(2)); @@ -2876,7 +2884,7 @@ async function Calc_Consumption(Brightness: number, Relays: number|undefined) { * @param {string} Path - The path to the Relays states. * @returns {Promise} The number of Relays that are currently on. */ -async function CountRelaysOn(Path: string):Promise { +async function CountRelaysOn (Path: string): Promise { try { let r1: boolean = true; let r2: boolean = true; @@ -2903,47 +2911,47 @@ async function CountRelaysOn(Path: string):Promise { * @param {string} Path - The path to the Dimmode settings and the ScreensaverInfo state. * @returns {Promise} The current brightness or undefined if an error occurs. */ -async function DetermineDimBrightness(Path: string) { - if ( existsState(NSPanel_Path + 'NSPanel_Dimmode_hourDay') && - existsState(NSPanel_Path + 'NSPanel_Dimmode_hourNight') && - existsState(NSPanel_Path + 'NSPanel_Dimmode_brightnessDay') && - existsState(NSPanel_Path + 'NSPanel_Dimmode_brightnessNight') && - existsState(NSPanel_Path + 'ScreensaverInfo') && - existsState(NSPanel_Path + 'ActivePage') - ) { - try { - const vTimeDay = getState(Path + 'NSPanel_Dimmode_hourDay').val; - const vTimeNight = getState(Path + 'NSPanel_Dimmode_hourNight').val; - const timeDimMode: NSPanel.DimMode = { - dimmodeOn: true, - brightnessDay: getState(NSPanel_Path + 'NSPanel_Dimmode_brightnessDay').val, - brightnessNight: getState(NSPanel_Path + 'NSPanel_Dimmode_brightnessNight').val, - timeDay: vTimeDay < 10 ? `0${vTimeDay}:00` : `${vTimeDay}:00`, - timeNight: vTimeNight < 10 ? `0${vTimeNight}:00` : `${vTimeNight}:00`, - }; +async function DetermineDimBrightness (Path: string) { + if (existsState(NSPanel_Path + 'NSPanel_Dimmode_hourDay') && + existsState(NSPanel_Path + 'NSPanel_Dimmode_hourNight') && + existsState(NSPanel_Path + 'NSPanel_Dimmode_brightnessDay') && + existsState(NSPanel_Path + 'NSPanel_Dimmode_brightnessNight') && + existsState(NSPanel_Path + 'ScreensaverInfo') && + existsState(NSPanel_Path + 'ActivePage') + ) { + try { + const vTimeDay = getState(Path + 'NSPanel_Dimmode_hourDay').val; + const vTimeNight = getState(Path + 'NSPanel_Dimmode_hourNight').val; + const timeDimMode: NSPanel.DimMode = { + dimmodeOn: true, + brightnessDay: getState(NSPanel_Path + 'NSPanel_Dimmode_brightnessDay').val, + brightnessNight: getState(NSPanel_Path + 'NSPanel_Dimmode_brightnessNight').val, + timeDay: vTimeDay < 10 ? `0${vTimeDay}:00` : `${vTimeDay}:00`, + timeNight: vTimeNight < 10 ? `0${vTimeNight}:00` : `${vTimeNight}:00`, + }; - if (getState(Path + 'ScreensaverInfo.activeDimmodeBrightness').val == -1) { - if (getState(Path + 'ActivePage.id0').val == 'screensaver') { - return await DetermineScreensaverDimmode(timeDimMode); + if (getState(Path + 'ScreensaverInfo.activeDimmodeBrightness').val == -1) { + if (getState(Path + 'ActivePage.id0').val == 'screensaver') { + return await DetermineScreensaverDimmode(timeDimMode); + } else { + return getState(Path + 'ScreensaverInfo.activeBrightness').val; + } } else { - return getState(Path + 'ScreensaverInfo.activeBrightness').val; + return getState(Path + 'ScreensaverInfo.activeDimmodeBrightness').val; } - } else { - return getState(Path + 'ScreensaverInfo.activeDimmodeBrightness').val; + } catch (err: any) { + log('error at function DetermineDimBrightness: ' + err.message, 'warn'); } - } catch (err: any) { - log('error at function DetermineDimBrightness: ' + err.message, 'warn'); } - } } - /** - * Determines the current brightness based on the Dimmode settings and the current time of day for the screensaver page. - * @param {NSPanel.DimMode} timeDimMode - The object containing the Dimmode settings. - * @returns {Promise} The current brightness or 100 if an error occurs. - */ -async function DetermineScreensaverDimmode(timeDimMode: NSPanel.DimMode): Promise { +/** + * Determines the current brightness based on the Dimmode settings and the current time of day for the screensaver page. + * @param {NSPanel.DimMode} timeDimMode - The object containing the Dimmode settings. + * @returns {Promise} The current brightness or 100 if an error occurs. + */ +async function DetermineScreensaverDimmode (timeDimMode: NSPanel.DimMode): Promise { try { if (timeDimMode.dimmodeOn != undefined ? timeDimMode.dimmodeOn : false) { if (compareTime(timeDimMode.timeNight != undefined ? timeDimMode.timeNight : '22:00', timeDimMode.timeDay != undefined ? timeDimMode.timeDay : '07:00', 'not between', undefined)) { @@ -2971,17 +2979,17 @@ async function DetermineScreensaverDimmode(timeDimMode: NSPanel.DimMode): Promis * @returns {Promise} A promise that resolves when the initialization is complete. * @throws {Error} If an error occurs during initialization. */ -async function InitMeanPowerConsumption() { +async function InitMeanPowerConsumption () { try { const meanPower = NSPanel_Path + 'Consumption.MeanPower'; - let meanConsumption: number|undefined = await Calc_Consumption(await DetermineDimBrightness(NSPanel_Path), await CountRelaysOn(NSPanel_Path)); + let meanConsumption: number | undefined = await Calc_Consumption(await DetermineDimBrightness(NSPanel_Path), await CountRelaysOn(NSPanel_Path)); if (meanConsumption === undefined) { meanConsumption = 0; // Assign a default value if undefined } if (!existsState(meanPower)) { - await createStateAsync(meanPower, { type: 'number', write: true, unit: 'W' }); + await createStateAsync(meanPower, {type: 'number', write: true, unit: 'W'}); } - await setStateAsync(meanPower, { val: meanConsumption, ack: true }); + await setStateAsync(meanPower, {val: meanConsumption, ack: true}); if (Debug) log(meanConsumption + ' W', 'info'); } catch (err: any) { log('error at function InitMeanPowerConsumption: ' + err.message, 'warn'); @@ -3057,43 +3065,43 @@ const popupNotifyBuzzer = NSPanel_Path + 'popupNotify.popupNotifyBuzzer'; // 1,1 * @returns {Promise} A promise that resolves when the initialization is complete. * @throws {Error} If an error occurs during initialization. */ -async function InitPopupNotify() { +async function InitPopupNotify () { try { if (!existsState(screensaverNotifyHeading)) { - await createStateAsync(screensaverNotifyHeading, { type: 'string', write: true }); - await setStateAsync(screensaverNotifyHeading, { val: '', ack: true }); + await createStateAsync(screensaverNotifyHeading, {type: 'string', write: true}); + await setStateAsync(screensaverNotifyHeading, {val: '', ack: true}); } if (!existsState(screensaverNotifyText)) { - await createStateAsync(screensaverNotifyText, { type: 'string', write: true }); - await setStateAsync(screensaverNotifyText, { val: '', ack: true }); + await createStateAsync(screensaverNotifyText, {type: 'string', write: true}); + await setStateAsync(screensaverNotifyText, {val: '', ack: true}); } - await createStateAsync(popupNotifyHeading, { type: 'string', write: true }); - await createStateAsync(popupNotifyHeadingColor, { type: 'string', write: true }); - await createStateAsync(popupNotifyText, { type: 'string', write: true }); - await createStateAsync(popupNotifyTextColor, { type: 'string', write: true }); - await createStateAsync(popupNotifyInternalName, { type: 'string', write: true }); - await createStateAsync(popupNotifyButton1Text, { type: 'string', write: true }); - await createStateAsync(popupNotifyButton1TextColor, { type: 'string', write: true }); - await createStateAsync(popupNotifyButton2Text, { type: 'string', write: true }); - await createStateAsync(popupNotifyButton2TextColor, { type: 'string', write: true }); - await createStateAsync(popupNotifySleepTimeout, { type: 'number', write: true }); - await createStateAsync(popupNotifyAction, { type: 'boolean', write: true }); - await createStateAsync(popupNotifyLayout, { type: 'number', write: true }); - await createStateAsync(popupNotifyFontIdText, { type: 'number', write: true }); - await createStateAsync(popupNotifyIcon, { type: 'string', write: true }); - await createStateAsync(popupNotifyIconColor, { type: 'string', write: true }); - await createStateAsync(popupNotifyBuzzer, { type: 'string', def: '0', write: true }); + await createStateAsync(popupNotifyHeading, {type: 'string', write: true}); + await createStateAsync(popupNotifyHeadingColor, {type: 'string', write: true}); + await createStateAsync(popupNotifyText, {type: 'string', write: true}); + await createStateAsync(popupNotifyTextColor, {type: 'string', write: true}); + await createStateAsync(popupNotifyInternalName, {type: 'string', write: true}); + await createStateAsync(popupNotifyButton1Text, {type: 'string', write: true}); + await createStateAsync(popupNotifyButton1TextColor, {type: 'string', write: true}); + await createStateAsync(popupNotifyButton2Text, {type: 'string', write: true}); + await createStateAsync(popupNotifyButton2TextColor, {type: 'string', write: true}); + await createStateAsync(popupNotifySleepTimeout, {type: 'number', write: true}); + await createStateAsync(popupNotifyAction, {type: 'boolean', write: true}); + await createStateAsync(popupNotifyLayout, {type: 'number', write: true}); + await createStateAsync(popupNotifyFontIdText, {type: 'number', write: true}); + await createStateAsync(popupNotifyIcon, {type: 'string', write: true}); + await createStateAsync(popupNotifyIconColor, {type: 'string', write: true}); + await createStateAsync(popupNotifyBuzzer, {type: 'string', def: '0', write: true}); // Notification to screensaver - on({ id: [screensaverNotifyHeading, screensaverNotifyText], change: 'ne', ack: false }, async (obj) => { + on({id: [screensaverNotifyHeading, screensaverNotifyText], change: 'ne', ack: false}, async (obj) => { let heading: string = ''; - let text: string = ''; + let text: string = ''; if (existsState(screensaverNotifyHeading)) { heading = getState(screensaverNotifyHeading).val; } - if (existsState(screensaverNotifyText)) { + if (existsState(screensaverNotifyText)) { text = getState(screensaverNotifyText).val; } @@ -3102,12 +3110,12 @@ async function InitPopupNotify() { } if (obj.id) { - await setStateAsync(obj.id, { val: obj.state.val, ack: true }); // ack new value + await setStateAsync(obj.id, {val: obj.state.val, ack: true}); // ack new value } }); // popupNotify - Notification to a separate page - on({ id: [popupNotifyText], change: 'any' }, async () => { + on({id: [popupNotifyText], change: 'any'}, async () => { let notification: string; let v_popupNotifyHeadingColor = getState(popupNotifyHeadingColor).val != null ? getState(popupNotifyHeadingColor).val : '65504'; // Headline color - yellow 65504 @@ -3120,7 +3128,7 @@ async function InitPopupNotify() { let v_popupNotifyBuzzer = getState(popupNotifyBuzzer).val != null ? getState(popupNotifyBuzzer).val : '0'; let heading: string = ''; - let text: string = ''; + let text: string = ''; if (existsState(popupNotifyHeading)) { heading = getState(popupNotifyHeading).val; } @@ -3176,7 +3184,7 @@ async function InitPopupNotify() { } axios - .get(urlString, { headers: { 'User-Agent': 'ioBroker' } }) + .get(urlString, {headers: {'User-Agent': 'ioBroker'}}) .then(async function (response) { if (response.status === 200) { log('Axios Data: ' + JSON.stringify(response.data), 'info'); @@ -3247,7 +3255,7 @@ let scheduleSwichScreensaver = adapterSchedule(undefined, screensaverChangeTime, try { // WeatherForecast true/false Switchover delayed let heading: string = ''; - let text: string = ''; + let text: string = ''; let wForecast: boolean = true; let wForecastTimer: boolean = true; let changeTime: number = 60; @@ -3272,24 +3280,24 @@ let scheduleSwichScreensaver = adapterSchedule(undefined, screensaverChangeTime, wForecast == true && wForecastTimer == true ) { - setStateDelayed(NSPanel_Path + 'ScreensaverInfo.weatherForecast', {val:false, ack:true}, (changeTime / 2) * 1000, false); + setStateDelayed(NSPanel_Path + 'ScreensaverInfo.weatherForecast', {val: false, ack: true}, (changeTime / 2) * 1000, false); } else if ( heading == '' && text == '' && wForecast == false && wForecastTimer == true ) { - setStateDelayed(NSPanel_Path + 'ScreensaverInfo.weatherForecast', {val:true, ack:true}, (changeTime / 2) * 1000, false); + setStateDelayed(NSPanel_Path + 'ScreensaverInfo.weatherForecast', {val: true, ack: true}, (changeTime / 2) * 1000, false); } } catch (err: any) { log('error at schedule entityChangeTime: ' + err.message, 'warn'); } }); -function InitHWButton1Color() { +function InitHWButton1Color () { try { if ([null, undefined, ''].indexOf(config.mrIcon1ScreensaverEntity.ScreensaverEntity) == -1) { - on({ id: config.mrIcon1ScreensaverEntity.ScreensaverEntity, change: 'ne' }, async function () { + on({id: config.mrIcon1ScreensaverEntity.ScreensaverEntity, change: 'ne'}, async function () { HandleScreensaverUpdate(); }); } @@ -3314,10 +3322,10 @@ InitHWButton1Color(); * * @throws Will log a warning message if an error occurs during execution. */ -function InitHWButton2Color() { +function InitHWButton2Color () { try { - if ([null, undefined, ''].indexOf(config.mrIcon2ScreensaverEntity.ScreensaverEntity) == -1 ) { - on({ id: config.mrIcon2ScreensaverEntity.ScreensaverEntity, change: 'ne' }, async function () { + if ([null, undefined, ''].indexOf(config.mrIcon2ScreensaverEntity.ScreensaverEntity) == -1) { + on({id: config.mrIcon2ScreensaverEntity.ScreensaverEntity, change: 'ne'}, async function () { HandleScreensaverUpdate(); }); } @@ -3338,7 +3346,7 @@ InitHWButton2Color(); * @param {Object} obj - The object containing the state change information. * @throws {Error} If an error occurs during the state change handling. */ -on({ id: [NSPanel_Path + 'ScreensaverInfo.weatherForecast'], change: 'ne' }, async function (obj) { +on({id: [NSPanel_Path + 'ScreensaverInfo.weatherForecast'], change: 'ne'}, async function (obj) { try { weatherForecast = obj.state.val; HandleScreensaverUpdate(); @@ -3358,7 +3366,7 @@ on({ id: [NSPanel_Path + 'ScreensaverInfo.weatherForecast'], change: 'ne' }, asy * @param {Object} obj - The object containing the state change information. * @throws {Error} If an error occurs during the state change handling. */ -on({ id: [config.weatherEntity + '.TEMP', config.weatherEntity + '.ICON'], change: 'ne' }, async function (obj) { +on({id: [config.weatherEntity + '.TEMP', config.weatherEntity + '.ICON'], change: 'ne'}, async function (obj) { try { HandleScreensaverUpdate(); } catch (err: any) { @@ -3377,10 +3385,10 @@ on({ id: [config.weatherEntity + '.TEMP', config.weatherEntity + '.ICON'], chang * @param {Object} obj - The object containing the state change information. * @throws {Error} If an error occurs during the state change handling. */ -on({ id: [NSPanel_Path + 'Config.Screensaver.timeoutScreensaver'], change: 'ne' }, async function (obj) { +on({id: [NSPanel_Path + 'Config.Screensaver.timeoutScreensaver'], change: 'ne'}, async function (obj) { try { let timeout = obj.state.val; - SendToPanel({ payload: 'timeout~' + timeout }); + SendToPanel({payload: 'timeout~' + timeout}); } catch (err: any) { log('error at trigger timeoutScreensaver: ' + err.message, 'warn'); } @@ -3391,7 +3399,7 @@ let scheduleSendDate = adapterSchedule(new Date().setMinutes(0, 0), 60 * 60, () }); // 3:30 a.m. Perform startup and receive current TFT version -let scheduleStartup = adapterSchedule({ hour: 3, minute: 30 }, 24 * 60 * 60, async () => { +let scheduleStartup = adapterSchedule({hour: 3, minute: 30}, 24 * 60 * 60, async () => { setIfExists(config.panelSendTopic, 'pageType~pageStartup'); }); @@ -3439,7 +3447,7 @@ setTimeout(async function () { * @returns {String} The locale string for Moment.js. * @throws {Error} If an error occurs during the locale retrieval. */ -function getMomentjsLocale(): String { +function getMomentjsLocale (): String { try { let locale = 'en-US'; if (existsState(NSPanel_Path + 'Config.locale')) { @@ -3468,7 +3476,7 @@ function getMomentjsLocale(): String { * @returns {Promise} A promise that resolves when the locales have been fetched and stored. * @throws {Error} If an error occurs during the request or state update. */ -async function get_locales() { +async function get_locales () { try { if (Debug) { log('Requesting locales', 'info'); @@ -3476,14 +3484,14 @@ async function get_locales() { let urlString: string = 'https://raw.githubusercontent.com/joBr99/nspanel-lovelace-ui/main/ioBroker/ioBroker_NSPanel_locales.json'; axios - .get(urlString, { headers: { 'User-Agent': 'ioBroker' } }) + .get(urlString, {headers: {'User-Agent': 'ioBroker'}}) .then(async function (response) { if (response.status === 200) { if (Debug) { log(JSON.stringify(response.data), 'info'); } - await createStateAsync(NSPanel_Path + 'NSPanel_locales_json', { type: 'string', role: 'json', write: false }); - await setStateAsync(NSPanel_Path + 'NSPanel_locales_json', { val: JSON.stringify(response.data), ack: true }); + await createStateAsync(NSPanel_Path + 'NSPanel_locales_json', {type: 'string', role: 'json', write: false}); + await setStateAsync(NSPanel_Path + 'NSPanel_locales_json', {val: JSON.stringify(response.data), ack: true}); } else { log('Axios Status - Requesting locales: ' + response.state, 'warn'); } @@ -3508,7 +3516,7 @@ async function get_locales() { * @returns {Promise} A promise that resolves when the locales have been fetched and stored. * @throws {Error} If an error occurs during the request or state update. */ -async function get_locales_servicemenu() { +async function get_locales_servicemenu () { try { if (Debug) { log('Requesting locales Service Menu', 'info'); @@ -3516,14 +3524,14 @@ async function get_locales_servicemenu() { let urlString: string = 'https://raw.githubusercontent.com/joBr99/nspanel-lovelace-ui/main/ioBroker/ioBroker_NSPanel_locales_service.json'; axios - .get(urlString, { headers: { 'User-Agent': 'ioBroker' } }) + .get(urlString, {headers: {'User-Agent': 'ioBroker'}}) .then(async function (response) { if (response.status === 200) { if (Debug) { log(JSON.stringify(response.data), 'info'); } - await createStateAsync(NSPanel_Path + 'NSPanel_locales_service_json', { type: 'string', role: 'json', write: false }); - await setStateAsync(NSPanel_Path + 'NSPanel_locales_service_json', { val: JSON.stringify(response.data), ack: true }); + await createStateAsync(NSPanel_Path + 'NSPanel_locales_service_json', {type: 'string', role: 'json', write: false}); + await setStateAsync(NSPanel_Path + 'NSPanel_locales_service_json', {val: JSON.stringify(response.data), ack: true}); } else { log('Axios Status - Requesting locales Service Menu: ' + response.state, 'warn'); } @@ -3546,7 +3554,7 @@ async function get_locales_servicemenu() { * @returns {Promise} A promise that resolves when the update check is complete. * @throws {Error} If an error occurs during the update check. */ -async function check_updates() { +async function check_updates () { try { if (Debug) log('Check-Updates', 'info'); @@ -3577,7 +3585,7 @@ async function check_updates() { update_tasmota_firmware(); // Current Tasmota version = online Tasmota version - await setStateAsync(NSPanel_Path + 'Tasmota_Firmware.currentVersion', { val: getState(NSPanel_Path + 'Tasmota_Firmware.onlineVersion').val, ack: true }); + await setStateAsync(NSPanel_Path + 'Tasmota_Firmware.currentVersion', {val: getState(NSPanel_Path + 'Tasmota_Firmware.onlineVersion').val, ack: true}); } else { // Point out Tasmota updates if (Debug) log('Tasmota-Firmware => Automatische Updates aus, manuelles Update nötig', 'info'); @@ -3615,7 +3623,7 @@ async function check_updates() { // Tasmota Berry-Driver Update durchführen update_berry_driver_version(); // Aktuelle Berry-Driver Version = Online Berry-Driver Version - await setStateAsync(NSPanel_Path + 'Berry_Driver.currentVersion', { val: getState(NSPanel_Path + 'Berry_Driver.onlineVersion').val, ack: true }); + await setStateAsync(NSPanel_Path + 'Berry_Driver.currentVersion', {val: getState(NSPanel_Path + 'Berry_Driver.onlineVersion').val, ack: true}); if (Debug) log('Berry driver updated automatically', 'info'); } else { @@ -3647,7 +3655,7 @@ async function check_updates() { // TFT-Firmware-Vergleich if (existsObject(NSPanel_Path + 'Display_Firmware.currentVersion')) { - if (parseInt(getState(NSPanel_Path + 'Display_Firmware.currentVersion').val) == 0) { + if (parseInt(getState(NSPanel_Path + 'Display_Firmware.currentVersion').val) == 0) { log('Actual TFT-firmware version just not not initialized', 'info'); } else { if (parseInt(getState(NSPanel_Path + 'Display_Firmware.currentVersion').val) < desired_display_firmware_version) { @@ -3657,31 +3665,31 @@ async function check_updates() { // TFT-Firmware Update durchführen update_tft_firmware(); - + // Aktuelle TFT-Firmware Version = Online TFT-Firmware Version - await setStateAsync(NSPanel_Path + 'Display_Firmware.currentVersion', { val: getState(NSPanel_Path + 'Display_Firmware.onlineVersion').val, ack: true }); + await setStateAsync(NSPanel_Path + 'Display_Firmware.currentVersion', {val: getState(NSPanel_Path + 'Display_Firmware.onlineVersion').val, ack: true}); if (Debug) log('Display firmware updated automatically', 'info'); } else { - // Auf TFT-Firmware hinweisen - if (Debug) log('Display firmware => Automatic updates off, manual update required', 'info'); + // Auf TFT-Firmware hinweisen + if (Debug) log('Display firmware => Automatic updates off, manual update required', 'info'); - InternalName = 'TFTFirmwareUpdate'; - Headline = 'TFT-Firmware Update'; + InternalName = 'TFTFirmwareUpdate'; + Headline = 'TFT-Firmware Update'; Text = [ - 'Es ist eine neue Version der TFT-Firmware', - '\r\n', - 'verfügbar', - '\r\n', - '\r\n', - 'Installierte Version: ' + String(getState(String(NSPanel_Path) + 'Display_Firmware.currentVersion').val), + 'Es ist eine neue Version der TFT-Firmware', '\r\n', - 'Verfügbare Version: ' + String(desired_display_firmware_version), - '\r\n', - '\r\n', - 'Upgrade durchführen?', - ].join(''); - Update = true; + 'verfügbar', + '\r\n', + '\r\n', + 'Installierte Version: ' + String(getState(String(NSPanel_Path) + 'Display_Firmware.currentVersion').val), + '\r\n', + 'Verfügbare Version: ' + String(desired_display_firmware_version), + '\r\n', + '\r\n', + 'Upgrade durchführen?', + ].join(''); + Update = true; } } } else { @@ -3694,16 +3702,16 @@ async function check_updates() { update_message = getState(NSPanel_Path + 'Config.Update.UpdateMessage').val; } if (Update && update_message) { - await setStateAsync(popupNotifyHeading, { val: Headline, ack: false }); - await setStateAsync(popupNotifyHeadingColor, { val: HeadlineColor, ack: false }); - await setStateAsync(popupNotifyButton1Text, { val: Button1, ack: false }); - await setStateAsync(popupNotifyButton1TextColor, { val: Button1Color, ack: false }); - await setStateAsync(popupNotifyButton2Text, { val: Button2, ack: false }); - await setStateAsync(popupNotifyButton2TextColor, { val: Button2Color, ack: false }); - await setStateAsync(popupNotifySleepTimeout, { val: Timeout, ack: false }); - await setStateAsync(popupNotifyInternalName, { val: InternalName, ack: false }); - await setStateAsync(popupNotifyLayout, { val: Layout, ack: false }); - await setStateAsync(popupNotifyText, { val: [formatDate(getDateObject(new Date().getTime()), 'TT.MM.JJJJ SS:mm:ss'), '\r\n', '\r\n', Text].join(''), ack: false }); + await setStateAsync(popupNotifyHeading, {val: Headline, ack: false}); + await setStateAsync(popupNotifyHeadingColor, {val: HeadlineColor, ack: false}); + await setStateAsync(popupNotifyButton1Text, {val: Button1, ack: false}); + await setStateAsync(popupNotifyButton1TextColor, {val: Button1Color, ack: false}); + await setStateAsync(popupNotifyButton2Text, {val: Button2, ack: false}); + await setStateAsync(popupNotifyButton2TextColor, {val: Button2Color, ack: false}); + await setStateAsync(popupNotifySleepTimeout, {val: Timeout, ack: false}); + await setStateAsync(popupNotifyInternalName, {val: InternalName, ack: false}); + await setStateAsync(popupNotifyLayout, {val: Layout, ack: false}); + await setStateAsync(popupNotifyText, {val: [formatDate(getDateObject(new Date().getTime()), 'TT.MM.JJJJ SS:mm:ss'), '\r\n', '\r\n', Text].join(''), ack: false}); } else if (Update && !update_message) { log('Updates for NSPanel available', 'info'); } else { @@ -3724,7 +3732,8 @@ async function check_updates() { * @param {Object} obj - The object containing the state change information. * @throws {Error} If an error occurs during the state change handling. */ -on({ id: NSPanel_Path + 'popupNotify.popupNotifyAction', change: 'any' }, async function (obj) { try { +on({id: NSPanel_Path + 'popupNotify.popupNotifyAction', change: 'any'}, async function (obj) { + try { const val = obj.state ? obj.state.val : false; if (!val) { if (Debug) { @@ -3760,33 +3769,34 @@ on({ id: NSPanel_Path + 'popupNotify.popupNotifyAction', change: 'any' }, async * @returns {Promise} A promise that resolves when the update data has been retrieved. * @throws {Error} If an error occurs during the data retrieval. */ -async function get_panel_update_data() { try { +async function get_panel_update_data () { + try { if (isSetOptionActive) { - await createStateAsync(NSPanel_Path + 'Config.Update.UpdateMessage', true, { read: true, write: true, name: 'Update-Message', type: 'boolean', def: true }); + await createStateAsync(NSPanel_Path + 'Config.Update.UpdateMessage', true, {read: true, write: true, name: 'Update-Message', type: 'boolean', def: true}); if (autoCreateAlias) { - setObject(AliasPath + 'Config.Update.UpdateMessage', { type: 'channel', common: { role: 'socket', name: 'UpdateMesssage' }, native: {} }); - await createAliasAsync(AliasPath + 'Config.Update.UpdateMessage.ACTUAL', NSPanel_Path + 'Config.Update.UpdateMessage', true, { + setObject(AliasPath + 'Config.Update.UpdateMessage', {type: 'channel', common: {role: 'socket', name: 'UpdateMesssage'}, native: {}}); + await createAliasAsync(AliasPath + 'Config.Update.UpdateMessage.ACTUAL', NSPanel_Path + 'Config.Update.UpdateMessage', true, { type: 'boolean', role: 'switch', name: 'ACTUAL', }); - await createAliasAsync(AliasPath + 'Config.Update.UpdateMessage.SET', NSPanel_Path + 'Config.Update.UpdateMessage', true, { + await createAliasAsync(AliasPath + 'Config.Update.UpdateMessage.SET', NSPanel_Path + 'Config.Update.UpdateMessage', true, { type: 'boolean', role: 'switch', name: 'SET', }); } - await createStateAsync(NSPanel_Path + 'NSPanel_autoUpdate', false, { read: true, write: true, name: 'Auto-Update', type: 'boolean', def: false }); + await createStateAsync(NSPanel_Path + 'NSPanel_autoUpdate', false, {read: true, write: true, name: 'Auto-Update', type: 'boolean', def: false}); if (autoCreateAlias) { - setObject(AliasPath + 'autoUpdate', { type: 'channel', common: { role: 'socket', name: 'AutoUpdate' }, native: {} }); - await createAliasAsync(AliasPath + 'autoUpdate.ACTUAL', NSPanel_Path + 'NSPanel_autoUpdate', true, { type: 'boolean', role: 'switch', name: 'ACTUAL' }); - await createAliasAsync(AliasPath + 'autoUpdate.SET', NSPanel_Path + 'NSPanel_autoUpdate', true, { type: 'boolean', role: 'switch', name: 'SET' }); + setObject(AliasPath + 'autoUpdate', {type: 'channel', common: {role: 'socket', name: 'AutoUpdate'}, native: {}}); + await createAliasAsync(AliasPath + 'autoUpdate.ACTUAL', NSPanel_Path + 'NSPanel_autoUpdate', true, {type: 'boolean', role: 'switch', name: 'ACTUAL'}); + await createAliasAsync(AliasPath + 'autoUpdate.SET', NSPanel_Path + 'NSPanel_autoUpdate', true, {type: 'boolean', role: 'switch', name: 'SET'}); } - await createStateAsync(NSPanel_Path + 'NSPanel_ipAddress', { type: 'string', write: false }); - await setStateAsync(NSPanel_Path + 'NSPanel_ipAddress', { val: get_current_tasmota_ip_address(), ack: true }); + await createStateAsync(NSPanel_Path + 'NSPanel_ipAddress', {type: 'string', write: false}); + await setStateAsync(NSPanel_Path + 'NSPanel_ipAddress', {val: get_current_tasmota_ip_address(), ack: true}); if (autoCreateAlias) { - setObject(AliasPath + 'ipAddress', { type: 'channel', common: { role: 'info', name: 'ipAddress' }, native: {} }); - await createAliasAsync(AliasPath + 'ipAddress.ACTUAL', NSPanel_Path + 'NSPanel_ipAddress', true, { type: 'string', role: 'state', name: 'ACTUAL' }); + setObject(AliasPath + 'ipAddress', {type: 'channel', common: {role: 'info', name: 'ipAddress'}, native: {}}); + await createAliasAsync(AliasPath + 'ipAddress.ACTUAL', NSPanel_Path + 'NSPanel_ipAddress', true, {type: 'string', role: 'state', name: 'ACTUAL'}); } get_online_tasmota_firmware_version(); get_current_berry_driver_version(); @@ -3807,7 +3817,8 @@ async function get_panel_update_data() { try { * @function get_current_tasmota_ip_address * @returns {string} The IP address of the Tasmota device. */ -function get_current_tasmota_ip_address() { try { +function get_current_tasmota_ip_address () { + try { const infoObjId = config.panelRecvTopic.substring(0, config.panelRecvTopic.length - 'RESULT'.length) + 'INFO2'; const infoObj = JSON.parse(getState(infoObjId).val); @@ -3829,7 +3840,7 @@ function get_current_tasmota_ip_address() { try { * @returns {string} The IP address of the Tasmota device. * @throws {Error} If an error occurs during the IP address retrieval. */ -function get_online_tasmota_firmware_version() { +function get_online_tasmota_firmware_version () { try { if (Debug) { log('Requesting tasmota firmware version', 'info'); @@ -3838,7 +3849,7 @@ function get_online_tasmota_firmware_version() { let urlString: string = 'https://api.github.com/repositories/80286288/releases/latest'; axios - .get(urlString, { headers: { 'User-Agent': 'ioBroker' } }) + .get(urlString, {headers: {'User-Agent': 'ioBroker'}}) .then(async function (response) { if (response.status === 200) { if (Debug) { @@ -3848,14 +3859,14 @@ function get_online_tasmota_firmware_version() { const Tasmota_JSON = JSON.parse(JSON.stringify(response.data)); // Write JSON result to variable const TasmotaTagName = Tasmota_JSON.tag_name; // Filter JSON by "tag_name" and write to variable const TasmotaVersionOnline = TasmotaTagName.replace(/v/i, ''); // Filter unnecessary "v" from variable and write to release variable - await createStateAsync(NSPanel_Path + 'Tasmota_Firmware.onlineVersion', { type: 'string', write: false }); - setObject(AliasPath + 'Tasmota_Firmware.onlineVersion', { type: 'channel', common: { role: 'info', name: 'onlineVersion' }, native: {} }); - await createAliasAsync(AliasPath + 'Tasmota_Firmware.onlineVersion.ACTUAL', NSPanel_Path + 'Tasmota_Firmware.onlineVersion', true, { + await createStateAsync(NSPanel_Path + 'Tasmota_Firmware.onlineVersion', {type: 'string', write: false}); + setObject(AliasPath + 'Tasmota_Firmware.onlineVersion', {type: 'channel', common: {role: 'info', name: 'onlineVersion'}, native: {}}); + await createAliasAsync(AliasPath + 'Tasmota_Firmware.onlineVersion.ACTUAL', NSPanel_Path + 'Tasmota_Firmware.onlineVersion', true, { type: 'string', role: 'state', name: 'ACTUAL', }); - await setStateAsync(NSPanel_Path + 'Tasmota_Firmware.onlineVersion', { val: TasmotaVersionOnline, ack: true }); + await setStateAsync(NSPanel_Path + 'Tasmota_Firmware.onlineVersion', {val: TasmotaVersionOnline, ack: true}); if (Debug) log('online tasmota firmware version => ' + TasmotaVersionOnline, 'info'); } } else { @@ -3879,7 +3890,7 @@ function get_online_tasmota_firmware_version() { * @returns {Promise} A promise that resolves when the current Berry driver version has been retrieved. * @throws {Error} If an error occurs during the version retrieval. */ -function get_current_berry_driver_version() { +function get_current_berry_driver_version () { try { if (Debug) { log('Requesting current berry driver version', 'info'); @@ -3888,7 +3899,7 @@ function get_current_berry_driver_version() { let urlString = get_tasmot_url('GetDriverVersion') axios - .get(urlString, { headers: { 'User-Agent': 'ioBroker' } }) + .get(urlString, {headers: {'User-Agent': 'ioBroker'}}) .then(async function (response) { if (response.status === 200) { if (Debug) { @@ -3896,11 +3907,11 @@ function get_current_berry_driver_version() { } if (isSetOptionActive) { const BerryDriverVersionCurrent: string = JSON.parse(JSON.stringify(response.data)).nlui_driver_version; - await createStateAsync(NSPanel_Path + 'Berry_Driver.currentVersion', { type: 'string', write: false }); - await setStateAsync(NSPanel_Path + 'Berry_Driver.currentVersion', { val: JSON.parse(JSON.stringify(response.data)).nlui_driver_version, ack: true }); + await createStateAsync(NSPanel_Path + 'Berry_Driver.currentVersion', {type: 'string', write: false}); + await setStateAsync(NSPanel_Path + 'Berry_Driver.currentVersion', {val: JSON.parse(JSON.stringify(response.data)).nlui_driver_version, ack: true}); if (autoCreateAlias) { - setObject(AliasPath + 'Display.BerryDriver', { type: 'channel', common: { role: 'info', name: 'Berry Driver' }, native: {} }); - await createAliasAsync(AliasPath + 'Display.BerryDriver.ACTUAL', NSPanel_Path + 'Berry_Driver.currentVersion', true, { + setObject(AliasPath + 'Display.BerryDriver', {type: 'channel', common: {role: 'info', name: 'Berry Driver'}, native: {}}); + await createAliasAsync(AliasPath + 'Display.BerryDriver.ACTUAL', NSPanel_Path + 'Berry_Driver.currentVersion', true, { type: 'string', role: 'state', name: 'ACTUAL', @@ -3931,7 +3942,7 @@ function get_current_berry_driver_version() { * @returns {Promise} A promise that resolves when the online Berry driver version has been retrieved. * @throws {Error} If an error occurs during the version retrieval. */ -function get_tasmota_status0() { +function get_tasmota_status0 () { try { if (Debug) { log('Requesting tasmota status0', 'info'); @@ -3943,98 +3954,98 @@ function get_tasmota_status0() { } axios - .get(urlString, { headers: { 'User-Agent': 'ioBroker' } }) + .get(urlString, {headers: {'User-Agent': 'ioBroker'}}) .then(async function (response) { if (response.status === 200) { if (Debug) { log(JSON.stringify(response.data), 'info'); } if (isSetOptionActive) { - await createStateAsync(NSPanel_Path + 'Tasmota_Firmware.currentVersion', { type: 'string', write: false }); - await createStateAsync(NSPanel_Path + 'Tasmota.Uptime', { type: 'string', write: false }); - await createStateAsync(NSPanel_Path + 'Tasmota.Version', { type: 'string', write: false }); - await createStateAsync(NSPanel_Path + 'Tasmota.Hardware', { type: 'string', write: false }); - await createStateAsync(NSPanel_Path + 'Tasmota.Wifi.AP', { type: 'number', write: false }); - await createStateAsync(NSPanel_Path + 'Tasmota.Wifi.SSId', { type: 'string', write: false }); - await createStateAsync(NSPanel_Path + 'Tasmota.Wifi.BSSId', { type: 'string', write: false }); - await createStateAsync(NSPanel_Path + 'Tasmota.Wifi.Channel', { type: 'number', write: false }); - await createStateAsync(NSPanel_Path + 'Tasmota.Wifi.Mode', { type: 'string', write: false }); - await createStateAsync(NSPanel_Path + 'Tasmota.Wifi.RSSI', { type: 'number', write: false }); - await createStateAsync(NSPanel_Path + 'Tasmota.Wifi.Signal', { type: 'number', write: false }); - await createStateAsync(NSPanel_Path + 'Tasmota.Product', { type: 'string', write: false }); + await createStateAsync(NSPanel_Path + 'Tasmota_Firmware.currentVersion', {type: 'string', write: false}); + await createStateAsync(NSPanel_Path + 'Tasmota.Uptime', {type: 'string', write: false}); + await createStateAsync(NSPanel_Path + 'Tasmota.Version', {type: 'string', write: false}); + await createStateAsync(NSPanel_Path + 'Tasmota.Hardware', {type: 'string', write: false}); + await createStateAsync(NSPanel_Path + 'Tasmota.Wifi.AP', {type: 'number', write: false}); + await createStateAsync(NSPanel_Path + 'Tasmota.Wifi.SSId', {type: 'string', write: false}); + await createStateAsync(NSPanel_Path + 'Tasmota.Wifi.BSSId', {type: 'string', write: false}); + await createStateAsync(NSPanel_Path + 'Tasmota.Wifi.Channel', {type: 'number', write: false}); + await createStateAsync(NSPanel_Path + 'Tasmota.Wifi.Mode', {type: 'string', write: false}); + await createStateAsync(NSPanel_Path + 'Tasmota.Wifi.RSSI', {type: 'number', write: false}); + await createStateAsync(NSPanel_Path + 'Tasmota.Wifi.Signal', {type: 'number', write: false}); + await createStateAsync(NSPanel_Path + 'Tasmota.Product', {type: 'string', write: false}); try { const Tasmota_JSON = JSON.parse(JSON.stringify(response.data)); const tasmoVersion = Tasmota_JSON.StatusFWR.Version.indexOf('(') > -1 ? Tasmota_JSON.StatusFWR.Version.split('(')[0] : Tasmota_JSON.StatusFWR.Version; - await setStateAsync(NSPanel_Path + 'Tasmota_Firmware.currentVersion', { val: tasmoVersion, ack: true }); - await setStateAsync(NSPanel_Path + 'Tasmota.Uptime', { val: Tasmota_JSON.StatusPRM.Uptime, ack: true }); - await setStateAsync(NSPanel_Path + 'Tasmota.Version', { val: Tasmota_JSON.StatusFWR.Version, ack: true }); + await setStateAsync(NSPanel_Path + 'Tasmota_Firmware.currentVersion', {val: tasmoVersion, ack: true}); + await setStateAsync(NSPanel_Path + 'Tasmota.Uptime', {val: Tasmota_JSON.StatusPRM.Uptime, ack: true}); + await setStateAsync(NSPanel_Path + 'Tasmota.Version', {val: Tasmota_JSON.StatusFWR.Version, ack: true}); let TasmotaHardware: string = Tasmota_JSON.StatusFWR.Hardware.split(' '); - await setStateAsync(NSPanel_Path + 'Tasmota.Hardware', { val: TasmotaHardware[0] + '\r\n' + TasmotaHardware[1], ack: true }); - await setStateAsync(NSPanel_Path + 'Tasmota.Wifi.AP', { val: Tasmota_JSON.StatusSTS.Wifi.AP, ack: true }); - await setStateAsync(NSPanel_Path + 'Tasmota.Wifi.SSId', { val: Tasmota_JSON.StatusSTS.Wifi.SSId, ack: true }); - await setStateAsync(NSPanel_Path + 'Tasmota.Wifi.BSSId', { val: Tasmota_JSON.StatusSTS.Wifi.BSSId, ack: true }); - await setStateAsync(NSPanel_Path + 'Tasmota.Wifi.Channel', { val: Tasmota_JSON.StatusSTS.Wifi.Channel, ack: true }); - await setStateAsync(NSPanel_Path + 'Tasmota.Wifi.Mode', { val: Tasmota_JSON.StatusSTS.Wifi.Mode, ack: true }); - await setStateAsync(NSPanel_Path + 'Tasmota.Wifi.RSSI', { val: Tasmota_JSON.StatusSTS.Wifi.RSSI, ack: true }); - await setStateAsync(NSPanel_Path + 'Tasmota.Wifi.Signal', { val: Tasmota_JSON.StatusSTS.Wifi.Signal, ack: true }); - await setStateAsync(NSPanel_Path + 'Tasmota.Product', { val: 'SONOFF NSPanel', ack: true }); + await setStateAsync(NSPanel_Path + 'Tasmota.Hardware', {val: TasmotaHardware[0] + '\r\n' + TasmotaHardware[1], ack: true}); + await setStateAsync(NSPanel_Path + 'Tasmota.Wifi.AP', {val: Tasmota_JSON.StatusSTS.Wifi.AP, ack: true}); + await setStateAsync(NSPanel_Path + 'Tasmota.Wifi.SSId', {val: Tasmota_JSON.StatusSTS.Wifi.SSId, ack: true}); + await setStateAsync(NSPanel_Path + 'Tasmota.Wifi.BSSId', {val: Tasmota_JSON.StatusSTS.Wifi.BSSId, ack: true}); + await setStateAsync(NSPanel_Path + 'Tasmota.Wifi.Channel', {val: Tasmota_JSON.StatusSTS.Wifi.Channel, ack: true}); + await setStateAsync(NSPanel_Path + 'Tasmota.Wifi.Mode', {val: Tasmota_JSON.StatusSTS.Wifi.Mode, ack: true}); + await setStateAsync(NSPanel_Path + 'Tasmota.Wifi.RSSI', {val: Tasmota_JSON.StatusSTS.Wifi.RSSI, ack: true}); + await setStateAsync(NSPanel_Path + 'Tasmota.Wifi.Signal', {val: Tasmota_JSON.StatusSTS.Wifi.Signal, ack: true}); + await setStateAsync(NSPanel_Path + 'Tasmota.Product', {val: 'SONOFF NSPanel', ack: true}); if (Debug) log('current tasmota firmware version => ' + tasmoVersion, 'info'); } catch (err: any) { log('error setState in function get_tasmota_status0' + err.message, 'warn'); } if (autoCreateAlias) { - setObject(AliasPath + 'Tasmota.Uptime', { type: 'channel', common: { role: 'info', name: 'Uptime' }, native: {} }); - setObject(AliasPath + 'Tasmota.Version', { type: 'channel', common: { role: 'info', name: 'Version' }, native: {} }); - setObject(AliasPath + 'Tasmota.Hardware', { type: 'channel', common: { role: 'info', name: 'Hardware' }, native: {} }); - setObject(AliasPath + 'Tasmota.Wifi.AP', { type: 'channel', common: { role: 'info', name: 'AP' }, native: {} }); - setObject(AliasPath + 'Tasmota.Wifi.SSId', { type: 'channel', common: { role: 'info', name: 'SSId' }, native: {} }); - setObject(AliasPath + 'Tasmota.Wifi.BSSId', { type: 'channel', common: { role: 'info', name: 'BSSId' }, native: {} }); - setObject(AliasPath + 'Tasmota.Wifi.Channel', { type: 'channel', common: { role: 'info', name: 'Channel' }, native: {} }); - setObject(AliasPath + 'Tasmota.Wifi.Mode', { type: 'channel', common: { role: 'info', name: 'Mode' }, native: {} }); - setObject(AliasPath + 'Tasmota.Wifi.RSSI', { type: 'channel', common: { role: 'info', name: 'RSSI' }, native: {} }); - setObject(AliasPath + 'Tasmota.Wifi.Signal', { type: 'channel', common: { role: 'info', name: 'Signal' }, native: {} }); - setObject(AliasPath + 'Tasmota.Product', { type: 'channel', common: { role: 'info', name: 'Product' }, native: {} }); - await createAliasAsync(AliasPath + 'Tasmota.Uptime.ACTUAL', NSPanel_Path + 'Tasmota.Uptime', true, { type: 'string', role: 'state', name: 'ACTUAL' }); - await createAliasAsync(AliasPath + 'Tasmota.Version.ACTUAL', NSPanel_Path + 'Tasmota.Version', true, { type: 'string', role: 'state', name: 'ACTUAL' }); - await createAliasAsync(AliasPath + 'Tasmota.Hardware.ACTUAL', NSPanel_Path + 'Tasmota.Hardware', true, { + setObject(AliasPath + 'Tasmota.Uptime', {type: 'channel', common: {role: 'info', name: 'Uptime'}, native: {}}); + setObject(AliasPath + 'Tasmota.Version', {type: 'channel', common: {role: 'info', name: 'Version'}, native: {}}); + setObject(AliasPath + 'Tasmota.Hardware', {type: 'channel', common: {role: 'info', name: 'Hardware'}, native: {}}); + setObject(AliasPath + 'Tasmota.Wifi.AP', {type: 'channel', common: {role: 'info', name: 'AP'}, native: {}}); + setObject(AliasPath + 'Tasmota.Wifi.SSId', {type: 'channel', common: {role: 'info', name: 'SSId'}, native: {}}); + setObject(AliasPath + 'Tasmota.Wifi.BSSId', {type: 'channel', common: {role: 'info', name: 'BSSId'}, native: {}}); + setObject(AliasPath + 'Tasmota.Wifi.Channel', {type: 'channel', common: {role: 'info', name: 'Channel'}, native: {}}); + setObject(AliasPath + 'Tasmota.Wifi.Mode', {type: 'channel', common: {role: 'info', name: 'Mode'}, native: {}}); + setObject(AliasPath + 'Tasmota.Wifi.RSSI', {type: 'channel', common: {role: 'info', name: 'RSSI'}, native: {}}); + setObject(AliasPath + 'Tasmota.Wifi.Signal', {type: 'channel', common: {role: 'info', name: 'Signal'}, native: {}}); + setObject(AliasPath + 'Tasmota.Product', {type: 'channel', common: {role: 'info', name: 'Product'}, native: {}}); + await createAliasAsync(AliasPath + 'Tasmota.Uptime.ACTUAL', NSPanel_Path + 'Tasmota.Uptime', true, {type: 'string', role: 'state', name: 'ACTUAL'}); + await createAliasAsync(AliasPath + 'Tasmota.Version.ACTUAL', NSPanel_Path + 'Tasmota.Version', true, {type: 'string', role: 'state', name: 'ACTUAL'}); + await createAliasAsync(AliasPath + 'Tasmota.Hardware.ACTUAL', NSPanel_Path + 'Tasmota.Hardware', true, { type: 'string', role: 'state', name: 'ACTUAL', }); - await createAliasAsync(AliasPath + 'Tasmota.Wifi.AP.ACTUAL', NSPanel_Path + 'Tasmota.Wifi.AP', true, { type: 'number', role: 'state', name: 'ACTUAL' }); - await createAliasAsync(AliasPath + 'Tasmota.Wifi.SSId.ACTUAL', NSPanel_Path + 'Tasmota.Wifi.SSId', true, { + await createAliasAsync(AliasPath + 'Tasmota.Wifi.AP.ACTUAL', NSPanel_Path + 'Tasmota.Wifi.AP', true, {type: 'number', role: 'state', name: 'ACTUAL'}); + await createAliasAsync(AliasPath + 'Tasmota.Wifi.SSId.ACTUAL', NSPanel_Path + 'Tasmota.Wifi.SSId', true, { type: 'string', role: 'state', name: 'ACTUAL', }); - await createAliasAsync(AliasPath + 'Tasmota.Wifi.BSSId.ACTUAL', NSPanel_Path + 'Tasmota.Wifi.BSSId', true, { + await createAliasAsync(AliasPath + 'Tasmota.Wifi.BSSId.ACTUAL', NSPanel_Path + 'Tasmota.Wifi.BSSId', true, { type: 'string', role: 'state', name: 'ACTUAL', }); - await createAliasAsync(AliasPath + 'Tasmota.Wifi.Channel.ACTUAL', NSPanel_Path + 'Tasmota.Wifi.Channel', true, { + await createAliasAsync(AliasPath + 'Tasmota.Wifi.Channel.ACTUAL', NSPanel_Path + 'Tasmota.Wifi.Channel', true, { type: 'number', role: 'state', name: 'ACTUAL', }); - await createAliasAsync(AliasPath + 'Tasmota.Wifi.Mode.ACTUAL', NSPanel_Path + 'Tasmota.Wifi.Mode', true, { + await createAliasAsync(AliasPath + 'Tasmota.Wifi.Mode.ACTUAL', NSPanel_Path + 'Tasmota.Wifi.Mode', true, { type: 'string', role: 'state', name: 'ACTUAL', }); - await createAliasAsync(AliasPath + 'Tasmota.Wifi.RSSI.ACTUAL', NSPanel_Path + 'Tasmota.Wifi.RSSI', true, { + await createAliasAsync(AliasPath + 'Tasmota.Wifi.RSSI.ACTUAL', NSPanel_Path + 'Tasmota.Wifi.RSSI', true, { type: 'number', role: 'state', name: 'ACTUAL', }); - await createAliasAsync(AliasPath + 'Tasmota.Wifi.Signal.ACTUAL', NSPanel_Path + 'Tasmota.Wifi.Signal', true, { + await createAliasAsync(AliasPath + 'Tasmota.Wifi.Signal.ACTUAL', NSPanel_Path + 'Tasmota.Wifi.Signal', true, { type: 'number', role: 'state', name: 'ACTUAL', }); - await createAliasAsync(AliasPath + 'Tasmota.Product.ACTUAL', NSPanel_Path + 'Tasmota.Product', true, { type: 'string', role: 'state', name: 'ACTUAL' }); + await createAliasAsync(AliasPath + 'Tasmota.Product.ACTUAL', NSPanel_Path + 'Tasmota.Product', true, {type: 'string', role: 'state', name: 'ACTUAL'}); } } } else { @@ -4051,32 +4062,32 @@ function get_tasmota_status0() { } } -function renameChannel() { +function renameChannel () { const urlString = get_tasmot_url('DeviceName'); axios - .get(urlString, { headers: { 'User-Agent': 'ioBroker' } }) - .then(async function (response) { - if (response.status === 200) { - if (Debug) { - log(JSON.stringify(response.data), 'info'); - } - if (isSetOptionActive) { - try { - if (response.data && response.data.DeviceName && response.data.DeviceName !== '') { - await extendObjectAsync(NSPanel_Path.slice(0,-1), {common:{name:response.data.DeviceName}}) - await extendObjectAsync(AliasPath.slice(0,-1), {common:{name:response.data.DeviceName}}) + .get(urlString, {headers: {'User-Agent': 'ioBroker'}}) + .then(async function (response) { + if (response.status === 200) { + if (Debug) { + log(JSON.stringify(response.data), 'info'); + } + if (isSetOptionActive) { + try { + if (response.data && response.data.DeviceName && response.data.DeviceName !== '') { + await extendObjectAsync(NSPanel_Path.slice(0, -1), {common: {name: response.data.DeviceName}}) + await extendObjectAsync(AliasPath.slice(0, -1), {common: {name: response.data.DeviceName}}) + } + } catch (e) { + //nothing } - } catch (e) { - //nothing } } - } - }) - .catch(function (error) { - if (error.code === 'EHOSTUNREACH') { - log(`Can't connect to display!`, 'warn'); - } else log(error, 'error'); - }); + }) + .catch(function (error) { + if (error.code === 'EHOSTUNREACH') { + log(`Can't connect to display!`, 'warn'); + } else log(error, 'error'); + }); } /** @@ -4084,7 +4095,7 @@ function renameChannel() { * @param cmd tasmota command * @returns url */ -function get_tasmot_url(cmd: string): string { +function get_tasmot_url (cmd: string): string { if (tasmota_web_admin_password != '') { return `http://${get_current_tasmota_ip_address()}/cm?user=${tasmota_web_admin_user}&password=${tasmota_web_admin_password}&cmnd=${cmd}`; } @@ -4100,7 +4111,7 @@ function get_tasmot_url(cmd: string): string { * @returns {Promise} A promise that resolves when the firmware update has been completed. * @throws {Error} If an error occurs during the firmware update. */ -function get_online_berry_driver_version() { +function get_online_berry_driver_version () { try { if (NSPanel_Path + 'Config.Update.activ') { if (Debug) { @@ -4110,7 +4121,7 @@ function get_online_berry_driver_version() { let urlString = 'https://raw.githubusercontent.com/joBr99/nspanel-lovelace-ui/main/tasmota/autoexec.be'; axios - .get(urlString, { headers: { 'User-Agent': 'ioBroker' } }) + .get(urlString, {headers: {'User-Agent': 'ioBroker'}}) .then(async function (response) { if (response.status === 200) { if (Debug) { @@ -4120,14 +4131,14 @@ function get_online_berry_driver_version() { const BerryDriverVersionOnline = response.data .substring(response.data.indexOf('version_of_this_script = ') + 24, response.data.indexOf('version_of_this_script = ') + 27) .replace(/\s+/g, ''); - await createStateAsync(NSPanel_Path + 'Berry_Driver.onlineVersion', { type: 'string', write: false }); - setObject(AliasPath + 'Berry_Driver.onlineVersion', { type: 'channel', common: { role: 'info', name: 'onlineVersion' }, native: {} }); - await createAliasAsync(AliasPath + 'Berry_Driver.onlineVersion.ACTUAL', NSPanel_Path + 'Berry_Driver.onlineVersion', true, { + await createStateAsync(NSPanel_Path + 'Berry_Driver.onlineVersion', {type: 'string', write: false}); + setObject(AliasPath + 'Berry_Driver.onlineVersion', {type: 'channel', common: {role: 'info', name: 'onlineVersion'}, native: {}}); + await createAliasAsync(AliasPath + 'Berry_Driver.onlineVersion.ACTUAL', NSPanel_Path + 'Berry_Driver.onlineVersion', true, { type: 'string', role: 'state', name: 'ACTUAL', }); - await setStateAsync(NSPanel_Path + 'Berry_Driver.onlineVersion', { val: BerryDriverVersionOnline, ack: true }); + await setStateAsync(NSPanel_Path + 'Berry_Driver.onlineVersion', {val: BerryDriverVersionOnline, ack: true}); if (Debug) log('online berry driver version => ' + BerryDriverVersionOnline, 'info'); } } else { @@ -4152,7 +4163,7 @@ function get_online_berry_driver_version() { * @returns {Promise} A promise that resolves when the Berry driver update has been completed. * @throws {Error} If an error occurs during the update. */ -function check_version_tft_firmware() { +function check_version_tft_firmware () { try { if (Debug) { log('Requesting online TFT version', 'info'); @@ -4161,7 +4172,7 @@ function check_version_tft_firmware() { let urlString = 'https://api.github.com/repos/joBr99/nspanel-lovelace-ui/releases/latest'; axios - .get(urlString, { headers: { 'User-Agent': 'ioBroker' } }) + .get(urlString, {headers: {'User-Agent': 'ioBroker'}}) .then(async function (response) { if (response.status === 200) { if (Debug) { @@ -4171,8 +4182,8 @@ function check_version_tft_firmware() { let NSPanelTagName = NSPanel_JSON.tag_name; // created_at; published_at; name ; draft ; prerelease let NSPanelVersion = NSPanelTagName.replace(/v/i, ''); // Filter unnecessary "v" from variable and write to release variable - await createStateAsync(NSPanel_Path + 'TFT_Firmware.onlineVersion', { type: 'string', write: false }); - await setStateAsync(NSPanel_Path + 'TFT_Firmware.onlineVersion', { val: NSPanelVersion, ack: true }); + await createStateAsync(NSPanel_Path + 'TFT_Firmware.onlineVersion', {type: 'string', write: false}); + await setStateAsync(NSPanel_Path + 'TFT_Firmware.onlineVersion', {val: NSPanelVersion, ack: true}); if (Debug) log('online TFT firmware version => ' + NSPanelVersion, 'info'); } else { log('Axios Status - check_version_tft_firmware: ' + response.state, 'warn'); @@ -4195,7 +4206,7 @@ function check_version_tft_firmware() { * @returns {Promise} A promise that resolves when the display firmware update data has been retrieved. * @throws {Error} If an error occurs during the update data retrieval. */ -function check_online_display_firmware() { +function check_online_display_firmware () { try { if (Debug) { log('Requesting online firmware version', 'info'); @@ -4204,7 +4215,7 @@ function check_online_display_firmware() { let urlString = 'https://raw.githubusercontent.com/joBr99/nspanel-lovelace-ui/main/apps/nspanel-lovelace-ui/nspanel-lovelace-ui.py'; axios - .get(urlString, { headers: { 'User-Agent': 'ioBroker' } }) + .get(urlString, {headers: {'User-Agent': 'ioBroker'}}) .then(async function (response) { if (response.status === 200) { if (Debug) { @@ -4214,8 +4225,8 @@ function check_online_display_firmware() { .substring(response.data.indexOf('desired_display_firmware_version =') + 34, response.data.indexOf('desired_display_firmware_version =') + 38) .replace(/\s+/g, ''); - await createStateAsync(NSPanel_Path + 'Display_Firmware.onlineVersion', { type: 'string', write: false }); - await setStateAsync(NSPanel_Path + 'Display_Firmware.onlineVersion', { val: desired_display_firmware_version, ack: true }); + await createStateAsync(NSPanel_Path + 'Display_Firmware.onlineVersion', {type: 'string', write: false}); + await setStateAsync(NSPanel_Path + 'Display_Firmware.onlineVersion', {val: desired_display_firmware_version, ack: true}); if (Debug) log('online display firmware version => ' + desired_display_firmware_version, 'info'); } else { log('Axios Status - check_online_display_firmware: ' + response.state, 'warn'); @@ -4241,28 +4252,28 @@ function check_online_display_firmware() { * @returns {Promise} A promise that resolves when the message has been processed. * @throws {Error} If an error occurs during the message processing. */ -on({ id: config.panelRecvTopic }, async (obj) => { +on({id: config.panelRecvTopic}, async (obj) => { if (obj.state.val.startsWith('{"CustomRecv":')) { try { const json = JSON.parse(obj.state.val); const split = json.CustomRecv.split(','); if (isSetOptionActive) { if (split[0] == 'event' && split[1] == 'startup') { - await createStateAsync(NSPanel_Path + 'Display_Firmware.currentVersion', { type: 'string', write: false }); - await createStateAsync(NSPanel_Path + 'NSPanel_Version', { type: 'string', write: false }); + await createStateAsync(NSPanel_Path + 'Display_Firmware.currentVersion', {type: 'string', write: false}); + await createStateAsync(NSPanel_Path + 'NSPanel_Version', {type: 'string', write: false}); - await setStateAsync(NSPanel_Path + 'Display_Firmware.currentVersion', { val: split[2], ack: true }); - await setStateAsync(NSPanel_Path + 'NSPanel_Version', { val: split[3], ack: true }); + await setStateAsync(NSPanel_Path + 'Display_Firmware.currentVersion', {val: split[2], ack: true}); + await setStateAsync(NSPanel_Path + 'NSPanel_Version', {val: split[3], ack: true}); if (autoCreateAlias) { - setObject(AliasPath + 'Display.TFTVersion', { type: 'channel', common: { role: 'info', name: 'Display.TFTVersion' }, native: {} }); - setObject(AliasPath + 'Display.Model', { type: 'channel', common: { role: 'info', name: 'Display.Model' }, native: {} }); - await createAliasAsync(AliasPath + 'Display.TFTVersion.ACTUAL', NSPanel_Path + 'Display_Firmware.currentVersion', true, { + setObject(AliasPath + 'Display.TFTVersion', {type: 'channel', common: {role: 'info', name: 'Display.TFTVersion'}, native: {}}); + setObject(AliasPath + 'Display.Model', {type: 'channel', common: {role: 'info', name: 'Display.Model'}, native: {}}); + await createAliasAsync(AliasPath + 'Display.TFTVersion.ACTUAL', NSPanel_Path + 'Display_Firmware.currentVersion', true, { type: 'string', role: 'state', name: 'ACTUAL', }); - await createAliasAsync(AliasPath + 'Display.Model.ACTUAL', NSPanel_Path + 'NSPanel_Version', true, { type: 'string', role: 'state', name: 'ACTUAL' }); + await createAliasAsync(AliasPath + 'Display.Model.ACTUAL', NSPanel_Path + 'NSPanel_Version', true, {type: 'string', role: 'state', name: 'ACTUAL'}); } } } @@ -4284,7 +4295,7 @@ on({ id: config.panelRecvTopic }, async (obj) => { * @function update_berry_driver_version * @throws {Error} If an error occurs during the update process. */ -function update_berry_driver_version() { +function update_berry_driver_version () { try { let urlString = `http://${get_current_tasmota_ip_address()}/cm?cmnd=Backlog UpdateDriverVersion https://raw.githubusercontent.com/joBr99/nspanel-lovelace-ui/main/tasmota/autoexec.be; Restart 1`; if (tasmota_web_admin_password != '') { @@ -4292,7 +4303,7 @@ function update_berry_driver_version() { } axios - .get(urlString, { headers: { 'User-Agent': 'ioBroker' } }) + .get(urlString, {headers: {'User-Agent': 'ioBroker'}}) .then(async function (response) { if (response.status === 200) { if (Debug) { @@ -4318,12 +4329,12 @@ function update_berry_driver_version() { * @function update_display_firmware * @throws {Error} If an error occurs during the firmware update. */ -function update_tft_firmware() { +function update_tft_firmware () { if ((existsObject(NSPanel_Path + 'Config.Update.activ') != false) && (existsObject(NSPanel_Path + 'Display_Firmware.TFT.currentVersion') != false)) { let id = getState(NSPanel_Path + 'Display_Firmware.TFT.currentVersion').val; let currentVersion = id.split('/'); let version = parseInt(currentVersion[0]); - if ( ! isNaN(version) ) { + if (!isNaN(version)) { if ((getState(NSPanel_Path + 'Config.Update.activ').val == 0) && (version != 0)) { if (existsState(NSPanel_Path + 'NSPanel_Version')) { let desired_display_firmware_url = ''; @@ -4345,14 +4356,14 @@ function update_tft_firmware() { urlString = `http://${get_current_tasmota_ip_address()}/cm?user=${tasmota_web_admin_user}&password=${tasmota_web_admin_password}&cmnd=FlashNextion ${desired_display_firmware_url}`; } axios - .get(urlString, { headers: { 'User-Agent': 'ioBroker' } }) + .get(urlString, {headers: {'User-Agent': 'ioBroker'}}) .then(async function (response) { if (response.status === 200) { if (Debug) { log(response.data, 'info'); } - await createStateAsync(NSPanel_Path + 'TFT_Firmware.onlineVersion', { type: 'string', write: false }); - await setStateAsync(NSPanel_Path + 'TFT_Firmware.onlineVersion', { val: tft_version, ack: true }); + await createStateAsync(NSPanel_Path + 'TFT_Firmware.onlineVersion', {type: 'string', write: false}); + await setStateAsync(NSPanel_Path + 'TFT_Firmware.onlineVersion', {val: tft_version, ack: true}); Init_Release(); } else { log('Axios Status - update_tft_firmware: ' + response.state, 'warn'); @@ -4378,7 +4389,7 @@ function update_tft_firmware() { * @function check_updates * @throws {Error} If an error occurs during the update check. */ -function update_tasmota_firmware() { +function update_tasmota_firmware () { if (existsObject(NSPanel_Path + 'Config.Update.activ') != false) { try { if (getState(NSPanel_Path + 'Config.Update.activ').val == 0) { @@ -4387,7 +4398,7 @@ function update_tasmota_firmware() { urlString = `http://${get_current_tasmota_ip_address()}/cm?user=${tasmota_web_admin_user}&password=${tasmota_web_admin_password}&cmnd=OtaUrl ${tasmotaOtaUrl}${tasmotaOtaVersion}`; } axios - .get(urlString, { headers: { 'User-Agent': 'ioBroker' } }) + .get(urlString, {headers: {'User-Agent': 'ioBroker'}}) .then(async function (response) { if (response.status === 200) { if (Debug) { @@ -4407,7 +4418,7 @@ function update_tasmota_firmware() { } axios - .get(urlString, { headers: { 'User-Agent': 'ioBroker' } }) + .get(urlString, {headers: {'User-Agent': 'ioBroker'}}) .then(async function (response) { if (response.status === 200) { if (Debug) { @@ -4437,7 +4448,8 @@ function update_tasmota_firmware() { * @param {Object} obj - The object containing the state change information. * @throws {Error} If an error occurs during the state change handling. */ -on({ id: config.panelRecvTopic.substring(0, config.panelRecvTopic.length - 'RESULT'.length) + 'INFO1', change: 'ne' }, async (obj) => { try { +on({id: config.panelRecvTopic.substring(0, config.panelRecvTopic.length - 'RESULT'.length) + 'INFO1', change: 'ne'}, async (obj) => { + try { if (getState(NSPanel_Path + 'Config.Update.activ').val == 0) { let Tasmota_JSON: any = JSON.parse(obj.state.val); if (Tasmota_JSON.Info1.Version.indexOf('safeboot') != -1) { @@ -4461,7 +4473,7 @@ on({ id: config.panelRecvTopic.substring(0, config.panelRecvTopic.length - 'RESU * @param {NSPanel.Payload | NSPanel.Payload[]} val Payload or Array of Payload to send * @returns {Promise} */ -async function SendToPanel(val: NSPanel.Payload | NSPanel.Payload[]) { +async function SendToPanel (val: NSPanel.Payload | NSPanel.Payload[]) { try { if (Array.isArray(val)) { val.forEach(function (id) { @@ -4491,7 +4503,8 @@ async function SendToPanel(val: NSPanel.Payload | NSPanel.Payload[]) { * @param {Object} obj - The object containing the state change information. * @throws {Error} If an error occurs during the state change handling. */ -on({ id: NSPanel_Alarm_Path + 'Alarm.AlarmState', change: 'ne' }, async (obj) => { try { +on({id: NSPanel_Alarm_Path + 'Alarm.AlarmState', change: 'ne'}, async (obj) => { + try { if ((obj.state ? obj.state.val : '') == 'armed' || (obj.state ? obj.state.val : '') == 'disarmed' || (obj.state ? obj.state.val : '') == 'triggered') { if (Debug) { log('Trigger AlarmState aktivePage: ' + activePage, 'info'); @@ -4516,7 +4529,8 @@ on({ id: NSPanel_Alarm_Path + 'Alarm.AlarmState', change: 'ne' }, async (obj) => * @param {number | undefined} page - The page number associated with the event, if applicable. * @param {string[] | undefined} words - Additional words or parameters associated with the event, if applicable. */ -function HandleMessage(typ: string, method: NSPanel.EventMethod, page: number | undefined, words: string[] | undefined): void { try { +function HandleMessage (typ: string, method: NSPanel.EventMethod, page: number | undefined, words: string[] | undefined): void { + try { if (typ == 'event') { switch (method as NSPanel.EventMethod) { case 'startup': @@ -4598,7 +4612,7 @@ function HandleMessage(typ: string, method: NSPanel.EventMethod, page: number | * If not found, it searches through each subPage's items. Logs the found PageItem details if in debug mode. * Returns the PageItem if found, otherwise returns the first item of the active page in case of an error. */ -function findPageItem(searching: String): NSPanel.PageItem { +function findPageItem (searching: String): NSPanel.PageItem { try { let pageItem = activePage!.items.find((e) => e && e.id === searching); @@ -4630,7 +4644,7 @@ function findPageItem(searching: String): NSPanel.PageItem { * @function GeneratePage * @param {NSPanel.PageType} page - The page type to generate. */ -function GeneratePage(page: PageType): void { +function GeneratePage (page: PageType): void { try { activePage = page; setIfExists(NSPanel_Path + 'ActivePage.type', activePage.type, null, true); @@ -4692,7 +4706,8 @@ function GeneratePage(page: PageType): void { * @function HandleHardwareButton * @param {NSPanel.EventMethod} method - The method associated with the hardware button event. */ -function HandleHardwareButton(method: NSPanel.EventMethod): void { try { +function HandleHardwareButton (method: NSPanel.EventMethod): void { + try { let buttonConfig: NSPanel.ConfigButtonFunction = config[method]; if (buttonConfig.mode === null) { return; @@ -4743,13 +4758,14 @@ function HandleHardwareButton(method: NSPanel.EventMethod): void { try { * * @function HandleStartupProcess */ -function HandleStartupProcess(): void { let timeout:number = 10; +function HandleStartupProcess (): void { + let timeout: number = 10; SendDate(); SendTime(); if (existsState(NSPanel_Path + 'Config.Screensaver.timeoutScreensaver')) { timeout = getState(NSPanel_Path + 'Config.Screensaver.timeoutScreensaver').val; } - SendToPanel({ payload: 'timeout~' + timeout }); + SendToPanel({payload: 'timeout~' + timeout}); } /** @@ -4759,17 +4775,18 @@ function HandleStartupProcess(): void { let timeout:number = 10; * * @function SendDate */ -function SendDate(): void { try { +function SendDate (): void { + try { if (existsObject(NSPanel_Path + 'Config.locale')) { let dpWeekday = existsObject(NSPanel_Path + 'Config.Dateformat.weekday') ? getState(NSPanel_Path + 'Config.Dateformat.weekday').val : 'short'; let dpMonth = existsObject(NSPanel_Path + 'Config.Dateformat.month') ? getState(NSPanel_Path + 'Config.Dateformat.month').val : 'short'; let dpCustomFormat = existsObject(NSPanel_Path + 'Config.Dateformat.customFormat') ? getState(NSPanel_Path + 'Config.Dateformat.customFormat').val : ''; const date = new Date(); - const options: any = { weekday: dpWeekday, year: 'numeric', month: dpMonth, day: 'numeric' }; + const options: any = {weekday: dpWeekday, year: 'numeric', month: dpMonth, day: 'numeric'}; const _SendDate = dpCustomFormat != '' ? moment().format(dpCustomFormat) : date.toLocaleDateString(getState(NSPanel_Path + 'Config.locale').val, options); - SendToPanel({ payload: 'date~' + _SendDate }); + SendToPanel({payload: 'date~' + _SendDate}); } } catch (err: any) { if ((err.message = 'Cannot convert undefined or null to object')) { @@ -4787,13 +4804,14 @@ function SendDate(): void { try { * * @function SendTime */ -function SendTime(): void { try { +function SendTime (): void { + try { /*const d = new Date(); const hr = (d.getHours() < 10 ? '0' : '') + d.getHours(); const min = (d.getMinutes() < 10 ? '0' : '') + d.getMinutes(); SendToPanel({ payload: 'time~' + hr + ':' + min });*/ - SendToPanel({ payload: `time~${new Date().toLocaleTimeString('de-DE', { hour: '2-digit', minute: '2-digit' })}` }); + SendToPanel({payload: `time~${new Date().toLocaleTimeString('de-DE', {hour: '2-digit', minute: '2-digit'})}`}); } catch (err: any) { log('error at function SendTime: ' + err.message, 'warn'); } @@ -4808,10 +4826,11 @@ function SendTime(): void { try { * @param {NSPanel.PageEntities} page - The entities page configuration. * @returns {NSPanel.Payload[]} The payload array for the entities page. */ -function GenerateEntitiesPage(page: NSPanel.PageEntities): NSPanel.Payload[] { try { +function GenerateEntitiesPage (page: NSPanel.PageEntities): NSPanel.Payload[] { + try { let out_msgs: NSPanel.Payload[]; - out_msgs = [{ payload: 'pageType~cardEntities' }]; - out_msgs.push({ payload: GeneratePageElements(page) }); + out_msgs = [{payload: 'pageType~cardEntities'}]; + out_msgs.push({payload: GeneratePageElements(page)}); return out_msgs; } catch (err: any) { log('error at function GenerateEntitiesPage: ' + err.message, 'warn'); @@ -4828,9 +4847,10 @@ function GenerateEntitiesPage(page: NSPanel.PageEntities): NSPanel.Payload[] { * @param {NSPanel.PageGrid} page - The grid page configuration. * @returns {NSPanel.Payload[]} The payload array for the grid page. */ -function GenerateGridPage(page: NSPanel.PageGrid): NSPanel.Payload[] { try { - let out_msgs: NSPanel.Payload[] = [{ payload: 'pageType~cardGrid' }]; - out_msgs.push({ payload: GeneratePageElements(page) }); +function GenerateGridPage (page: NSPanel.PageGrid): NSPanel.Payload[] { + try { + let out_msgs: NSPanel.Payload[] = [{payload: 'pageType~cardGrid'}]; + out_msgs.push({payload: GeneratePageElements(page)}); return out_msgs; } catch (err: any) { log('error at function GenerateGridPage: ' + err.message, 'warn'); @@ -4847,9 +4867,10 @@ function GenerateGridPage(page: NSPanel.PageGrid): NSPanel.Payload[] { try { * @param {NSPanel.PageGrid2} page - The secondary grid page configuration. * @returns {NSPanel.Payload[]} The payload array for the secondary grid page. */ -function GenerateGridPage2(page: NSPanel.PageGrid2): NSPanel.Payload[] { try { - let out_msgs: NSPanel.Payload[] = [{ payload: 'pageType~cardGrid2' }]; - out_msgs.push({ payload: GeneratePageElements(page) }); +function GenerateGridPage2 (page: NSPanel.PageGrid2): NSPanel.Payload[] { + try { + let out_msgs: NSPanel.Payload[] = [{payload: 'pageType~cardGrid2'}]; + out_msgs.push({payload: GeneratePageElements(page)}); return out_msgs; } catch (err: any) { log('error at function GenerateGridPage2: ' + err.message, 'warn'); @@ -4866,9 +4887,10 @@ function GenerateGridPage2(page: NSPanel.PageGrid2): NSPanel.Payload[] { try * @param {NSPanel.PageGrid3} page - The secondary grid page configuration. * @returns {NSPanel.Payload[]} The payload array for the secondary grid page. */ -function GenerateGridPage3(page: NSPanel.PageGrid3): NSPanel.Payload[] { try { - let out_msgs: NSPanel.Payload[] = [{ payload: 'pageType~cardGrid3' }]; - out_msgs.push({ payload: GeneratePageElements(page) }); +function GenerateGridPage3 (page: NSPanel.PageGrid3): NSPanel.Payload[] { + try { + let out_msgs: NSPanel.Payload[] = [{payload: 'pageType~cardGrid3'}]; + out_msgs.push({payload: GeneratePageElements(page)}); return out_msgs; } catch (err: any) { log('error at function GenerateGridPage3: ' + err.message, 'warn'); @@ -4885,7 +4907,8 @@ function GenerateGridPage3(page: NSPanel.PageGrid3): NSPanel.Payload[] { try * @param {PageType} page - The page type configuration. * @returns {string} The string representation of the page elements. */ -function GeneratePageElements(page: PageType): string { try { +function GeneratePageElements (page: PageType): string { + try { activePage = page; let maxItems = 0; switch (page.type) { @@ -4918,7 +4941,7 @@ function GeneratePageElements(page: PageType): string { try { maxItems = 5; } } else { - maxItems = 4; + maxItems = 4; } break; case 'cardGrid': @@ -4927,12 +4950,12 @@ function GeneratePageElements(page: PageType): string { try { case 'cardGrid2': if (existsState(NSPanel_Path + 'NSPanel_Version')) { if (getState(NSPanel_Path + 'NSPanel_Version').val == 'us-p') { - maxItems = 9; - } else { + maxItems = 9; + } else { maxItems = 8; - } + } } else { - maxItems = 8; + maxItems = 8; } break; case 'cardGrid3': @@ -4963,7 +4986,7 @@ function GeneratePageElements(page: PageType): string { try { * @param {boolean} [useColors=false] - Whether the entity should contain color information. * @returns {string} The string representing the entity. */ -function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean = false): string { +function CreateEntity (pageItem: PageItem, placeId: number, useColors: boolean = false): string { try { let iconId = '0'; let iconId2 = '0'; @@ -5074,17 +5097,7 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean = * The same extension can be found below in blind. vval=0 means closed / val=100 means open. If val is in between, icon3 is used. * Icons in this part can be states and strings. The specifications are based on German shutters. */ - if (pageItem.icon3 && typeof pageItem.icon3 === 'string'){ - let max = pageItem.maxValueLevel ?? 100 - let min = pageItem.minValueLevel ?? 0 - if (min > max && val >= min || min <= max && val <= min) { - iconId = pageItem.icon && existsState(pageItem.icon) && Icons.GetIcon(getState(pageItem.icon).val) || Icons.GetIcon(pageItem.icon) || Icons.GetIcon('window-shutter') - } else if (min > max && val <= max || min <= max && val >= max) { - iconId = pageItem.icon2 && existsState(pageItem.icon2) && Icons.GetIcon(getState(pageItem.icon2).val) || Icons.GetIcon(pageItem.icon2) || Icons.GetIcon('window-shutter-open') - } else { - iconId = existsState(pageItem.icon3) && Icons.GetIcon(getState(pageItem.icon3).val) || Icons.GetIcon(pageItem.icon3) || Icons.GetIcon('window-shutter-alert') - } - } + iconId = determinePageItemStatusIcon(pageItem, val, iconId, ['window-shutter', 'window-shutter-open', 'window-shutter-alert']); iconColor = existsState(pageItem.id + '.COLORDEC') ? getState(pageItem.id + '.COLORDEC').val : GetIconColor(pageItem, existsState(pageItem.id + '.ACTUAL') ? getState(pageItem.id + '.ACTUAL').val : true, useColors); @@ -5110,7 +5123,7 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean = iconId = iconId2; } break; - + case 'info': iconId = pageItem.icon !== undefined ? Icons.GetIcon(pageItem.icon) : Icons.GetIcon('gesture-tap-button'); @@ -5174,8 +5187,8 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean = pageItem.icon !== undefined ? Icons.GetIcon(pageItem.icon) : role == 'temperature' || role == 'value.temperature' || role == 'thermostat' - ? Icons.GetIcon('thermometer') - : Icons.GetIcon('information-outline'); + ? Icons.GetIcon('thermometer') + : Icons.GetIcon('information-outline'); let unit = ''; optVal = '0'; @@ -5188,6 +5201,11 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean = unit = pageItem.unit !== undefined ? pageItem.unit : GetUnitOfMeasurement(pageItem.id + '.ACTUAL'); } + if (role == 'temperature' || role == 'value.temperature' || role == 'thermostat') { + iconId = determinePageItemStatusIcon(pageItem, val, iconId, ['snowflake-thermometer', 'sun-thermometer', 'thermometer']); + } else if (role == 'humidity' || role == 'value.humidity') { + iconId = determinePageItemStatusIcon(pageItem, val, iconId, ['water-off', 'water-percent-alert' , 'water-percent']); + } iconColor = GetIconColor(pageItem, parseInt(optVal), useColors); if (pageItem.colorScale != undefined) { @@ -5304,7 +5322,7 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean = if (existsState(pageItem.id + '.HUE')) { if (getState(pageItem.id + '.HUE').val != null) { let huecolor = hsv2rgb(getState(pageItem.id + '.HUE').val, 1, 1); - let rgb: RGB = { red: Math.round(huecolor[0]), green: Math.round(huecolor[1]), blue: Math.round(huecolor[2]) }; + let rgb: RGB = {red: Math.round(huecolor[0]), green: Math.round(huecolor[1]), blue: Math.round(huecolor[2])}; iconColor = rgb_dec565(pageItem.interpolateColor !== undefined ? rgb : config.defaultOnColor); } } @@ -5355,7 +5373,7 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean = let rgbRed = getState(pageItem.id + '.RED').val; let rgbGreen = getState(pageItem.id + '.GREEN').val; let rgbBlue = getState(pageItem.id + '.BLUE').val; - let rgb: RGB = { red: Math.round(rgbRed), green: Math.round(rgbGreen), blue: Math.round(rgbBlue) }; + let rgb: RGB = {red: Math.round(rgbRed), green: Math.round(rgbGreen), blue: Math.round(rgbBlue)}; iconColor = rgb_dec565(pageItem.interpolateColor !== undefined ? rgb : config.defaultOnColor); } } @@ -5387,7 +5405,7 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean = let hexRed = parseInt(hex[1] + hex[2], 16); let hexGreen = parseInt(hex[3] + hex[4], 16); let hexBlue = parseInt(hex[5] + hex[6], 16); - let rgb: RGB = { red: Math.round(hexRed), green: Math.round(hexGreen), blue: Math.round(hexBlue) }; + let rgb: RGB = {red: Math.round(hexRed), green: Math.round(hexGreen), blue: Math.round(hexBlue)}; iconColor = rgb_dec565(pageItem.interpolateColor !== undefined ? rgb : config.defaultOnColor); } } @@ -5420,17 +5438,8 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean = iconId = pageItem.icon !== undefined ? Icons.GetIcon(pageItem.icon) : Icons.GetIcon('window-open'); iconColor = GetIconColor(pageItem, existsState(pageItem.id + '.ACTUAL') ? getState(pageItem.id + '.ACTUAL').val : true, useColors); // only if icon3 is set go into 3 icons - if (pageItem.icon3 && typeof pageItem.icon3 === 'string'){ - let max = pageItem.maxValueLevel ?? 100 - let min = pageItem.minValueLevel ?? 0 - if (min > max && val >= min || min <= max && val <= min) { - iconId = pageItem.icon && existsState(pageItem.icon) && Icons.GetIcon(getState(pageItem.icon).val) || Icons.GetIcon(pageItem.icon) || Icons.GetIcon('window-shutter') - } else if (min > max && val <= max || min <= max && val >= max) { - iconId = pageItem.icon2 && existsState(pageItem.icon2) && Icons.GetIcon(getState(pageItem.icon2).val) || Icons.GetIcon(pageItem.icon2) || Icons.GetIcon('window-shutter-open') - } else { - iconId = existsState(pageItem.icon3) && Icons.GetIcon(getState(pageItem.icon3).val) || Icons.GetIcon(pageItem.icon3) || Icons.GetIcon('window-shutter-alert') - } - } + iconId = determinePageItemStatusIcon(pageItem, val, iconId, ['window-shutter', 'window-shutter-open', 'window-shutter-alert']); + let min_Level: number = 0; let max_Level: number = 100; if (pageItem.minValueLevel !== undefined && pageItem.maxValueLevel !== undefined) { @@ -5544,8 +5553,8 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean = pageItem.icon !== undefined ? Icons.GetIcon(pageItem.icon) : role == 'temperature' || role == 'value.temperature' || role == 'thermostat' - ? Icons.GetIcon('thermometer') - : Icons.GetIcon('information-outline'); + ? Icons.GetIcon('thermometer') + : Icons.GetIcon('information-outline'); let unit = ''; optVal = '0'; @@ -5558,6 +5567,12 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean = unit = pageItem.unit !== undefined ? pageItem.unit : GetUnitOfMeasurement(pageItem.id + '.ACTUAL'); } + if (role == 'temperature' || role == 'value.temperature' || role == 'thermostat') { + iconId = determinePageItemStatusIcon(pageItem, val, iconId, ['snowflake-thermometer', 'sun-thermometer', 'thermometer']); + } else if (role == 'humidity' || role == 'value.humidity') { + iconId = determinePageItemStatusIcon(pageItem, val, iconId, ['water-off', 'water-percent-alert' , 'water-percent']); + } + iconColor = GetIconColor(pageItem, parseInt(optVal), useColors); if (pageItem.colorScale != undefined) { @@ -5735,21 +5750,21 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean = if (Debug) log( 'CreateEntity Icon role volumeGroup/volume ~' + - type + - '~' + - placeId + - '~' + - iconId + - '~' + - iconColor + - '~' + - name + - '~' + - val + - '|' + - pageItem.minValue + - '|' + - pageItem.maxValue, + type + + '~' + + placeId + + '~' + + iconId + + '~' + + iconColor + + '~' + + name + + '~' + + val + + '|' + + pageItem.minValue + + '|' + + pageItem.maxValue, 'info' ); return '~' + type + '~' + placeId + '~' + iconId + '~' + iconColor + '~' + name + '~' + val + '|' + pageItem.minValue + '|' + pageItem.maxValue; @@ -5817,13 +5832,14 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean = * @param {string} controlsState - The controls state identifier. * @returns {string} The locale string for the specified controls object and state. */ -function findLocale(controlsObject: string, controlsState: string): string { if ( ! existsState(NSPanel_Path + 'Config.locale')) { +function findLocale (controlsObject: string, controlsState: string): string { + if (!existsState(NSPanel_Path + 'Config.locale')) { if (Debug) { log('findLocaleServMenu missing object: ' + NSPanel_Path + 'Config.locale' + ' -> ' + controlsState, 'warn'); } return controlsState; } - if ( ! existsState(NSPanel_Path + 'NSPanel_locales_json')) { + if (!existsState(NSPanel_Path + 'NSPanel_locales_json')) { if (Debug) { log('findLocaleServMenu missing object: ' + NSPanel_Path + 'NSPanel_locales_json' + ' -> ' + controlsState, 'warn'); } @@ -5867,13 +5883,14 @@ function findLocale(controlsObject: string, controlsState: string): string { * @param {string} controlsState - The service menu controls state identifier. * @returns {string} The locale string for the specified service menu controls state. */ -function findLocaleServMenu(controlsState: string): string { if ( ! existsState(NSPanel_Path + 'Config.locale')) { +function findLocaleServMenu (controlsState: string): string { + if (!existsState(NSPanel_Path + 'Config.locale')) { if (Debug) { log('findLocaleServMenu missing object: ' + NSPanel_Path + 'Config.locale' + ' -> ' + controlsState, 'warn'); } return controlsState; } - if ( ! existsState(NSPanel_Path + 'NSPanel_locales_service_json')) { + if (!existsState(NSPanel_Path + 'NSPanel_locales_service_json')) { if (Debug) { log('findLocaleServMenu missing object: ' + NSPanel_Path + 'NSPanel_locales_service_json' + ' -> ' + controlsState, 'warn'); } @@ -5926,7 +5943,8 @@ function findLocaleServMenu(controlsState: string): string { if ( ! existsSta * @param {boolean} useColors - A flag indicating whether colors should be used. * @returns {number} The color code for the icon. */ -function GetIconColor(pageItem: PageItem, value: boolean | number, useColors: boolean): number { try { +function GetIconColor (pageItem: PageItem, value: boolean | number, useColors: boolean): number { + try { // dimmer if ((pageItem.useColor || useColors) && pageItem.interpolateColor && typeof value === 'number') { let maxValue = pageItem.maxValueBrightness !== undefined ? pageItem.maxValueBrightness : 100; @@ -5967,20 +5985,21 @@ function GetIconColor(pageItem: PageItem, value: boolean | number, useColors: bo * @function RegisterEntityWatcher * @param {string} id - The ID of the entity to watch. */ -function RegisterEntityWatcher(id: string): void { try { +function RegisterEntityWatcher (id: string): void { + try { if (subscriptions.hasOwnProperty(id)) { return; } - subscriptions[id] = on({ id: id, change: 'any' }, () => { + subscriptions[id] = on({id: id, change: 'any'}, () => { if (pageId == -1 && config.button1.page) { - SendToPanel({ payload: GeneratePageElements(config.button1.page) }); + SendToPanel({payload: GeneratePageElements(config.button1.page)}); } if (pageId == -2 && config.button2.page) { - SendToPanel({ payload: GeneratePageElements(config.button2.page) }); + SendToPanel({payload: GeneratePageElements(config.button2.page)}); } if (activePage !== undefined) { - SendToPanel({ payload: GeneratePageElements(activePage!) }); + SendToPanel({payload: GeneratePageElements(activePage!)}); } }); } catch (err: any) { @@ -6000,14 +6019,15 @@ function RegisterEntityWatcher(id: string): void { try { * @param {NSPanel.PopupType} type - The type of popup to display. * @param {number | undefined} placeId - The place ID associated with the entity, if applicable. */ -function RegisterDetailEntityWatcher(id: string, pageItem: PageItem, type: NSPanel.PopupType, placeId: number | undefined): void { try { +function RegisterDetailEntityWatcher (id: string, pageItem: PageItem, type: NSPanel.PopupType, placeId: number | undefined): void { + try { if (subscriptions.hasOwnProperty(id)) { return; } if (Debug) log('id: ' + id + ' - pageItem: ' + JSON.stringify(pageItem) + ' - type: ' + type + ' - placeId: ' + placeId, 'info'); - subscriptions[id] = on({ id: id, change: 'any' }, () => { + subscriptions[id] = on({id: id, change: 'any'}, () => { SendToPanel(GenerateDetailPage(type, undefined, pageItem, placeId)); }); } catch (err: any) { @@ -6024,7 +6044,8 @@ function RegisterDetailEntityWatcher(id: string, pageItem: PageItem, type: NSPan * @param {string} id - The ID of the entity. * @returns {string} The unit of measurement for the entity. */ -function GetUnitOfMeasurement(id: string): string { try { +function GetUnitOfMeasurement (id: string): string { + try { if (!existsObject(id)) return ''; let obj = getObject(id); @@ -6037,7 +6058,7 @@ function GetUnitOfMeasurement(id: string): string { try { } } catch (err: any) { log('error at function GetUnitOfMeasurement: ' + err.message, 'warn'); - + } return ''; } @@ -6051,29 +6072,30 @@ function GetUnitOfMeasurement(id: string): string { try { * @param {NSPanel.PageThermo} page - The thermostat page configuration. * @returns {NSPanel.Payload[]} The payload array for the thermostat page. */ -function GenerateThermoPage(page: NSPanel.PageThermo): NSPanel.Payload[] { try { +function GenerateThermoPage (page: NSPanel.PageThermo): NSPanel.Payload[] { + try { UnsubscribeWatcher(); let id = page.items[0].id; let out_msgs: NSPanel.Payload[] = []; // Leave the display on if the alwaysOnDisplay parameter is specified (true) if (page.type == 'cardThermo' && pageCounter == 0 && page.items[0].alwaysOnDisplay != undefined) { - out_msgs.push({ payload: 'pageType~cardThermo' }); + out_msgs.push({payload: 'pageType~cardThermo'}); if (page.items[0].alwaysOnDisplay != undefined) { if (page.items[0].alwaysOnDisplay) { pageCounter = 1; if (id && existsObject(id) && alwaysOn == false) { alwaysOn = true; - SendToPanel({ payload: 'timeout~0' }); + SendToPanel({payload: 'timeout~0'}); subscribePowerSubscriptions(id); } } } } else if (id && existsObject(id) && page.type == 'cardThermo' && pageCounter == 1) { subscribePowerSubscriptions(id); - + } else { - out_msgs.push({ payload: 'pageType~cardThermo' }); + out_msgs.push({payload: 'pageType~cardThermo'}); } // ioBroker @@ -6297,7 +6319,7 @@ function GenerateThermoPage(page: NSPanel.PageThermo): NSPanel.Payload[] { tr tempIconOffColor = iconsObj != undefined ? rgb_dec565(iconsObj['AUTO']['iconOffColor']) : 35921; } if (stateKeyNumber == Mode) { - bt[iconIndex] = Icons.GetIcon(tempIcon) + '~' + tempIconOnColor +'~1~' + 'AUTO' + '~'; + bt[iconIndex] = Icons.GetIcon(tempIcon) + '~' + tempIconOnColor + '~1~' + 'AUTO' + '~'; } else { //bt[iconIndex] = Icons.GetIcon(tempIcon) + '~' + tempIconOffColor + '~0~' + 'AUTO' + '~'; bis HMI Fix bt[iconIndex] = Icons.GetIcon(tempIcon) + '~' + tempIconOffColor + '~1~' + 'AUTO' + '~'; @@ -6313,7 +6335,7 @@ function GenerateThermoPage(page: NSPanel.PageThermo): NSPanel.Payload[] { tr tempIconOffColor = iconsObj != undefined ? rgb_dec565(iconsObj['COOL']['iconOffColor']) : 35921; } if (stateKeyNumber == Mode) { - bt[iconIndex] = Icons.GetIcon(tempIcon) + '~' + tempIconOnColor +'~1~' + 'COOL' + '~'; + bt[iconIndex] = Icons.GetIcon(tempIcon) + '~' + tempIconOnColor + '~1~' + 'COOL' + '~'; } else { //bt[iconIndex] = Icons.GetIcon(tempIcon) + '~' + tempIconOffColor + '~0~' + 'COOL' + '~'; bis HMI Fix bt[iconIndex] = Icons.GetIcon(tempIcon) + '~' + tempIconOffColor + '~1~' + 'COOL' + '~'; @@ -6329,7 +6351,7 @@ function GenerateThermoPage(page: NSPanel.PageThermo): NSPanel.Payload[] { tr tempIconOffColor = iconsObj != undefined ? rgb_dec565(iconsObj['HEAT']['iconOffColor']) : 35921; } if (stateKeyNumber == Mode) { - bt[iconIndex] = Icons.GetIcon(tempIcon) + '~' + tempIconOnColor +'~1~' + 'HEAT' + '~'; + bt[iconIndex] = Icons.GetIcon(tempIcon) + '~' + tempIconOnColor + '~1~' + 'HEAT' + '~'; } else { //bt[iconIndex] = Icons.GetIcon(tempIcon) + '~' + tempIconOffColor + '~0~' + 'HEAT' + '~'; bis HMI Fix bt[iconIndex] = Icons.GetIcon(tempIcon) + '~' + tempIconOffColor + '~1~' + 'HEAT' + '~'; @@ -6345,7 +6367,7 @@ function GenerateThermoPage(page: NSPanel.PageThermo): NSPanel.Payload[] { tr tempIconOffColor = iconsObj != undefined ? rgb_dec565(iconsObj['ECO']['iconOffColor']) : 35921; } if (stateKeyNumber == Mode) { - bt[iconIndex] = Icons.GetIcon(tempIcon) + '~' + tempIconOnColor +'~1~' + 'ECO' + '~'; + bt[iconIndex] = Icons.GetIcon(tempIcon) + '~' + tempIconOnColor + '~1~' + 'ECO' + '~'; } else { //bt[iconIndex] = Icons.GetIcon(tempIcon) + '~' + tempIconOffColor + '~0~' + 'ECO' + '~'; bis HMI Fix bt[iconIndex] = Icons.GetIcon(tempIcon) + '~' + tempIconOffColor + '~1~' + 'ECO' + '~'; @@ -6361,7 +6383,7 @@ function GenerateThermoPage(page: NSPanel.PageThermo): NSPanel.Payload[] { tr tempIconOffColor = iconsObj != undefined ? rgb_dec565(iconsObj['FAN_ONLY']['iconOffColor']) : 35921; } if (stateKeyNumber == Mode) { - bt[iconIndex] = Icons.GetIcon(tempIcon) + '~' + tempIconOnColor +'~1~' + 'FAN_ONLY' + '~'; + bt[iconIndex] = Icons.GetIcon(tempIcon) + '~' + tempIconOnColor + '~1~' + 'FAN_ONLY' + '~'; } else { //bt[iconIndex] = Icons.GetIcon(tempIcon) + '~' + tempIconOffColor + '~0~' + 'FAN_ONLY' + '~'; bis HMI Fix bt[iconIndex] = Icons.GetIcon(tempIcon) + '~' + tempIconOffColor + '~1~' + 'FAN_ONLY' + '~'; @@ -6377,7 +6399,7 @@ function GenerateThermoPage(page: NSPanel.PageThermo): NSPanel.Payload[] { tr tempIconOffColor = iconsObj != undefined ? rgb_dec565(iconsObj["DRY"]["iconOffColor"]) : 35921; } if (stateKeyNumber == Mode) { - bt[iconIndex] = Icons.GetIcon(tempIcon) + '~' + tempIconOnColor +'~1~' + 'DRY' + '~'; + bt[iconIndex] = Icons.GetIcon(tempIcon) + '~' + tempIconOnColor + '~1~' + 'DRY' + '~'; } else { //bt[iconIndex] = Icons.GetIcon(tempIcon) + '~' + tempIconOffColor + '~0~' + 'DRY' + '~'; // bis HMI Fix bt[iconIndex] = Icons.GetIcon(tempIcon) + '~' + tempIconOffColor + '~1~' + 'DRY' + '~'; @@ -6459,7 +6481,7 @@ function GenerateThermoPage(page: NSPanel.PageThermo): NSPanel.Payload[] { tr if (page.items[0].popupThermoMode1 != undefined) { thermoPopup = 0; } - + let temperatureUnit = getState(NSPanel_Path + 'Config.temperatureUnit').val; let icon_res = bt[0] + bt[1] + bt[2] + bt[3] + bt[4] + bt[5] + bt[6] + bt[7]; @@ -6522,7 +6544,8 @@ function GenerateThermoPage(page: NSPanel.PageThermo): NSPanel.Payload[] { tr * * @function unsubscribeMediaSubscriptions */ -function unsubscribeMediaSubscriptions(): void { for (let i = 0; i < config.pages.length; i++) { +function unsubscribeMediaSubscriptions (): void { + for (let i = 0; i < config.pages.length; i++) { const page: NSPanel.PageType = config.pages[i]; if (isPageMedia(page)) { let mediaID = page.items[0].id; @@ -6565,8 +6588,9 @@ function unsubscribeMediaSubscriptions(): void { for (let i = 0; i < config.p * @function subscribeMediaSubscriptions * @param {string} id - The ID of the media entity to subscribe to. */ -function subscribeMediaSubscriptions(id: string): void { on( - { id: [id + '.STATE', id + '.ARTIST', id + '.TITLE', id + '.ALBUM', id + '.VOLUME', id + '.REPEAT', id + '.SHUFFLE', id + '.DURATION', id + '.ELAPSED'], change: 'any', ack: true }, +function subscribeMediaSubscriptions (id: string): void { + on( + {id: [id + '.STATE', id + '.ARTIST', id + '.TITLE', id + '.ALBUM', id + '.VOLUME', id + '.REPEAT', id + '.SHUFFLE', id + '.DURATION', id + '.ELAPSED'], change: 'any', ack: true}, async function () { if (useMediaEvents && pageCounter == 1) { GeneratePage(activePage!); @@ -6583,7 +6607,8 @@ function subscribeMediaSubscriptions(id: string): void { on( * @function subscribeMediaSubscriptionsSonosAdd * @param {string} id - The ID of the Sonos media entity to subscribe to. */ -function subscribeMediaSubscriptionsSonosAdd(id: string): void { on({ id: [id + '.QUEUE'], change: 'any', ack: true }, async function () { +function subscribeMediaSubscriptionsSonosAdd (id: string): void { + on({id: [id + '.QUEUE'], change: 'any', ack: true}, async function () { if (useMediaEvents && pageCounter == 1) { GeneratePage(activePage!); } @@ -6601,7 +6626,7 @@ function subscribeMediaSubscriptionsSonosAdd(id: string): void { on({ id: [id * and creates it if not. Supported adapters include Alexa, Sonos, Spotify, Volumio, Squeezebox, and Bose SoundTouch. * Logs errors if alias creation fails. */ -async function createAutoMediaAlias(id: string, mediaDevice: string, adapterPlayerInstance: NSPanel.adapterPlayerInstanceType) { +async function createAutoMediaAlias (id: string, mediaDevice: string, adapterPlayerInstance: NSPanel.adapterPlayerInstanceType) { if (autoCreateAlias) { if (isSetOptionActive) { switch (adapterPlayerInstance) { @@ -6621,20 +6646,20 @@ async function createAutoMediaAlias(id: string, mediaDevice: string, adapterPlay const dpPath: string = adapterPlayerInstance + 'Echo-Devices.' + mediaDevice; try { - setObject(id, { _id: id, type: 'channel', common: { role: 'media', name: 'media' }, native: {} }); - await createAliasAsync(id + '.ACTUAL', dpPath + '.Player.volume', true, { type: 'number', role: 'value.volume', name: 'ACTUAL' }); - await createAliasAsync(id + '.ALBUM', dpPath + '.Player.currentAlbum', true, { type: 'string', role: 'media.album', name: 'ALBUM' }); - await createAliasAsync(id + '.ARTIST', dpPath + '.Player.currentArtist', true, { type: 'string', role: 'media.artist', name: 'ARTIST' }); - await createAliasAsync(id + '.TITLE', dpPath + '.Player.currentTitle', true, { type: 'string', role: 'media.title', name: 'TITLE' }); - await createAliasAsync(id + '.NEXT', dpPath + '.Player.controlNext', true, { type: 'boolean', role: 'button.next', name: 'NEXT' }); - await createAliasAsync(id + '.PREV', dpPath + '.Player.controlPrevious', true, { type: 'boolean', role: 'button.prev', name: 'PREV' }); - await createAliasAsync(id + '.PLAY', dpPath + '.Player.controlPlay', true, { type: 'boolean', role: 'button.play', name: 'PLAY' }); - await createAliasAsync(id + '.PAUSE', dpPath + '.Player.controlPause', true, { type: 'boolean', role: 'button.pause', name: 'PAUSE' }); - await createAliasAsync(id + '.STOP', dpPath + '.Commands.deviceStop', true, { type: 'boolean', role: 'button.stop', name: 'STOP' }); - await createAliasAsync(id + '.STATE', dpPath + '.Player.currentState', true, { type: 'boolean', role: 'media.state', name: 'STATE' }); - await createAliasAsync(id + '.VOLUME', dpPath + '.Player.volume', true, { type: 'number', role: 'level.volume', name: 'VOLUME' }); - await createAliasAsync(id + '.REPEAT', dpPath + '.Player.controlRepeat', true, { type: 'boolean', role: 'media.mode.repeat', name: 'REPEAT' }); - await createAliasAsync(id + '.SHUFFLE', dpPath + '.Player.controlShuffle', true, { type: 'boolean', role: 'media.mode.shuffle', name: 'SHUFFLE' }); + setObject(id, {_id: id, type: 'channel', common: {role: 'media', name: 'media'}, native: {}}); + await createAliasAsync(id + '.ACTUAL', dpPath + '.Player.volume', true, {type: 'number', role: 'value.volume', name: 'ACTUAL'}); + await createAliasAsync(id + '.ALBUM', dpPath + '.Player.currentAlbum', true, {type: 'string', role: 'media.album', name: 'ALBUM'}); + await createAliasAsync(id + '.ARTIST', dpPath + '.Player.currentArtist', true, {type: 'string', role: 'media.artist', name: 'ARTIST'}); + await createAliasAsync(id + '.TITLE', dpPath + '.Player.currentTitle', true, {type: 'string', role: 'media.title', name: 'TITLE'}); + await createAliasAsync(id + '.NEXT', dpPath + '.Player.controlNext', true, {type: 'boolean', role: 'button.next', name: 'NEXT'}); + await createAliasAsync(id + '.PREV', dpPath + '.Player.controlPrevious', true, {type: 'boolean', role: 'button.prev', name: 'PREV'}); + await createAliasAsync(id + '.PLAY', dpPath + '.Player.controlPlay', true, {type: 'boolean', role: 'button.play', name: 'PLAY'}); + await createAliasAsync(id + '.PAUSE', dpPath + '.Player.controlPause', true, {type: 'boolean', role: 'button.pause', name: 'PAUSE'}); + await createAliasAsync(id + '.STOP', dpPath + '.Commands.deviceStop', true, {type: 'boolean', role: 'button.stop', name: 'STOP'}); + await createAliasAsync(id + '.STATE', dpPath + '.Player.currentState', true, {type: 'boolean', role: 'media.state', name: 'STATE'}); + await createAliasAsync(id + '.VOLUME', dpPath + '.Player.volume', true, {type: 'number', role: 'level.volume', name: 'VOLUME'}); + await createAliasAsync(id + '.REPEAT', dpPath + '.Player.controlRepeat', true, {type: 'boolean', role: 'media.mode.repeat', name: 'REPEAT'}); + await createAliasAsync(id + '.SHUFFLE', dpPath + '.Player.controlShuffle', true, {type: 'boolean', role: 'media.mode.shuffle', name: 'SHUFFLE'}); } catch (err: any) { log('error at function createAutoMediaAlias Adapter Alexa2: ' + err.message, 'warn'); } @@ -6642,8 +6667,8 @@ async function createAutoMediaAlias(id: string, mediaDevice: string, adapterPlay //Add Alexa Datapoints > v4.3.3.18 if (existsObject(id + '.DURATION') == false) { let dpPath: string = adapterPlayerInstance + 'Echo-Devices.' + mediaDevice; - await createAliasAsync(id + '.DURATION', dpPath + '.Player.mediaLength', true, { type: 'string', role: 'media.duration.text', name: 'DURATION' }); - await createAliasAsync(id + '.ELAPSED', dpPath + '.Player.mediaProgressStr', true, { type: 'string', role: 'media.elapsed.text', name: 'ELAPSED' }); + await createAliasAsync(id + '.DURATION', dpPath + '.Player.mediaLength', true, {type: 'string', role: 'media.duration.text', name: 'DURATION'}); + await createAliasAsync(id + '.ELAPSED', dpPath + '.Player.mediaProgressStr', true, {type: 'string', role: 'media.elapsed.text', name: 'ELAPSED'}); } } break; @@ -6663,25 +6688,25 @@ async function createAutoMediaAlias(id: string, mediaDevice: string, adapterPlay const dpPath: string = adapterPlayerInstance + 'root.' + mediaDevice; try { - setObject(id, { _id: id, type: 'channel', common: { role: 'media', name: 'media' }, native: {} }); - await createAliasAsync(id + '.ACTUAL', dpPath + '.volume', true, { type: 'number', role: 'value.volume', name: 'ACTUAL' }); - await createAliasAsync(id + '.ALBUM', dpPath + '.current_album', true, { type: 'string', role: 'media.album', name: 'ALBUM' }); - await createAliasAsync(id + '.ARTIST', dpPath + '.current_artist', true, { type: 'string', role: 'media.artist', name: 'ARTIST' }); - await createAliasAsync(id + '.TITLE', dpPath + '.current_title', true, { type: 'string', role: 'media.title', name: 'TITLE' }); - await createAliasAsync(id + '.CONTEXT_DESCRIPTION', dpPath + '.current_station', true, { + setObject(id, {_id: id, type: 'channel', common: {role: 'media', name: 'media'}, native: {}}); + await createAliasAsync(id + '.ACTUAL', dpPath + '.volume', true, {type: 'number', role: 'value.volume', name: 'ACTUAL'}); + await createAliasAsync(id + '.ALBUM', dpPath + '.current_album', true, {type: 'string', role: 'media.album', name: 'ALBUM'}); + await createAliasAsync(id + '.ARTIST', dpPath + '.current_artist', true, {type: 'string', role: 'media.artist', name: 'ARTIST'}); + await createAliasAsync(id + '.TITLE', dpPath + '.current_title', true, {type: 'string', role: 'media.title', name: 'TITLE'}); + await createAliasAsync(id + '.CONTEXT_DESCRIPTION', dpPath + '.current_station', true, { type: 'string', role: 'media.station', name: 'CONTEXT_DESCRIPTION', }); - await createAliasAsync(id + '.NEXT', dpPath + '.next', true, { type: 'boolean', role: 'button.next', name: 'NEXT' }); - await createAliasAsync(id + '.PREV', dpPath + '.prev', true, { type: 'boolean', role: 'button.prev', name: 'PREV' }); - await createAliasAsync(id + '.PLAY', dpPath + '.play', true, { type: 'boolean', role: 'button.play', name: 'PLAY' }); - await createAliasAsync(id + '.PAUSE', dpPath + '.pause', true, { type: 'boolean', role: 'button.pause', name: 'PAUSE' }); - await createAliasAsync(id + '.STOP', dpPath + '.stop', true, { type: 'boolean', role: 'button.stop', name: 'STOP' }); - await createAliasAsync(id + '.STATE', dpPath + '.state_simple', true, { type: 'boolean', role: 'media.state', name: 'STATE' }); - await createAliasAsync(id + '.VOLUME', dpPath + '.volume', true, { type: 'number', role: 'level.volume', name: 'VOLUME' }); - await createAliasAsync(id + '.REPEAT', dpPath + '.repeat', true, { type: 'number', role: 'media.mode.repeat', name: 'REPEAT' }); - await createAliasAsync(id + '.SHUFFLE', dpPath + '.shuffle', true, { type: 'boolean', role: 'media.mode.shuffle', name: 'SHUFFLE' }); + await createAliasAsync(id + '.NEXT', dpPath + '.next', true, {type: 'boolean', role: 'button.next', name: 'NEXT'}); + await createAliasAsync(id + '.PREV', dpPath + '.prev', true, {type: 'boolean', role: 'button.prev', name: 'PREV'}); + await createAliasAsync(id + '.PLAY', dpPath + '.play', true, {type: 'boolean', role: 'button.play', name: 'PLAY'}); + await createAliasAsync(id + '.PAUSE', dpPath + '.pause', true, {type: 'boolean', role: 'button.pause', name: 'PAUSE'}); + await createAliasAsync(id + '.STOP', dpPath + '.stop', true, {type: 'boolean', role: 'button.stop', name: 'STOP'}); + await createAliasAsync(id + '.STATE', dpPath + '.state_simple', true, {type: 'boolean', role: 'media.state', name: 'STATE'}); + await createAliasAsync(id + '.VOLUME', dpPath + '.volume', true, {type: 'number', role: 'level.volume', name: 'VOLUME'}); + await createAliasAsync(id + '.REPEAT', dpPath + '.repeat', true, {type: 'number', role: 'media.mode.repeat', name: 'REPEAT'}); + await createAliasAsync(id + '.SHUFFLE', dpPath + '.shuffle', true, {type: 'boolean', role: 'media.mode.shuffle', name: 'SHUFFLE'}); } catch (err: any) { log('error at function createAutoMediaAlias Adapter sonos: ' + err.message, 'warn'); } @@ -6689,9 +6714,9 @@ async function createAutoMediaAlias(id: string, mediaDevice: string, adapterPlay //Add Sonos Datapoints > v4.3.3.15 if (existsObject(id + '.QUEUE') == false) { let dpPath: string = adapterPlayerInstance + 'root.' + mediaDevice; - await createAliasAsync(id + '.QUEUE', dpPath + '.queue', true, { type: 'string', role: 'state', name: 'QUEUE' }); - await createAliasAsync(id + '.DURATION', dpPath + '.current_duration_s', true, { type: 'string', role: 'media.duration.text', name: 'DURATION' }); - await createAliasAsync(id + '.ELAPSED', dpPath + '.current_elapsed_s', true, { type: 'string', role: 'media.elapsed.text', name: 'ELAPSED' }); + await createAliasAsync(id + '.QUEUE', dpPath + '.queue', true, {type: 'string', role: 'state', name: 'QUEUE'}); + await createAliasAsync(id + '.DURATION', dpPath + '.current_duration_s', true, {type: 'string', role: 'media.duration.text', name: 'DURATION'}); + await createAliasAsync(id + '.ELAPSED', dpPath + '.current_elapsed_s', true, {type: 'string', role: 'media.elapsed.text', name: 'ELAPSED'}); } } break; @@ -6711,25 +6736,25 @@ async function createAutoMediaAlias(id: string, mediaDevice: string, adapterPlay const dpPath: string = adapterPlayerInstance; try { - setObject(id, { _id: id + 'player', type: 'channel', common: { role: 'media', name: 'media' }, native: {} }); - await createAliasAsync(id + '.ACTUAL', dpPath + 'player.volume', true, { type: 'number', role: 'value.volume', name: 'ACTUAL' }); - await createAliasAsync(id + '.ALBUM', dpPath + 'player.album', true, { type: 'string', role: 'media.album', name: 'ALBUM' }); - await createAliasAsync(id + '.ARTIST', dpPath + 'player.artistName', true, { type: 'string', role: 'media.artist', name: 'ARTIST' }); - await createAliasAsync(id + '.TITLE', dpPath + 'player.trackName', true, { type: 'string', role: 'media.title', name: 'TITLE' }); - await createAliasAsync(id + '.CONTEXT_DESCRIPTION', dpPath + 'player.contextDescription', true, { + setObject(id, {_id: id + 'player', type: 'channel', common: {role: 'media', name: 'media'}, native: {}}); + await createAliasAsync(id + '.ACTUAL', dpPath + 'player.volume', true, {type: 'number', role: 'value.volume', name: 'ACTUAL'}); + await createAliasAsync(id + '.ALBUM', dpPath + 'player.album', true, {type: 'string', role: 'media.album', name: 'ALBUM'}); + await createAliasAsync(id + '.ARTIST', dpPath + 'player.artistName', true, {type: 'string', role: 'media.artist', name: 'ARTIST'}); + await createAliasAsync(id + '.TITLE', dpPath + 'player.trackName', true, {type: 'string', role: 'media.title', name: 'TITLE'}); + await createAliasAsync(id + '.CONTEXT_DESCRIPTION', dpPath + 'player.contextDescription', true, { type: 'string', role: 'media.station', name: 'CONTEXT_DESCRIPTION', }); - await createAliasAsync(id + '.NEXT', dpPath + 'player.skipPlus', true, { type: 'boolean', role: 'button.next', name: 'NEXT' }); - await createAliasAsync(id + '.PREV', dpPath + 'player.skipMinus', true, { type: 'boolean', role: 'button.prev', name: 'PREV' }); - await createAliasAsync(id + '.PLAY', dpPath + 'player.play', true, { type: 'boolean', role: 'button.play', name: 'PLAY' }); - await createAliasAsync(id + '.PAUSE', dpPath + 'player.pause', true, { type: 'boolean', role: 'button.pause', name: 'PAUSE' }); - await createAliasAsync(id + '.STOP', dpPath + 'player.pause', true, { type: 'boolean', role: 'button.stop', name: 'STOP' }); - await createAliasAsync(id + '.STATE', dpPath + 'player.isPlaying', true, { type: 'boolean', role: 'media.state', name: 'STATE' }); - await createAliasAsync(id + '.VOLUME', dpPath + 'player.volume', true, { type: 'number', role: 'level.volume', name: 'VOLUME' }); - await createAliasAsync(id + '.REPEAT', dpPath + 'player.repeat', true, { type: 'string', role: 'value', name: 'REPEAT' }); - await createAliasAsync(id + '.SHUFFLE', dpPath + 'player.shuffle', true, { type: 'string', role: 'value', name: 'SHUFFLE' }); + await createAliasAsync(id + '.NEXT', dpPath + 'player.skipPlus', true, {type: 'boolean', role: 'button.next', name: 'NEXT'}); + await createAliasAsync(id + '.PREV', dpPath + 'player.skipMinus', true, {type: 'boolean', role: 'button.prev', name: 'PREV'}); + await createAliasAsync(id + '.PLAY', dpPath + 'player.play', true, {type: 'boolean', role: 'button.play', name: 'PLAY'}); + await createAliasAsync(id + '.PAUSE', dpPath + 'player.pause', true, {type: 'boolean', role: 'button.pause', name: 'PAUSE'}); + await createAliasAsync(id + '.STOP', dpPath + 'player.pause', true, {type: 'boolean', role: 'button.stop', name: 'STOP'}); + await createAliasAsync(id + '.STATE', dpPath + 'player.isPlaying', true, {type: 'boolean', role: 'media.state', name: 'STATE'}); + await createAliasAsync(id + '.VOLUME', dpPath + 'player.volume', true, {type: 'number', role: 'level.volume', name: 'VOLUME'}); + await createAliasAsync(id + '.REPEAT', dpPath + 'player.repeat', true, {type: 'string', role: 'value', name: 'REPEAT'}); + await createAliasAsync(id + '.SHUFFLE', dpPath + 'player.shuffle', true, {type: 'string', role: 'value', name: 'SHUFFLE'}); } catch (err: any) { log('error at function createAutoMediaAlias Adapter spotify-premium: ' + err.message, 'warn'); } @@ -6738,8 +6763,8 @@ async function createAutoMediaAlias(id: string, mediaDevice: string, adapterPlay //Spotify-Premium has Role value and a known Bug in player.progress if (existsObject(id + '.DURATION') == false) { const dpPath: string = adapterPlayerInstance; - await createAliasAsync(id + '.DURATION', dpPath + 'player.duration', true, { type: 'string', role: 'media.duration.text', name: 'DURATION' }); - await createAliasAsync(id + '.ELAPSED', dpPath + 'player.progress', true, { type: 'string', role: 'media.elapsed.text', name: 'ELAPSED' }); + await createAliasAsync(id + '.DURATION', dpPath + 'player.duration', true, {type: 'string', role: 'media.duration.text', name: 'DURATION'}); + await createAliasAsync(id + '.ELAPSED', dpPath + 'player.progress', true, {type: 'string', role: 'media.elapsed.text', name: 'ELAPSED'}); } } break; @@ -6759,21 +6784,21 @@ async function createAutoMediaAlias(id: string, mediaDevice: string, adapterPlay const dpPath: string = adapterPlayerInstance; try { - setObject(id, { _id: id, type: 'channel', common: { role: 'media', name: 'media' }, native: {} }); - await createAliasAsync(id + '.ACTUAL', dpPath + 'playbackInfo.volume', true, { type: 'number', role: 'value.volume', name: 'ACTUAL' }); - await createAliasAsync(id + '.ALBUM', dpPath + 'playbackInfo.album', true, { type: 'string', role: 'media.album', name: 'ALBUM' }); - await createAliasAsync(id + '.ARTIST', dpPath + 'playbackInfo.artist', true, { type: 'string', role: 'media.artist', name: 'ARTIST' }); - await createAliasAsync(id + '.TITLE', dpPath + 'playbackInfo.title', true, { type: 'string', role: 'media.title', name: 'TITLE' }); - await createAliasAsync(id + '.NEXT', dpPath + 'player.next', true, { type: 'boolean', role: 'button.next', name: 'NEXT' }); - await createAliasAsync(id + '.PREV', dpPath + 'player.prev', true, { type: 'boolean', role: 'button.prev', name: 'PREV' }); - await createAliasAsync(id + '.PLAY', dpPath + 'player.play', true, { type: 'boolean', role: 'button.play', name: 'PLAY' }); - await createAliasAsync(id + '.PAUSE', dpPath + 'player.toggle', true, { type: 'boolean', role: 'button.pause', name: 'PAUSE' }); - await createAliasAsync(id + '.STOP', dpPath + 'player.stop', true, { type: 'boolean', role: 'button.stop', name: 'STOP' }); - await createAliasAsync(id + '.STATE', dpPath + 'playbackInfo.status', true, { type: 'boolean', role: 'media.state', name: 'STATE' }); - await createAliasAsync(id + '.VOLUME', dpPath + 'playbackInfo.volume', true, { type: 'number', role: 'level.volume', name: 'VOLUME' }); - await createAliasAsync(id + '.REPEAT', dpPath + 'playbackInfo.repeat', true, { type: 'number', role: 'media.mode.repeat', name: 'REPEAT' }); - await createAliasAsync(id + '.SHUFFLE', dpPath + 'queue.shuffle', true, { type: 'boolean', role: 'media.mode.shuffle', name: 'SHUFFLE' }); - await createAliasAsync(id + '.status', dpPath + 'playbackInfo.status', true, { type: 'string', role: 'media.state', name: 'status' }); + setObject(id, {_id: id, type: 'channel', common: {role: 'media', name: 'media'}, native: {}}); + await createAliasAsync(id + '.ACTUAL', dpPath + 'playbackInfo.volume', true, {type: 'number', role: 'value.volume', name: 'ACTUAL'}); + await createAliasAsync(id + '.ALBUM', dpPath + 'playbackInfo.album', true, {type: 'string', role: 'media.album', name: 'ALBUM'}); + await createAliasAsync(id + '.ARTIST', dpPath + 'playbackInfo.artist', true, {type: 'string', role: 'media.artist', name: 'ARTIST'}); + await createAliasAsync(id + '.TITLE', dpPath + 'playbackInfo.title', true, {type: 'string', role: 'media.title', name: 'TITLE'}); + await createAliasAsync(id + '.NEXT', dpPath + 'player.next', true, {type: 'boolean', role: 'button.next', name: 'NEXT'}); + await createAliasAsync(id + '.PREV', dpPath + 'player.prev', true, {type: 'boolean', role: 'button.prev', name: 'PREV'}); + await createAliasAsync(id + '.PLAY', dpPath + 'player.play', true, {type: 'boolean', role: 'button.play', name: 'PLAY'}); + await createAliasAsync(id + '.PAUSE', dpPath + 'player.toggle', true, {type: 'boolean', role: 'button.pause', name: 'PAUSE'}); + await createAliasAsync(id + '.STOP', dpPath + 'player.stop', true, {type: 'boolean', role: 'button.stop', name: 'STOP'}); + await createAliasAsync(id + '.STATE', dpPath + 'playbackInfo.status', true, {type: 'boolean', role: 'media.state', name: 'STATE'}); + await createAliasAsync(id + '.VOLUME', dpPath + 'playbackInfo.volume', true, {type: 'number', role: 'level.volume', name: 'VOLUME'}); + await createAliasAsync(id + '.REPEAT', dpPath + 'playbackInfo.repeat', true, {type: 'number', role: 'media.mode.repeat', name: 'REPEAT'}); + await createAliasAsync(id + '.SHUFFLE', dpPath + 'queue.shuffle', true, {type: 'boolean', role: 'media.mode.shuffle', name: 'SHUFFLE'}); + await createAliasAsync(id + '.status', dpPath + 'playbackInfo.status', true, {type: 'string', role: 'media.state', name: 'status'}); } catch (err: any) { log('error function createAutoMediaAlias Adapter volumio: ' + err.message, 'warn'); } @@ -6781,7 +6806,7 @@ async function createAutoMediaAlias(id: string, mediaDevice: string, adapterPlay //Add Volumio Datapoints > v4.3.3.42 if (existsObject(id + '.DURATION') == false) { const dpPath: string = adapterPlayerInstance; - await createAliasAsync(id + '.DURATION', dpPath + 'playbackInfo.duration', true, { type: 'string', role: 'media.duration', name: 'DURATION' }); + await createAliasAsync(id + '.DURATION', dpPath + 'playbackInfo.duration', true, {type: 'string', role: 'media.duration', name: 'DURATION'}); //await createAliasAsync(id + '.ELAPSED', dpPath + 'player.progress', true, {type: 'string', role: 'media.elapsed.text', name: 'ELAPSED'}); } } @@ -6802,37 +6827,37 @@ async function createAutoMediaAlias(id: string, mediaDevice: string, adapterPlay const dpPath: string = adapterPlayerInstance + 'Players.' + mediaDevice; try { - setObject(id, { _id: id, type: 'channel', common: { role: 'media', name: 'media' }, native: {} }); - await createAliasAsync(id + '.ALBUM', dpPath + '.Album', true, { type: 'string', role: 'media.album', name: 'ALBUM' }); - await createAliasAsync(id + '.ARTIST', dpPath + '.Artist', true, { type: 'string', role: 'media.artist', name: 'ARTIST' }); - await createAliasAsync(id + '.TITLE', dpPath + '.Title', true, { type: 'string', role: 'media.title', name: 'TITLE' }); - await createAliasAsync(id + '.NEXT', dpPath + '.btnForward', true, { type: 'boolean', role: 'button.forward', name: 'NEXT' }); - await createAliasAsync(id + '.PREV', dpPath + '.btnRewind', true, { type: 'boolean', role: 'button.reverse', name: 'PREV' }); - await createAliasAsync(id + '.PLAY', dpPath + '.state', true, { + setObject(id, {_id: id, type: 'channel', common: {role: 'media', name: 'media'}, native: {}}); + await createAliasAsync(id + '.ALBUM', dpPath + '.Album', true, {type: 'string', role: 'media.album', name: 'ALBUM'}); + await createAliasAsync(id + '.ARTIST', dpPath + '.Artist', true, {type: 'string', role: 'media.artist', name: 'ARTIST'}); + await createAliasAsync(id + '.TITLE', dpPath + '.Title', true, {type: 'string', role: 'media.title', name: 'TITLE'}); + await createAliasAsync(id + '.NEXT', dpPath + '.btnForward', true, {type: 'boolean', role: 'button.forward', name: 'NEXT'}); + await createAliasAsync(id + '.PREV', dpPath + '.btnRewind', true, {type: 'boolean', role: 'button.reverse', name: 'PREV'}); + await createAliasAsync(id + '.PLAY', dpPath + '.state', true, { type: 'boolean', role: 'media.state', name: 'PLAY', - alias: { id: dpPath + '.state', read: 'val === 1 ? true : false' }, + alias: {id: dpPath + '.state', read: 'val === 1 ? true : false'}, }); - await createAliasAsync(id + '.PAUSE', dpPath + '.state', true, { + await createAliasAsync(id + '.PAUSE', dpPath + '.state', true, { type: 'boolean', role: 'media.state', name: 'PAUSE', - alias: { id: dpPath + '.state', read: 'val === 0 ? true : false' }, + alias: {id: dpPath + '.state', read: 'val === 0 ? true : false'}, }); - await createAliasAsync(id + '.STOP', dpPath + '.state', true, { + await createAliasAsync(id + '.STOP', dpPath + '.state', true, { type: 'boolean', role: 'media.state', name: 'STOP', - alias: { id: dpPath + '.state', read: 'val === 0 ? true : false' }, + alias: {id: dpPath + '.state', read: 'val === 0 ? true : false'}, }); - await createAliasAsync(id + '.STATE', dpPath + '.Power', true, { type: 'number', role: 'switch', name: 'STATE' }); - await createAliasAsync(id + '.VOLUME', dpPath + '.Volume', true, { type: 'number', role: 'level.volume', name: 'VOLUME' }); - await createAliasAsync(id + '.VOLUME_ACTUAL', dpPath + '.Volume', true, { type: 'number', role: 'value.volume', name: 'VOLUME_ACTUAL' }); - await createAliasAsync(id + '.SHUFFLE', dpPath + '.PlaylistShuffle', true, { type: 'string', role: 'media.mode.shuffle', name: 'SHUFFLE' }); - await createAliasAsync(id + '.REPEAT', dpPath + '.PlaylistRepeat', true, { type: 'number', role: 'media.mode.repeat', name: 'REPEAT' }); - await createAliasAsync(id + '.DURATION', dpPath + '.Duration', true, { type: 'string', role: 'media.duration', name: 'DURATION' }); - await createAliasAsync(id + '.ELAPSED', dpPath + '.Time', true, { type: 'string', role: 'media.elapsed', name: 'ELAPSED' }); + await createAliasAsync(id + '.STATE', dpPath + '.Power', true, {type: 'number', role: 'switch', name: 'STATE'}); + await createAliasAsync(id + '.VOLUME', dpPath + '.Volume', true, {type: 'number', role: 'level.volume', name: 'VOLUME'}); + await createAliasAsync(id + '.VOLUME_ACTUAL', dpPath + '.Volume', true, {type: 'number', role: 'value.volume', name: 'VOLUME_ACTUAL'}); + await createAliasAsync(id + '.SHUFFLE', dpPath + '.PlaylistShuffle', true, {type: 'string', role: 'media.mode.shuffle', name: 'SHUFFLE'}); + await createAliasAsync(id + '.REPEAT', dpPath + '.PlaylistRepeat', true, {type: 'number', role: 'media.mode.repeat', name: 'REPEAT'}); + await createAliasAsync(id + '.DURATION', dpPath + '.Duration', true, {type: 'string', role: 'media.duration', name: 'DURATION'}); + await createAliasAsync(id + '.ELAPSED', dpPath + '.Time', true, {type: 'string', role: 'media.elapsed', name: 'ELAPSED'}); } catch (err: any) { log('error at function createAutoMediaAlias Adapter Squeezebox: ' + err.message, 'warn'); } @@ -6854,26 +6879,26 @@ async function createAutoMediaAlias(id: string, mediaDevice: string, adapterPlay try { let dpPath: string = adapterPlayerInstance; - await extendObjectAsync(id, { _id: id, type: 'channel', common: { role: 'media', name: 'media' }, native: {} }); - await createAliasAsync(id + '.ACTUAL', dpPath + 'volume', true, { type: 'number', role: 'value.volume', name: 'ACTUAL' }); - await createAliasAsync(id + '.VOLUME', dpPath + 'volume', true, { type: 'number', role: 'level.volume', name: 'VOLUME' }); - await createAliasAsync(id + '.STATE', dpPath + 'on', true, { type: 'boolean', role: 'media.state', name: 'STATE' }); + await extendObjectAsync(id, {_id: id, type: 'channel', common: {role: 'media', name: 'media'}, native: {}}); + await createAliasAsync(id + '.ACTUAL', dpPath + 'volume', true, {type: 'number', role: 'value.volume', name: 'ACTUAL'}); + await createAliasAsync(id + '.VOLUME', dpPath + 'volume', true, {type: 'number', role: 'level.volume', name: 'VOLUME'}); + await createAliasAsync(id + '.STATE', dpPath + 'on', true, {type: 'boolean', role: 'media.state', name: 'STATE'}); dpPath = adapterPlayerInstance + 'nowPlaying'; - await createAliasAsync(id + '.ALBUM', dpPath + '.album', true, { type: 'string', role: 'media.album', name: 'ALBUM' }); - await createAliasAsync(id + '.ARTIST', dpPath + '.artist', true, { type: 'string', role: 'media.artist', name: 'ARTIST' }); - await createAliasAsync(id + '.TITLE', dpPath + '.track', true, { type: 'string', role: 'media.title', name: 'TITLE' }); - await createAliasAsync(id + '.DURATION', dpPath + '.total', true, { type: 'string', role: 'media.duration.text', name: 'DURATION' }); - await createAliasAsync(id + '.ELAPSED', dpPath + '.time', true, { type: 'string', role: 'media.elapsed.text', name: 'ELAPSED' }); - await createAliasAsync(id + '.REPEAT', dpPath + '.repeat', true, { type: 'boolean', role: 'media.mode.repeat', name: 'REPEAT' }); - await createAliasAsync(id + '.SHUFFLE', dpPath + '.shuffle', true, { type: 'boolean', role: 'media.mode.shuffle', name: 'SHUFFLE' }); + await createAliasAsync(id + '.ALBUM', dpPath + '.album', true, {type: 'string', role: 'media.album', name: 'ALBUM'}); + await createAliasAsync(id + '.ARTIST', dpPath + '.artist', true, {type: 'string', role: 'media.artist', name: 'ARTIST'}); + await createAliasAsync(id + '.TITLE', dpPath + '.track', true, {type: 'string', role: 'media.title', name: 'TITLE'}); + await createAliasAsync(id + '.DURATION', dpPath + '.total', true, {type: 'string', role: 'media.duration.text', name: 'DURATION'}); + await createAliasAsync(id + '.ELAPSED', dpPath + '.time', true, {type: 'string', role: 'media.elapsed.text', name: 'ELAPSED'}); + await createAliasAsync(id + '.REPEAT', dpPath + '.repeat', true, {type: 'boolean', role: 'media.mode.repeat', name: 'REPEAT'}); + await createAliasAsync(id + '.SHUFFLE', dpPath + '.shuffle', true, {type: 'boolean', role: 'media.mode.shuffle', name: 'SHUFFLE'}); dpPath = adapterPlayerInstance + 'keys'; - await createAliasAsync(id + '.NEXT', dpPath + '.NEXT_TRACK', true, { type: 'boolean', role: 'button.next', name: 'NEXT' }); - await createAliasAsync(id + '.PREV', dpPath + '.PREV_TRACK', true, { type: 'boolean', role: 'button.prev', name: 'PREV' }); - await createAliasAsync(id + '.PLAY', dpPath + '.PLAY', true, { type: 'boolean', role: 'button.play', name: 'PLAY' }); - await createAliasAsync(id + '.PAUSE', dpPath + '.PAUSE', true, { type: 'boolean', role: 'button.pause', name: 'PAUSE' }); - await createAliasAsync(id + '.STOP', dpPath + '.STOP', true, { type: 'boolean', role: 'button.stop', name: 'STOP' }); + await createAliasAsync(id + '.NEXT', dpPath + '.NEXT_TRACK', true, {type: 'boolean', role: 'button.next', name: 'NEXT'}); + await createAliasAsync(id + '.PREV', dpPath + '.PREV_TRACK', true, {type: 'boolean', role: 'button.prev', name: 'PREV'}); + await createAliasAsync(id + '.PLAY', dpPath + '.PLAY', true, {type: 'boolean', role: 'button.play', name: 'PLAY'}); + await createAliasAsync(id + '.PAUSE', dpPath + '.PAUSE', true, {type: 'boolean', role: 'button.pause', name: 'PAUSE'}); + await createAliasAsync(id + '.STOP', dpPath + '.STOP', true, {type: 'boolean', role: 'button.stop', name: 'STOP'}); } catch (err: any) { log('error at function createAutoMediaAlias Adapter bosesoundtouch: ' + err.message, 'warn'); } @@ -6897,7 +6922,8 @@ async function createAutoMediaAlias(id: string, mediaDevice: string, adapterPlay * @param {NSPanel.PageMedia} page - The media page configuration. * @returns {NSPanel.Payload[]} The payload array for the media page. */ -function GenerateMediaPage(page: NSPanel.PageMedia): NSPanel.Payload[] { try { +function GenerateMediaPage (page: NSPanel.PageMedia): NSPanel.Payload[] { + try { unsubscribeMediaSubscriptions(); if (!page.items[0].id) throw new Error('Missing page id for cardMedia!'); @@ -6920,13 +6946,13 @@ function GenerateMediaPage(page: NSPanel.PageMedia): NSPanel.Payload[] { try // Leave the display on if the alwaysOnDisplay parameter is specified (true) if (page.type == 'cardMedia' && pageCounter == 0 && page.items[0].alwaysOnDisplay != undefined) { - out_msgs.push({ payload: 'pageType~cardMedia' }); + out_msgs.push({payload: 'pageType~cardMedia'}); if (page.items[0].alwaysOnDisplay != undefined) { if (page.items[0].alwaysOnDisplay) { pageCounter = 1; if (alwaysOn == false) { alwaysOn = true; - SendToPanel({ payload: 'timeout~0' }); + SendToPanel({payload: 'timeout~0'}); subscribeMediaSubscriptions(page.items[0].id); if (v2Adapter == 'sonos') { subscribeMediaSubscriptionsSonosAdd(page.items[0].id); @@ -6947,7 +6973,7 @@ function GenerateMediaPage(page: NSPanel.PageMedia): NSPanel.Payload[] { try } else if (page.type == 'cardMedia' && pageCounter == -1) { //Do Nothing } else { - out_msgs.push({ payload: 'pageType~cardMedia' }); + out_msgs.push({payload: 'pageType~cardMedia'}); } if (existsObject(id)) { @@ -7290,7 +7316,7 @@ function GenerateMediaPage(page: NSPanel.PageMedia): NSPanel.Payload[] { try let urlString: string = `${getState(vInstance + 'info.host').val}/api/listplaylists`; axios - .get(urlString, { headers: { 'User-Agent': 'ioBroker' } }) + .get(urlString, {headers: {'User-Agent': 'ioBroker'}}) .then(async function (response) { if (response.status === 200) { if (Debug) { @@ -7338,7 +7364,7 @@ function GenerateMediaPage(page: NSPanel.PageMedia): NSPanel.Payload[] { try let urlString: string = `${getState(vInstance + 'info.host').val}/api/getQueue`; axios - .get(urlString, { headers: { 'User-Agent': 'ioBroker' } }) + .get(urlString, {headers: {'User-Agent': 'ioBroker'}}) .then(async function (response) { if (response.status === 200) { if (Debug) { @@ -7539,7 +7565,8 @@ function GenerateMediaPage(page: NSPanel.PageMedia): NSPanel.Payload[] { try * @returns {Promise} A promise that resolves when the alias has been created. * @throws {Error} If an error occurs during the alias creation. */ -async function createAutoAlarmAlias(id: string, nsPath: string) { try { +async function createAutoAlarmAlias (id: string, nsPath: string) { + try { if (Debug) { log('Alarm Alias Path: ' + id, 'info'); log('Alarm 0_userdata Path: ' + nsPath, 'info'); @@ -7553,17 +7580,17 @@ async function createAutoAlarmAlias(id: string, nsPath: string) { try { existsState(nsPath + '.PIN_Failed') == false || existsState(nsPath + '.PANEL') == false ) { - await createStateAsync(nsPath + '.AlarmPin', '0000', { type: 'string', write: true }); - await createStateAsync(nsPath + '.AlarmState', 'disarmed', { type: 'string', write: false }); - await createStateAsync(nsPath + '.AlarmType', 'D1', { type: 'string', write: false }); - await createStateAsync(nsPath + '.PIN_Failed', 0, { type: 'number', write: false }); - await createStateAsync(nsPath + '.PANEL', NSPanel_Path, { type: 'string', write: false }); - setObject(id, { _id: id, type: 'channel', common: { role: 'sensor.fire.alarm', name: 'alarm' }, native: {} }); - await createAliasAsync(id + '.ACTUAL', nsPath + '.AlarmState', true, { type: 'string', role: 'state', name: 'ACTUAL' }); - await createAliasAsync(id + '.PIN', nsPath + '.AlarmPin', true, { type: 'string', role: 'state', name: 'PIN' }); - await createAliasAsync(id + '.TYPE', nsPath + '.AlarmType', true, { type: 'string', role: 'state', name: 'TYPE' }); - await createAliasAsync(id + '.PIN_Failed', nsPath + '.PIN_Failed', true, { type: 'number', role: 'state', name: 'PIN_Failed' }); - await createAliasAsync(id + '.PANEL', nsPath + '.PANEL', true, { type: 'string', role: 'state', name: 'PANEL' }); + await createStateAsync(nsPath + '.AlarmPin', '0000', {type: 'string', write: true}); + await createStateAsync(nsPath + '.AlarmState', 'disarmed', {type: 'string', write: false}); + await createStateAsync(nsPath + '.AlarmType', 'D1', {type: 'string', write: false}); + await createStateAsync(nsPath + '.PIN_Failed', 0, {type: 'number', write: false}); + await createStateAsync(nsPath + '.PANEL', NSPanel_Path, {type: 'string', write: false}); + setObject(id, {_id: id, type: 'channel', common: {role: 'sensor.fire.alarm', name: 'alarm'}, native: {}}); + await createAliasAsync(id + '.ACTUAL', nsPath + '.AlarmState', true, {type: 'string', role: 'state', name: 'ACTUAL'}); + await createAliasAsync(id + '.PIN', nsPath + '.AlarmPin', true, {type: 'string', role: 'state', name: 'PIN'}); + await createAliasAsync(id + '.TYPE', nsPath + '.AlarmType', true, {type: 'string', role: 'state', name: 'TYPE'}); + await createAliasAsync(id + '.PIN_Failed', nsPath + '.PIN_Failed', true, {type: 'number', role: 'state', name: 'PIN_Failed'}); + await createAliasAsync(id + '.PANEL', nsPath + '.PANEL', true, {type: 'string', role: 'state', name: 'PANEL'}); } } } @@ -7581,14 +7608,15 @@ async function createAutoAlarmAlias(id: string, nsPath: string) { try { * @param {NSPanel.PageAlarm} page - The alarm page configuration. * @returns {NSPanel.Payload[]} The payload array for the alarm page. */ -function GenerateAlarmPage(page: NSPanel.PageAlarm): NSPanel.Payload[] { try { +function GenerateAlarmPage (page: NSPanel.PageAlarm): NSPanel.Payload[] { + try { activePage = page; let id = page.items[0].id; let name = page.heading; let out_msgs: NSPanel.Payload[] = []; - out_msgs.push({ payload: 'pageType~cardAlarm' }); + out_msgs.push({payload: 'pageType~cardAlarm'}); let nsPath = NSPanel_Alarm_Path + 'Alarm'; if (page.items[0].autoCreateALias) { @@ -7677,12 +7705,12 @@ function GenerateAlarmPage(page: NSPanel.PageAlarm): NSPanel.Payload[] { try } if (entityState == 'arming' || entityState == 'pending') { icon = Icons.GetIcon('shield'); //icon*~* - iconcolor = rgb_dec565({ red: 243, green: 179, blue: 0 }); //iconcolor*~* + iconcolor = rgb_dec565({red: 243, green: 179, blue: 0}); //iconcolor*~* numpadStatus = 'disable'; //numpadStatus*~* flashing = 'enable'; //flashing* } if (entityState == 'triggered') { - iconcolor = rgb_dec565({ red: 223, green: 76, blue: 30 }); //icon*~* + iconcolor = rgb_dec565({red: 223, green: 76, blue: 30}); //icon*~* icon = Icons.GetIcon('bell-ring'); //iconcolor*~* numpadStatus = 'enable'; //numpadStatus*~* flashing = 'enable'; //flashing* @@ -7746,7 +7774,8 @@ function GenerateAlarmPage(page: NSPanel.PageAlarm): NSPanel.Payload[] { try * @returns {Promise} A promise that resolves when the alias has been created. * @throws {Error} If an error occurs during the alias creation. */ -async function createAutoUnlockAlias(id: string, dpPath: string) { try { +async function createAutoUnlockAlias (id: string, dpPath: string) { + try { if (Debug) { log('Unlock Alias Path: ' + id, 'info'); log('Unlock 0_userdata Path: ' + dpPath, 'info'); @@ -7754,11 +7783,11 @@ async function createAutoUnlockAlias(id: string, dpPath: string) { try { if (autoCreateAlias) { if (isSetOptionActive) { if (existsState(dpPath + 'UnlockPin') == false || existsState(dpPath + 'Access') == false) { - await createStateAsync(dpPath + 'UnlockPin', '0000', { type: 'string', write: true }); - await createStateAsync(dpPath + 'Access', 'false', { type: 'boolean', write: false }); - setObject(id, { _id: id, type: 'channel', common: { role: 'sensor.fire.alarm', name: 'sensor.fire.alarm' }, native: {} }); - await createAliasAsync(id + '.PIN', dpPath + 'UnlockPin', true, { type: 'string', role: 'state', name: 'PIN' }); - await createAliasAsync(id + '.ACTUAL', dpPath + 'Access', true, { type: 'boolean', role: 'sensor.fire.alarm', name: 'ACTUAL' }); + await createStateAsync(dpPath + 'UnlockPin', '0000', {type: 'string', write: true}); + await createStateAsync(dpPath + 'Access', 'false', {type: 'boolean', write: false}); + setObject(id, {_id: id, type: 'channel', common: {role: 'sensor.fire.alarm', name: 'sensor.fire.alarm'}, native: {}}); + await createAliasAsync(id + '.PIN', dpPath + 'UnlockPin', true, {type: 'string', role: 'state', name: 'PIN'}); + await createAliasAsync(id + '.ACTUAL', dpPath + 'Access', true, {type: 'boolean', role: 'sensor.fire.alarm', name: 'ACTUAL'}); } } } @@ -7776,13 +7805,14 @@ async function createAutoUnlockAlias(id: string, dpPath: string) { try { * @param {NSPanel.PageUnlock} page - The unlock page configuration. * @returns {NSPanel.Payload[]} The payload array for the unlock page. */ -function GenerateUnlockPage(page: NSPanel.PageUnlock): NSPanel.Payload[] { try { +function GenerateUnlockPage (page: NSPanel.PageUnlock): NSPanel.Payload[] { + try { activePage = page; let id = page.items[0].id; let name = page.heading; let out_msgs: NSPanel.Payload[] = []; - out_msgs.push({ payload: 'pageType~cardAlarm' }); + out_msgs.push({payload: 'pageType~cardAlarm'}); let dpPath: string = ''; let dpTempPath: any = NSPanel_Path.split('.'); @@ -7799,7 +7829,7 @@ function GenerateUnlockPage(page: NSPanel.PageUnlock): NSPanel.Payload[] { tr let unlock1 = findLocale('lock', 'UNLOCK'); //unlock1*~* let unlock1ActionName: NSPanel.ButtonActionType | '' = 'U1'; //unlock1ActionName*~* - let iconcolor = rgb_dec565({ red: 223, green: 76, blue: 30 }); //icon*~* + let iconcolor = rgb_dec565({red: 223, green: 76, blue: 30}); //icon*~* let icon = Icons.GetIcon('lock-remove'); //iconcolor*~* let numpadStatus = 'enable'; //numpadStatus*~* let flashing = 'disable'; //flashing* @@ -7854,7 +7884,8 @@ function GenerateUnlockPage(page: NSPanel.PageUnlock): NSPanel.Payload[] { tr * @returns {Promise} A promise that resolves when the alias has been created. * @throws {Error} If an error occurs during the alias creation. */ -async function createAutoQRAlias(id: string, dpPath: string) { try { +async function createAutoQRAlias (id: string, dpPath: string) { + try { if (Debug) { log('QRPage Alias Path: ' + id, 'info'); log('QRPage 0_userdata Path: ' + dpPath, 'info'); @@ -7862,11 +7893,11 @@ async function createAutoQRAlias(id: string, dpPath: string) { try { if (autoCreateAlias) { if (isSetOptionActive) { if (existsState(dpPath + 'Daten') == false) { - await createStateAsync(dpPath + 'Daten', 'WIFI:T:undefined;S:undefined;P:undefined;H:undefined;', { type: 'string', write: true }); - await createStateAsync(dpPath + 'Switch', false, { type: 'boolean', write: true }); - setObject(id, { _id: id, type: 'channel', common: { role: 'switch.mode.wlan', name: 'QR Page' }, native: {} }); - await createAliasAsync(id + '.ACTUAL', dpPath + 'Daten', true, { type: 'string', role: 'state', name: 'ACTUAL' }); - await createAliasAsync(id + '.SWITCH', dpPath + 'Switch', true, { type: 'boolean', role: 'state', name: 'SWITCH' }); + await createStateAsync(dpPath + 'Daten', 'WIFI:T:undefined;S:undefined;P:undefined;H:undefined;', {type: 'string', write: true}); + await createStateAsync(dpPath + 'Switch', false, {type: 'boolean', write: true}); + setObject(id, {_id: id, type: 'channel', common: {role: 'switch.mode.wlan', name: 'QR Page'}, native: {}}); + await createAliasAsync(id + '.ACTUAL', dpPath + 'Daten', true, {type: 'string', role: 'state', name: 'ACTUAL'}); + await createAliasAsync(id + '.SWITCH', dpPath + 'Switch', true, {type: 'boolean', role: 'state', name: 'SWITCH'}); log('Adjust data for the QR page under ' + dpPath + 'data. Follow the instructions in the wiki.', 'warn'); } } @@ -7885,12 +7916,13 @@ async function createAutoQRAlias(id: string, dpPath: string) { try { * @param {NSPanel.PageQR} page - The QR page configuration. * @returns {NSPanel.Payload[]} The payload array for the QR page. */ -function GenerateQRPage(page: NSPanel.PageQR): NSPanel.Payload[] { try { +function GenerateQRPage (page: NSPanel.PageQR): NSPanel.Payload[] { + try { activePage = page; if (!page.items[0].id) throw new Error('Missing pageItem.id for cardQRPage!'); let id = page.items[0].id; let out_msgs: NSPanel.Payload[] = []; - out_msgs.push({ payload: 'pageType~cardQR' }); + out_msgs.push({payload: 'pageType~cardQR'}); let dpPath: string = ''; let dpTempPath: any = NSPanel_Path.split('.'); @@ -8001,7 +8033,8 @@ function GenerateQRPage(page: NSPanel.PageQR): NSPanel.Payload[] { try { * * @function unsubscribePowerSubscriptions */ -function unsubscribePowerSubscriptions(): void { for (let i = 0; i < config.pages.length; i++) { +function unsubscribePowerSubscriptions (): void { + for (let i = 0; i < config.pages.length; i++) { const page: NSPanel.PageType = config.pages[i]; if (isPagePower(page)) { let powerID = page.items[0].id; @@ -8026,8 +8059,8 @@ function unsubscribePowerSubscriptions(): void { for (let i = 0; i < config.p * @param {string} id - The ID of the page for which the power state is to be subscribed to. * @returns {void} */ -function subscribePowerSubscriptions(id: string): void { - on({ id: id + '.ACTUAL', change: 'ne' }, async function () { +function subscribePowerSubscriptions (id: string): void { + on({id: id + '.ACTUAL', change: 'ne'}, async function () { (function () { if (timeoutPower) { clearTimeout(timeoutPower); @@ -8047,7 +8080,7 @@ function subscribePowerSubscriptions(id: string): void { * @param {NSPanel.PagePower} page - The page configuration with the power state and energy usage information. * @returns {NSPanel.Payload[]} An array of payloads to be sent to the panel. */ -function GeneratePowerPage(page: NSPanel.PagePower): NSPanel.Payload[] { +function GeneratePowerPage (page: NSPanel.PagePower): NSPanel.Payload[] { try { let obj: object = {}; let demoMode = false; @@ -8062,7 +8095,7 @@ function GeneratePowerPage(page: NSPanel.PagePower): NSPanel.Payload[] { } let heading = 'cardPower Example'; - if (!page.items[0].id || typeof page.items[0].id !== 'string') {throw Error ('Id ist empty or not a string')} + if (!page.items[0].id || typeof page.items[0].id !== 'string') {throw Error('Id ist empty or not a string')} if (demoMode != true) { let id = page.items[0].id; unsubscribePowerSubscriptions(); @@ -8077,13 +8110,13 @@ function GeneratePowerPage(page: NSPanel.PagePower): NSPanel.Payload[] { // Leave the display on if the alwaysOnDisplay parameter is specified (true) if (page.type == 'cardPower' && pageCounter == 0 && page.items[0].alwaysOnDisplay != undefined) { - out_msgs.push({ payload: 'pageType~cardPower' }); + out_msgs.push({payload: 'pageType~cardPower'}); if (page.items[0].alwaysOnDisplay != undefined) { if (page.items[0].alwaysOnDisplay) { pageCounter = 1; if (alwaysOn == false) { alwaysOn = true; - SendToPanel({ payload: 'timeout~0' }); + SendToPanel({payload: 'timeout~0'}); subscribePowerSubscriptions(page.items[0].id); } } @@ -8091,7 +8124,7 @@ function GeneratePowerPage(page: NSPanel.PagePower): NSPanel.Payload[] { } else if (page.type == 'cardPower' && pageCounter == 1) { subscribePowerSubscriptions(page.items[0].id); } else { - out_msgs.push({ payload: 'pageType~cardPower' }); + out_msgs.push({payload: 'pageType~cardPower'}); } if (Debug) { @@ -8200,13 +8233,13 @@ const timeValueRegEx = /\~\d+:(\d+)/g; * @param {NSPanel.PageChart} page - the page data * @returns {NSPanel.Payload[]} - an array of payloads */ -function GenerateChartPage(page: NSPanel.PageChart): NSPanel.Payload[] { +function GenerateChartPage (page: NSPanel.PageChart): NSPanel.Payload[] { try { activePage = page; let id = page.items[0].id; let out_msgs: NSPanel.Payload[] = []; - out_msgs.push({ payload: 'pageType~' + page.type }); + out_msgs.push({payload: 'pageType~' + page.type}); let heading = page.heading !== undefined ? page.heading : 'Chart...'; @@ -8280,7 +8313,8 @@ function GenerateChartPage(page: NSPanel.PageChart): NSPanel.Payload[] { * @param {boolean} [ack=false] - The acknowledgment flag (optional). * @returns {boolean} True if the state exists and the value was set, false otherwise. */ -function setIfExists(id: string, value: any, type: string | null = null, ack: boolean = false): boolean { try { +function setIfExists (id: string, value: any, type: string | null = null, ack: boolean = false): boolean { + try { if (type === null) { if (existsState(id)) { setState(id, value, ack); @@ -8308,7 +8342,8 @@ function setIfExists(id: string, value: any, type: string | null = null, ack: bo * @param {string} id - The ID of the entity to toggle. * @returns {boolean} True if the state was successfully toggled, false otherwise. */ -function toggleState(id: string): boolean { try { +function toggleState (id: string): boolean { + try { const obj = getObject(id); if (existsState(id) && obj.common.type !== undefined && obj.common.type === 'boolean') { setIfExists(id, !getState(id).val); @@ -8330,7 +8365,8 @@ function toggleState(id: string): boolean { try { * @param {string} id - The ID of the entity to trigger. * @returns {boolean} True if the button action was successfully triggered, false otherwise. */ -function triggerButton(id: string): boolean { try { +function triggerButton (id: string): boolean { + try { let obj = getObject(id); if (existsState(id) && obj.common.type !== undefined && obj.common.type === 'boolean') { setState(id, true); @@ -8354,7 +8390,8 @@ function triggerButton(id: string): boolean { try { * @function HandleButtonEvent * @param {any} words - The words or parameters associated with the button event. */ -function HandleButtonEvent(words: any): void { try { +function HandleButtonEvent (words: any): void { + try { // Turn off the display if the alwaysOnDisplay parameter was specified if (alwaysOn == true) { unsubscribePowerSubscriptions(); @@ -8393,12 +8430,12 @@ function HandleButtonEvent(words: any): void { try { buttonAction = words[2]; pageCounter = 0; alwaysOn = false; - SendToPanel({ payload: 'timeout~' + getState(NSPanel_Path + 'Config.Screensaver.timeoutScreensaver').val }); + SendToPanel({payload: 'timeout~' + getState(NSPanel_Path + 'Config.Screensaver.timeoutScreensaver').val}); } - setOrCreate(NSPanel_Path + 'Event.Button.Action', buttonAction ?? words[2], false, { name: 'Incoming button acion', type: 'string', role: 'text', write: false, read: true }); - setOrCreate(NSPanel_Path + 'Event.Button.Value', words[4] != undefined ? words[4] : '', false, { name: 'Incoming button value', type: 'string', role: 'text', write: false, read: true }); - setOrCreate(NSPanel_Path + 'Event.Button.Id', id, false, { name: 'Incoming button id', type: 'string', role: 'text', write: false, read: true }); + setOrCreate(NSPanel_Path + 'Event.Button.Action', buttonAction ?? words[2], false, {name: 'Incoming button acion', type: 'string', role: 'text', write: false, read: true}); + setOrCreate(NSPanel_Path + 'Event.Button.Value', words[4] != undefined ? words[4] : '', false, {name: 'Incoming button value', type: 'string', role: 'text', write: false, read: true}); + setOrCreate(NSPanel_Path + 'Event.Button.Id', id, false, {name: 'Incoming button id', type: 'string', role: 'text', write: false, read: true}); if (Debug) { log('HandleButtonEvent buttonAction: ' + buttonAction, 'info'); @@ -8562,11 +8599,11 @@ function HandleButtonEvent(words: any): void { try { break; case 'notifyAction': if (words[4] == 'yes') { - setState(popupNotifyInternalName, { val: words[2], ack: true }); - setState(popupNotifyAction, { val: true, ack: true }); + setState(popupNotifyInternalName, {val: words[2], ack: true}); + setState(popupNotifyAction, {val: true, ack: true}); } else if (words[4] == 'no') { - setState(popupNotifyInternalName, { val: words[2], ack: true }); - setState(popupNotifyAction, { val: false, ack: true }); + setState(popupNotifyInternalName, {val: words[2], ack: true}); + setState(popupNotifyAction, {val: false, ack: true}); } setIfExists(config.panelSendTopic, 'exitPopup'); @@ -8720,7 +8757,7 @@ function HandleButtonEvent(words: any): void { try { case 'volumio': let urlString: string = `${getState(adapterInstanceRepeat + 'info.host').val}/api/commands/?cmd=repeat`; axios - .get(urlString, { headers: { 'User-Agent': 'ioBroker' } }) + .get(urlString, {headers: {'User-Agent': 'ioBroker'}}) .then(async function (response) { if (response.status === 200) { if (Debug) { @@ -9109,7 +9146,7 @@ function HandleButtonEvent(words: any): void { try { let strDevicePL = pageItemPL.playList![words[4]]; let urlString: string = `${getState(adapterInstancePL + 'info.host').val}/api/commands/?cmd=playplaylist&name=${strDevicePL}`; axios - .get(urlString, { headers: { 'User-Agent': 'ioBroker' } }) + .get(urlString, {headers: {'User-Agent': 'ioBroker'}}) .then(async function (response) { if (response.status === 200) { if (Debug) { @@ -9166,7 +9203,7 @@ function HandleButtonEvent(words: any): void { try { case 'volumio': let urlString: string = `${getState(adapterInstanceTL + 'info.host').val}/api/commands/?cmd=play&N=${words[4]}`; axios - .get(urlString, { headers: { 'User-Agent': 'ioBroker' } }) + .get(urlString, {headers: {'User-Agent': 'ioBroker'}}) .then(async function (response) { if (response.status === 200) { if (Debug) { @@ -9541,9 +9578,10 @@ function HandleButtonEvent(words: any): void { try { * @param {Partial} [common={}] - The common properties for the state (optional). * @param {iobJS.SetStateCallback} [callback] - The callback function to execute after setting or creating the state (optional). */ -function setOrCreate(id: string, value: any, forceCreation: boolean = true, common: Partial = {}, callback?: iobJS.SetStateCallback) { if (!existsState(id)) { - extendObject(id.split('.').slice(0, -2).join('.'), { type: 'channel', common: { name: 'channel' }, native: {} }); - extendObject(id.split('.').slice(0, -1).join('.'), { type: 'channel', common: { name: 'channel' }, native: {} }); +function setOrCreate (id: string, value: any, forceCreation: boolean = true, common: Partial = {}, callback?: iobJS.SetStateCallback) { + if (!existsState(id)) { + extendObject(id.split('.').slice(0, -2).join('.'), {type: 'channel', common: {name: 'channel'}, native: {}}); + extendObject(id.split('.').slice(0, -1).join('.'), {type: 'channel', common: {name: 'channel'}, native: {}}); createState(id, value, forceCreation, common, callback); } else { setState(id, value, true); @@ -9560,7 +9598,7 @@ function setOrCreate(id: string, value: any, forceCreation: boolean = true, comm * @param {number} pageId - The ID of the page. * @returns {string} The navigation string for the specified page ID. */ -function getNavigationString(pageId: number): string { +function getNavigationString (pageId: number): string { try { if (Debug) { log('getNavigationString Übergabe pageId: ' + pageId, 'info'); @@ -9657,7 +9695,8 @@ function getNavigationString(pageId: number): string { * @param {number | undefined} placeId - The place ID associated with the detail page, if applicable. * @returns {NSPanel.Payload[]} The payload array for the detail page. */ -function GenerateDetailPage(type: NSPanel.PopupType, optional: NSPanel.mediaOptional | undefined, pageItem: PageItem, placeId: number | undefined): NSPanel.Payload[] { if (Debug) log('GenerateDetailPage Übergabe Type: ' + type + ' - optional: ' + optional + ' - pageItem.id: ' + pageItem.id, 'info'); +function GenerateDetailPage (type: NSPanel.PopupType, optional: NSPanel.mediaOptional | undefined, pageItem: PageItem, placeId: number | undefined): NSPanel.Payload[] { + if (Debug) log('GenerateDetailPage Übergabe Type: ' + type + ' - optional: ' + optional + ' - pageItem.id: ' + pageItem.id, 'info'); try { let out_msgs: NSPanel.Payload[] = []; let id = pageItem.id; @@ -9834,7 +9873,7 @@ function GenerateDetailPage(type: NSPanel.PopupType, optional: NSPanel.mediaOpti if (getState(id + '.HUE').val != null) { colorMode = 'enable'; let huecolor = hsv2rgb(getState(id + '.HUE').val, 1, 1); - let rgb: RGB = { red: Math.round(huecolor[0]), green: Math.round(huecolor[1]), blue: Math.round(huecolor[2]) }; + let rgb: RGB = {red: Math.round(huecolor[0]), green: Math.round(huecolor[1]), blue: Math.round(huecolor[2])}; iconColor = rgb_dec565(pageItem.interpolateColor !== undefined ? rgb : config.defaultOnColor); } } @@ -9917,7 +9956,7 @@ function GenerateDetailPage(type: NSPanel.PopupType, optional: NSPanel.mediaOpti if (existsState(id + '.RED') && existsState(id + '.GREEN') && existsState(id + '.BLUE')) { if (getState(id + '.RED').val != null && getState(id + '.GREEN').val != null && getState(id + '.BLUE').val != null) { colorMode = 'enable'; - let rgb: RGB = { red: Math.round(getState(id + '.RED').val), green: Math.round(getState(id + '.GREEN').val), blue: Math.round(getState(id + '.BLUE').val) }; + let rgb: RGB = {red: Math.round(getState(id + '.RED').val), green: Math.round(getState(id + '.GREEN').val), blue: Math.round(getState(id + '.BLUE').val)}; iconColor = rgb_dec565(pageItem.interpolateColor !== undefined ? rgb : config.defaultOnColor); } } @@ -10004,7 +10043,7 @@ function GenerateDetailPage(type: NSPanel.PopupType, optional: NSPanel.mediaOpti let hexRed = parseInt(hex[1] + hex[2], 16); let hexGreen = parseInt(hex[3] + hex[4], 16); let hexBlue = parseInt(hex[5] + hex[6], 16); - let rgb: RGB = { red: Math.round(hexRed), green: Math.round(hexGreen), blue: Math.round(hexBlue) }; + let rgb: RGB = {red: Math.round(hexRed), green: Math.round(hexGreen), blue: Math.round(hexBlue)}; iconColor = rgb_dec565(pageItem.interpolateColor !== undefined ? rgb : config.defaultOnColor); } } @@ -10673,8 +10712,8 @@ function GenerateDetailPage(type: NSPanel.PopupType, optional: NSPanel.mediaOpti existsObject(NSPanel_Path + 'Media.Player.' + lastIndex + '.EQ.activeMode') == false || existsObject(NSPanel_Path + 'Media.Player.' + lastIndex + '.Speaker') == false ) { - createState(NSPanel_Path + 'Media.Player.' + lastIndex + '.EQ.activeMode', { type: 'string', write: false }); - createState(NSPanel_Path + 'Media.Player.' + lastIndex + '.Speaker', { type: 'string', write: false }); + createState(NSPanel_Path + 'Media.Player.' + lastIndex + '.EQ.activeMode', {type: 'string', write: false}); + createState(NSPanel_Path + 'Media.Player.' + lastIndex + '.Speaker', {type: 'string', write: false}); } actualState = ''; @@ -10818,7 +10857,8 @@ function GenerateDetailPage(type: NSPanel.PopupType, optional: NSPanel.mediaOpti * @param {number} outMax - The maximum value of the output range. * @returns {number} The scaled number. */ -function scale(number: number, inMin: number, inMax: number, outMin: number, outMax: number): number { try { +function scale (number: number, inMin: number, inMax: number, outMin: number, outMax: number): number { + try { return outMax + outMin - (((number - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin); } catch (err: any) { log('error at function scale: ' + err.message, 'warn'); @@ -10833,7 +10873,8 @@ function scale(number: number, inMin: number, inMax: number, outMin: number, out * * @function UnsubscribeWatcher */ -function UnsubscribeWatcher(): void { try { +function UnsubscribeWatcher (): void { + try { for (const [key, value] of Object.entries(subscriptions)) { unsubscribe(value); delete subscriptions[key]; @@ -10850,15 +10891,16 @@ function UnsubscribeWatcher(): void { try { * * @function HandleScreensaver */ -function HandleScreensaver(): void { setIfExists(NSPanel_Path + 'ActivePage.type', 'screensaver', null, true); +function HandleScreensaver (): void { + setIfExists(NSPanel_Path + 'ActivePage.type', 'screensaver', null, true); setIfExists(NSPanel_Path + 'ActivePage.id0', 'screensaver', null, true); setIfExists(NSPanel_Path + 'ActivePage.heading', 'Screensaver', null, true); if (existsObject(`${NSPanel_Path}${ScreensaverAdvancedEndPath}`) && getState(`${NSPanel_Path}${ScreensaverAdvancedEndPath}`).val) { - SendToPanel({ payload: 'pageType~screensaver2' }); + SendToPanel({payload: 'pageType~screensaver2'}); } else if (existsObject(`${NSPanel_Path}${ScreensaverEasyViewEndPath}`) && getState(`${NSPanel_Path}${ScreensaverEasyViewEndPath}`).val) { - SendToPanel({ payload: 'pageType~screensaver3' }); - } else { - SendToPanel({ payload: 'pageType~screensaver' }); + SendToPanel({payload: 'pageType~screensaver3'}); + } else { + SendToPanel({payload: 'pageType~screensaver'}); } weatherForecast = getState(NSPanel_Path + 'ScreensaverInfo.weatherForecast').val; HandleScreensaverUpdate(); @@ -10873,7 +10915,7 @@ function HandleScreensaver(): void { setIfExists(NSPanel_Path + 'ActivePage.t * * @function HandleScreensaverUpdate */ -function HandleScreensaverUpdate(): void { +function HandleScreensaverUpdate (): void { try { if (screensaverEnabled) { UnsubscribeWatcher(); @@ -10915,7 +10957,7 @@ function HandleScreensaverUpdate(): void { if (screensaverAdvanced) { let checkpoint = true; let i = 0; - if (config.leftScreensaverEntity && Array.isArray(config.leftScreensaverEntity)) { + if (config.leftScreensaverEntity && Array.isArray(config.leftScreensaverEntity) && config.leftScreensaverEntity.length > 0) { for (i = 0; i < 3 && i < config.leftScreensaverEntity.length; i++) { const leftScreensaverEntity = config.leftScreensaverEntity[i]; if (leftScreensaverEntity === null || leftScreensaverEntity === undefined) { @@ -10969,7 +11011,12 @@ function HandleScreensaverUpdate(): void { payloadString += '~' + '~' + icon + '~' + iconColor + '~' + leftScreensaverEntity.ScreensaverEntityText + '~' + val + '~'; } + } + + if (i < 3) { + checkpoint = false; } + if (checkpoint == false) { for (let j = i; j < 3; j++) { payloadString += '~~~~~~'; @@ -10984,8 +11031,9 @@ function HandleScreensaverUpdate(): void { if (getState(NSPanel_Path + 'Config.Screensaver.alternativeScreensaverLayout').val) { maxEntities = 6; } else if (getState(NSPanel_Path + ScreensaverEasyViewEndPath).val) { - maxEntities = 4; - } + //us-p needs 5 Items - us-l and eu only 4 + maxEntities = 5; + } } if (weatherForecast) { @@ -11144,8 +11192,9 @@ function HandleScreensaverUpdate(): void { } if (typeof val == 'number') { - val = - (val * (config.bottomScreensaverEntity[i].ScreensaverEntityFactor ? config.bottomScreensaverEntity[i].ScreensaverEntityFactor! : 0)).toFixed( + val = val * (config.bottomScreensaverEntity[i].ScreensaverEntityFactor ? config.bottomScreensaverEntity[i].ScreensaverEntityFactor! : 0) + icon = determineScreensaverStatusIcon(config.bottomScreensaverEntity[i],val,icon) + val = val.toFixed( config.bottomScreensaverEntity[i].ScreensaverEntityDecimalPlaces ) + config.bottomScreensaverEntity[i].ScreensaverEntityUnitText; iconColor = GetScreenSaverEntityColor(config.bottomScreensaverEntity[i]); @@ -11234,7 +11283,7 @@ function HandleScreensaverUpdate(): void { } if (Debug) log('HandleScreensaverUpdate payload: weatherUpdate~' + payloadString, 'info'); - SendToPanel({ payload: 'weatherUpdate~' + payloadString }); + SendToPanel({payload: 'weatherUpdate~' + payloadString}); HandleScreensaverStatusIcons(); @@ -11253,12 +11302,13 @@ function HandleScreensaverUpdate(): void { * @function RegisterScreensaverEntityWatcher * @param {string} id - The ID of the screensaver entity to watch. */ -function RegisterScreensaverEntityWatcher(id: string): void { try { +function RegisterScreensaverEntityWatcher (id: string): void { + try { if (subscriptions.hasOwnProperty(id)) { return; } - subscriptions[id] = on({ id: id, change: 'any' }, () => { + subscriptions[id] = on({id: id, change: 'any'}, () => { HandleScreensaverUpdate(); }); } catch (err: any) { @@ -11273,7 +11323,8 @@ function RegisterScreensaverEntityWatcher(id: string): void { try { * * @function HandleScreensaverStatusIcons */ -function HandleScreensaverStatusIcons(): void { try { +function HandleScreensaverStatusIcons (): void { + try { let payloadString = ''; const iconData: Record<'mrIcon1' | 'mrIcon2', NSPanel.ScreenSaverMRDataElement> = { mrIcon1: { @@ -11409,7 +11460,7 @@ function HandleScreensaverStatusIcons(): void { try { payloadString += '~'; } // statusUpdate~icon1~icon1Color~icon1font~icon2~icon2color~icon2font~icon2font - SendToPanel({ payload: 'statusUpdate~' + payloadString }); + SendToPanel({payload: 'statusUpdate~' + payloadString}); } catch (err: any) { log('error at function HandleScreensaverStatusIcons: ' + err.message, 'warn'); } @@ -11424,7 +11475,8 @@ function HandleScreensaverStatusIcons(): void { try { * @param {string} valueScaletemp - The temperature value to convert. * @returns {number} The corresponding color scale value. */ -function HandleColorScale(valueScaletemp: string): number { switch (valueScaletemp) { +function HandleColorScale (valueScaletemp: string): number { + switch (valueScaletemp) { case '0': return rgb_dec565(colorScale0); case '1': @@ -11459,7 +11511,8 @@ function HandleColorScale(valueScaletemp: string): number { switch (valueScal * * @function HandleScreensaverColors */ -function HandleScreensaverColors(): void { try { +function HandleScreensaverColors (): void { + try { let vwIcon: number[] = []; if (getState(NSPanel_Path + 'Config.Screensaver.autoWeatherColorScreensaverLayout').val) { vwIcon[0] = vwIconColor[0]; @@ -11494,9 +11547,9 @@ function HandleScreensaverColors(): void { try { } else if (bgColorScrSaver == 3) { scrSvrBGCol = rgb_dec565(scbackgroundInd3); } else if (bgColorScrSaver == 4) { - scrSvrBGCol = rgb_dec565({ red: 255, green: 16, blue: 240 }); + scrSvrBGCol = rgb_dec565({red: 255, green: 16, blue: 240}); } else if (bgColorScrSaver == 5) { - scrSvrBGCol = rgb_dec565({ red: 100, green: 0, blue: 0 }); + scrSvrBGCol = rgb_dec565({red: 100, green: 0, blue: 0}); } let payloadString = buildNSPanelString( @@ -11519,7 +11572,7 @@ function HandleScreensaverColors(): void { try { rgb_dec565(sctTimeAdd) //tTimeAdd ); - SendToPanel({ payload: payloadString }); + SendToPanel({payload: payloadString}); } catch (err: any) { log('error at function HandleScreensaverColors: ' + err.message, 'warn'); } @@ -11534,7 +11587,8 @@ function HandleScreensaverColors(): void { try { * @param {NSPanel.ScreenSaverElement | null} configElement - The configuration element for the screensaver entity. * @returns {number} The color code for the screensaver entity. */ -function GetScreenSaverEntityColor(configElement: NSPanel.ScreenSaverElement | null): number { try { +function GetScreenSaverEntityColor (configElement: NSPanel.ScreenSaverElement | null): number { + try { let colorReturn: number; if (configElement && configElement.ScreensaverEntityIconColor != undefined) { const ScreensaverEntityIconColor = configElement.ScreensaverEntityIconColor as NSPanel.IconScaleElement; @@ -11610,7 +11664,8 @@ function GetScreenSaverEntityColor(configElement: NSPanel.ScreenSaverElement | n * @param {number} icon - The AccuWeather icon number. * @returns {string} The corresponding icon string. */ -function GetAccuWeatherIcon(icon: number): string { try { +function GetAccuWeatherIcon (icon: number): string { + try { switch (icon) { case 30: // Hot return 'weather-sunny-alert'; // exceptional @@ -11700,7 +11755,8 @@ function GetAccuWeatherIcon(icon: number): string { try { * @param {number} icon - The AccuWeather icon number. * @returns {number} The corresponding color code. */ -function GetAccuWeatherIconColor(icon: number): number { try { +function GetAccuWeatherIconColor (icon: number): number { + try { switch (icon) { case 24: // Ice case 30: // Hot @@ -11788,7 +11844,8 @@ function GetAccuWeatherIconColor(icon: number): number { try { * @param {number} icon - The DasWetter icon number. * @returns {string} The corresponding icon string. */ -function GetDasWetterIcon(icon: number): string { try { +function GetDasWetterIcon (icon: number): string { + try { switch (icon) { case 1: // Sonnig return 'weather-sunny'; // sunny @@ -11856,7 +11913,8 @@ function GetDasWetterIcon(icon: number): string { try { * @param {number} icon - The DasWetter icon number. * @returns {number} The corresponding color code. */ -function GetDasWetterIconColor(icon: number): number { try { +function GetDasWetterIconColor (icon: number): number { + try { switch (icon) { case 1: // Sonnig return rgb_dec565(swSunny); @@ -11927,34 +11985,35 @@ function GetDasWetterIconColor(icon: number): number { try { * @param {Object} obj - The object containing the state change information. * @throws {Error} If an error occurs during the state change handling. */ -on({ id: config.panelRecvTopic.substring(0, config.panelRecvTopic.length - 'RESULT'.length) + 'SENSOR' }, async (obj) => { try { +on({id: config.panelRecvTopic.substring(0, config.panelRecvTopic.length - 'RESULT'.length) + 'SENSOR'}, async (obj) => { + try { const Tasmota_Sensor = JSON.parse(obj.state.val); - await createStateAsync(NSPanel_Path + 'Sensor.Time', { type: 'string', write: false }); - await createStateAsync(NSPanel_Path + 'Sensor.TempUnit', { type: 'string', write: false }); - await createStateAsync(NSPanel_Path + 'Sensor.ANALOG.Temperature', { type: 'number', unit: '°C', write: false }); - await createStateAsync(NSPanel_Path + 'Sensor.ESP32.Temperature', { type: 'number', unit: '°C', write: false }); + await createStateAsync(NSPanel_Path + 'Sensor.Time', {type: 'string', write: false}); + await createStateAsync(NSPanel_Path + 'Sensor.TempUnit', {type: 'string', write: false}); + await createStateAsync(NSPanel_Path + 'Sensor.ANALOG.Temperature', {type: 'number', unit: '°C', write: false}); + await createStateAsync(NSPanel_Path + 'Sensor.ESP32.Temperature', {type: 'number', unit: '°C', write: false}); let dateTime: string = Tasmota_Sensor.Time.split('T'); - await setStateAsync(NSPanel_Path + 'Sensor.Time', { val: dateTime[0] + '\r\n' + dateTime[1], ack: true }); - await setStateAsync(NSPanel_Path + 'Sensor.TempUnit', { val: '°' + Tasmota_Sensor.TempUnit, ack: true }); + await setStateAsync(NSPanel_Path + 'Sensor.Time', {val: dateTime[0] + '\r\n' + dateTime[1], ack: true}); + await setStateAsync(NSPanel_Path + 'Sensor.TempUnit', {val: '°' + Tasmota_Sensor.TempUnit, ack: true}); /* Some messages do not include temperature values, so catch ecxeption for them separately */ try { - await setStateAsync(NSPanel_Path + 'Sensor.ANALOG.Temperature', { val: parseFloat(Tasmota_Sensor.ANALOG.Temperature1), ack: true }); - await setStateAsync(NSPanel_Path + 'Sensor.ESP32.Temperature', { val: parseFloat(Tasmota_Sensor.ESP32.Temperature), ack: true }); + await setStateAsync(NSPanel_Path + 'Sensor.ANALOG.Temperature', {val: parseFloat(Tasmota_Sensor.ANALOG.Temperature1), ack: true}); + await setStateAsync(NSPanel_Path + 'Sensor.ESP32.Temperature', {val: parseFloat(Tasmota_Sensor.ESP32.Temperature), ack: true}); } catch (e) { /* Nothing to do */ } if (autoCreateAlias) { - setObject(AliasPath + 'Sensor.ANALOG.Temperature', { type: 'channel', common: { role: 'info', name: '' }, native: {} }); - setObject(AliasPath + 'Sensor.ESP32.Temperature', { type: 'channel', common: { role: 'info', name: '' }, native: {} }); - setObject(AliasPath + 'Sensor.Time', { type: 'channel', common: { role: 'info', name: '' }, native: {} }); - setObject(AliasPath + 'Sensor.TempUnit', { type: 'channel', common: { role: 'info', name: '' }, native: {} }); - await createAliasAsync(AliasPath + 'Sensor.ANALOG.Temperature.ACTUAL', NSPanel_Path + 'Sensor.ANALOG.Temperature', true, { type: 'number', unit: '°C' }); - await createAliasAsync(AliasPath + 'Sensor.ESP32.Temperature.ACTUAL', NSPanel_Path + 'Sensor.ESP32.Temperature', true, { type: 'number', unit: '°C' }); - await createAliasAsync(AliasPath + 'Sensor.Time.ACTUAL', NSPanel_Path + 'Sensor.Time', true, { type: 'string' }); - await createAliasAsync(AliasPath + 'Sensor.TempUnit.ACTUAL', NSPanel_Path + 'Sensor.TempUnit', true, { type: 'string' }); + setObject(AliasPath + 'Sensor.ANALOG.Temperature', {type: 'channel', common: {role: 'info', name: ''}, native: {}}); + setObject(AliasPath + 'Sensor.ESP32.Temperature', {type: 'channel', common: {role: 'info', name: ''}, native: {}}); + setObject(AliasPath + 'Sensor.Time', {type: 'channel', common: {role: 'info', name: ''}, native: {}}); + setObject(AliasPath + 'Sensor.TempUnit', {type: 'channel', common: {role: 'info', name: ''}, native: {}}); + await createAliasAsync(AliasPath + 'Sensor.ANALOG.Temperature.ACTUAL', NSPanel_Path + 'Sensor.ANALOG.Temperature', true, {type: 'number', unit: '°C'}); + await createAliasAsync(AliasPath + 'Sensor.ESP32.Temperature.ACTUAL', NSPanel_Path + 'Sensor.ESP32.Temperature', true, {type: 'number', unit: '°C'}); + await createAliasAsync(AliasPath + 'Sensor.Time.ACTUAL', NSPanel_Path + 'Sensor.Time', true, {type: 'string'}); + await createAliasAsync(AliasPath + 'Sensor.TempUnit.ACTUAL', NSPanel_Path + 'Sensor.TempUnit', true, {type: 'string'}); } } catch (err: any) { log('error Trigger reading senor-data: ' + err.message, 'warn'); @@ -11971,7 +12030,8 @@ on({ id: config.panelRecvTopic.substring(0, config.panelRecvTopic.length - 'RESU * @param {string} Text - The input text to format. * @returns {string} The formatted text. */ -function formatInSelText(Text: string): string { let splitText = Text.split(' '); +function formatInSelText (Text: string): string { + let splitText = Text.split(' '); let lengthLineOne = 0; let arrayLineOne: string[] = []; for (let i = 0; i < splitText.length; i++) { @@ -12007,7 +12067,8 @@ function formatInSelText(Text: string): string { let splitText = Text.split(' * @param {number} percentage - The percentage to determine the blended color. * @returns {RGB} The blended color as an RGB object. */ -function GetBlendedColor(percentage: number): RGB { if (percentage < 50) { +function GetBlendedColor (percentage: number): RGB { + if (percentage < 50) { return Interpolate(config.defaultOffColor, config.defaultOnColor, percentage / 50.0); } @@ -12025,10 +12086,11 @@ function GetBlendedColor(percentage: number): RGB { if (percentage < 50) { * @param {number} fraction - The fraction to determine the interpolation (0.0 to 1.0). * @returns {RGB} The interpolated RGB color. */ -function Interpolate(color1: RGB, color2: RGB, fraction: number): RGB { let r: number = InterpolateNum(color1.red, color2.red, fraction); +function Interpolate (color1: RGB, color2: RGB, fraction: number): RGB { + let r: number = InterpolateNum(color1.red, color2.red, fraction); let g: number = InterpolateNum(color1.green, color2.green, fraction); let b: number = InterpolateNum(color1.blue, color2.blue, fraction); - return { red: Math.round(r), green: Math.round(g), blue: Math.round(b) }; + return {red: Math.round(r), green: Math.round(g), blue: Math.round(b)}; } /** @@ -12042,7 +12104,8 @@ function Interpolate(color1: RGB, color2: RGB, fraction: number): RGB { let r * @param {number} fraction - The fraction to determine the interpolation (0.0 to 1.0). * @returns {number} The interpolated value. */ -function InterpolateNum(d1: number, d2: number, fraction: number): number { return d1 + (d2 - d1) * fraction; +function InterpolateNum (d1: number, d2: number, fraction: number): number { + return d1 + (d2 - d1) * fraction; } /** @@ -12054,7 +12117,7 @@ function InterpolateNum(d1: number, d2: number, fraction: number): number { r * @param {RGB} rgb - The RGB color object. * @returns {number} The 16-bit 565 color value. */ -function rgb_dec565(rgb: RGB): number { //return ((Math.floor(rgb.red / 255 * 31) << 11) | (Math.floor(rgb.green / 255 * 63) << 5) | (Math.floor(rgb.blue / 255 * 31))); +function rgb_dec565 (rgb: RGB): number { //return ((Math.floor(rgb.red / 255 * 31) << 11) | (Math.floor(rgb.green / 255 * 63) << 5) | (Math.floor(rgb.blue / 255 * 31))); return ((rgb.red >> 3) << 11) | ((rgb.green >> 2) << 5) | (rgb.blue >> 3); } @@ -12063,7 +12126,7 @@ function rgb_dec565(rgb: RGB): number { //return ((Math.floor(rgb.red / 255 * * @param rad radians to convert, expects rad in range +/- PI per Math.atan2 * @returns {number} degrees equivalent of rad */ -function rad2deg(rad): number { +function rad2deg (rad): number { return (360 + (180 * rad) / Math.PI) % 360; } @@ -12076,7 +12139,8 @@ function rad2deg(rad): number { * @param {number} color - The color value to convert. * @returns {string} The hexadecimal string representation of the color. */ -function ColorToHex(color): string { let hexadecimal: string = color.toString(16); +function ColorToHex (color): string { + let hexadecimal: string = color.toString(16); return hexadecimal.length == 1 ? '0' + hexadecimal : hexadecimal; } @@ -12091,7 +12155,8 @@ function ColorToHex(color): string { let hexadecimal: string = color.toString * @param {number} blue - The blue color value. * @returns {string} The hexadecimal string representation of the RGB color. */ -function ConvertRGBtoHex(red: number, green: number, blue: number): string { return '#' + ColorToHex(red) + ColorToHex(green) + ColorToHex(blue); +function ConvertRGBtoHex (red: number, green: number, blue: number): string { + return '#' + ColorToHex(red) + ColorToHex(green) + ColorToHex(blue); } /** @@ -12101,7 +12166,7 @@ function ConvertRGBtoHex(red: number, green: number, blue: number): string { * @param value in range 0 to 1 * @returns {[number, number, number]} [r, g,b] in range 0 to 255 */ -function hsv2rgb(hue: number, saturation: number, value: number): [number, number, number] { +function hsv2rgb (hue: number, saturation: number, value: number): [number, number, number] { hue /= 60; let chroma = value * saturation; let x = chroma * (1 - Math.abs((hue % 2) - 1)); @@ -12121,7 +12186,8 @@ function hsv2rgb(hue: number, saturation: number, value: number): [number, numbe * @param {number} blue - The blue color value. * @returns {number} The hue value. */ -function getHue(red: number, green: number, blue: number): number { let min = Math.min(Math.min(red, green), blue); +function getHue (red: number, green: number, blue: number): number { + let min = Math.min(Math.min(red, green), blue); let max = Math.max(Math.max(red, green), blue); if (min == max) { @@ -12154,7 +12220,7 @@ function getHue(red: number, green: number, blue: number): number { let min = * @param {number} y - The y-coordinate of the position. * @returns {RGB} The RGB color corresponding to the position. */ -function pos_to_color(x: number, y: number): RGB { +function pos_to_color (x: number, y: number): RGB { let r = 160 / 2; x = Math.round(((x - r) / r) * 100) / 100; y = Math.round(((r - y) / r) * 100) / 100; @@ -12170,7 +12236,7 @@ function pos_to_color(x: number, y: number): RGB { let hsv = rad2deg(Math.atan2(y, x)); let rgb = hsv2rgb(hsv, sat, 1); - return { red: Math.round(rgb[0]), green: Math.round(rgb[1]), blue: Math.round(rgb[2]) }; + return {red: Math.round(rgb[0]), green: Math.round(rgb[1]), blue: Math.round(rgb[2])}; } @@ -12185,7 +12251,7 @@ function pos_to_color(x: number, y: number): RGB { * @param {number} blue - The blue color value. * @returns {string} The CIE 1931 color space coordinates as a string. */ -function rgb_to_cie(red: number, green: number, blue: number): string { +function rgb_to_cie (red: number, green: number, blue: number): string { // Apply a gamma correction to the RGB values, which makes the color more vivid and more the like the color displayed on the screen of your device let vred = red > 0.04045 ? Math.pow((red + 0.055) / (1.0 + 0.055), 2.4) : red / 12.92; let vgreen = green > 0.04045 ? Math.pow((green + 0.055) / (1.0 + 0.055), 2.4) : green / 12.92; @@ -12204,6 +12270,102 @@ function rgb_to_cie(red: number, green: number, blue: number): string { return cie; } +/** + * Determines the icon ID for a given page item based on the provided value thresholds. + * If the icon3 property is missing or invalid, it immediately returns the fallback icon ID. + * Otherwise, it delegates to determineStatusIcon, passing the relevant parameters. + * + * @param {PageItem} pageItem - Contains icon references (icon, icon2, icon3) and threshold values. + * @param {number} val - The current value used to evaluate thresholds. + * @param {string} iconId - The fallback icon ID if no matching icon is found. + * @param {[string, string, string]} [def] - Optional array of default icons corresponding to threshold levels. [low, high, between] + * @returns {string} The icon ID determined by value, thresholds, and defaults. + */ +function determinePageItemStatusIcon (pageItem: PageItem, val: number, iconId: string, def?: [string, string, string]): string { + if (!pageItem.icon3 || typeof pageItem.icon3 !== 'string') { + return iconId; + } + const max = pageItem.maxValueLevel ?? pageItem.maxValue ?? 100; + const min = pageItem.minValueLevel ?? pageItem.minValue ?? 0; + return determineStatusIcon(pageItem.icon, pageItem.icon2, pageItem.icon3, val, min, max, iconId, def); +} + +/** + * Determines an icon for the screensaver based on the provided value and icon configuration. + * + * @param {NSPanel.ScreenSaverElement} ss - Object containing the ScreensaverEntityIconSelect array. + * @param {number} val - The current value used to determine which icon to select. + * @param {string} iconId - A fallback icon ID if no suitable icon can be retrieved. + * @returns {string} The icon ID that matches the value thresholds, or the fallback icon ID. + */ +function determineScreensaverStatusIcon(ss: NSPanel.ScreenSaverElement, val: number, iconId: string): string { + if (!ss) { + return iconId; + } + if (!ss.ScreensaverEntityIconSelect || !Array.isArray(ss.ScreensaverEntityIconSelect)) { + return iconId; + } + ss.ScreensaverEntityIconSelect = ss.ScreensaverEntityIconSelect.filter((item) => item); + ss.ScreensaverEntityIconSelect = ss.ScreensaverEntityIconSelect.sort((a, b) => a.value - b.value); + for (const item of ss.ScreensaverEntityIconSelect) { + if (val <= item.value) { + return Icons.GetIcon(item.icon) || iconId; + } + } + return Icons.GetIcon(ss.ScreensaverEntityIconSelect[ss.ScreensaverEntityIconSelect.length - 1].icon) || iconId; +} + +/** + * Determines which icon to use based on the given value range (min and max) and available icon references. + * + * @param {string | undefined} icon1 - The icon reference for the lower threshold condition. + * @param {string | undefined} icon2 - The icon reference for the higher threshold condition. + * @param {string | undefined} icon3 - The icon reference for the midrange condition. + * @param {number} val - The current value to evaluate. + * @param {number | undefined} min - The minimum threshold. + * @param {number | undefined} max - The maximum threshold. + * @param {string} iconId - The fallback icon identifier. + * @param {[string, string, string]} [def] - Optional array of default icons for each threshold level. + * + * @returns {string} The icon identifier determined by the value, thresholds, and defaults. + */ +function determineStatusIcon ( + icon1: string|undefined, + icon2: string|undefined, + icon3: string|undefined, + val: number, + min: number|undefined, + max: number|undefined, + iconId: string, + def?: [string, string, string] +): string { + if (!icon3 && typeof icon3 !== 'string') { + return iconId; + } + if (min === undefined || max === undefined) { + return iconId; + } + function pickIcon(iconKey?: string, defIndex?: number): string { + return ( + (iconKey && existsState(iconKey) && Icons.GetIcon(getState(iconKey).val)) || + Icons.GetIcon(iconKey) || + (def && defIndex !== undefined ? Icons.GetIcon(def[defIndex]) : undefined) || + iconId + ); + } + + if ((min > max && val >= min) || (min <= max && val <= min)) { + iconId = pickIcon(icon1, 0); + } else if ((min > max && val <= max) || (min <= max && val >= max)) { + iconId = pickIcon(icon2, 1); + } else { + // The original code used the entire def array for icon3; here we assume the third index + iconId = pickIcon(icon3, 2); + } + + return iconId; +} + /** * Retrieves the Spotify device ID for a given device name. @@ -12214,7 +12376,7 @@ function rgb_to_cie(red: number, green: number, blue: number): string { * @param {string} vDeviceString - The name of the Spotify device. * @returns {string} The ID of the Spotify device. */ -function spotifyGetDeviceID(vDeviceString: string): string { +function spotifyGetDeviceID (vDeviceString: string): string { const availableDeviceIDs: string = getState('spotify-premium.0.devices.availableDeviceListIds').val; const availableDeviceNames: string = getState('spotify-premium.0.devices.availableDeviceListString').val; let arrayDeviceListIds: string[] = availableDeviceIDs.split(';'); @@ -12228,7 +12390,7 @@ function spotifyGetDeviceID(vDeviceString: string): string { * @param tokens unlimited numbers of strings * @returns */ -function buildNSPanelString(...tokens: (string | number)[]): string { +function buildNSPanelString (...tokens: (string | number)[]): string { return tokens.join('~'); } @@ -12254,7 +12416,7 @@ type PageAlarm = NSPanel.PageAlarm; * @param callback what todo * @returns */ -function adapterSchedule(time: { hour?: number; minute?: number } | undefined | number, repeatTime: number, callback: () => void): number | null { +function adapterSchedule (time: {hour?: number; minute?: number} | undefined | number, repeatTime: number, callback: () => void): number | null { if (typeof callback !== 'function') return null; const ref = Math.random() + 1; (scheduleList[ref] = setTimeout(_schedule, 1, time, ref, repeatTime, callback)), true; @@ -12273,7 +12435,7 @@ function adapterSchedule(time: { hour?: number; minute?: number } | undefined | * @param {Function} callback - The callback function to execute. * @param {boolean} [init=false] - Whether to initialize the task immediately. */ -function _schedule(time: { hour?: number; minute?: number } | undefined | number, ref: number, repeatTime: number, callback, init: boolean = false) { +function _schedule (time: {hour?: number; minute?: number} | undefined | number, ref: number, repeatTime: number, callback, init: boolean = false) { if (!scheduleList[ref]) return; if (!init) callback(); let targetTime: number; @@ -12304,7 +12466,7 @@ function _schedule(time: { hour?: number; minute?: number } | undefined | number * @param {number} ref - The reference ID of the scheduled task to clear. * @returns {null} Returns null after clearing the scheduled task. */ -function _clearSchedule(ref: number): null { +function _clearSchedule (ref: number): null { if (scheduleList[ref]) clearTimeout(scheduleList[ref]); delete scheduleList[ref]; return null; @@ -12321,11 +12483,11 @@ const ArrayPlayerTypeWithOutMediaDevice = ['spotify-premium', 'volumio', 'boseso * @param {string | NSPanel._PlayerTypeWithMediaDevice} F - The player type to check. * @returns {boolean} True if the player type is a player with a media device, false otherwise. */ -function isPlayerWithMediaDevice(F: string | NSPanel._PlayerTypeWithMediaDevice): F is NSPanel._PlayerTypeWithMediaDevice { +function isPlayerWithMediaDevice (F: string | NSPanel._PlayerTypeWithMediaDevice): F is NSPanel._PlayerTypeWithMediaDevice { return ArrayPlayerTypeWithMediaDevice.indexOf(F as NSPanel._PlayerTypeWithMediaDevice) != -1; } /** check if NSPanel.adapterPlayerInstanceType has all Playertypes */ -function checkSortedPlayerType(F: NSPanel.notSortedPlayerType) { +function checkSortedPlayerType (F: NSPanel.notSortedPlayerType) { const test: NSPanel.adapterPlayerInstanceType = F; } @@ -12338,7 +12500,7 @@ function checkSortedPlayerType(F: NSPanel.notSortedPlayerType) { * @param {string | NSPanel.mediaOptional} F - The string to check. * @returns {boolean} True if the string is a valid media optional type, false otherwise. */ -function isMediaOptional(F: string | NSPanel.mediaOptional): F is NSPanel.mediaOptional { +function isMediaOptional (F: string | NSPanel.mediaOptional): F is NSPanel.mediaOptional { switch (F as NSPanel.mediaOptional) { case 'seek': case 'crossfade': @@ -12364,7 +12526,7 @@ function isMediaOptional(F: string | NSPanel.mediaOptional): F is NSPanel.mediaO * @param {string | NSPanel.EventMethod} F - The string to check. * @returns {boolean} True if the string is a valid event method, false otherwise. */ -function isEventMethod(F: string | NSPanel.EventMethod): F is NSPanel.EventMethod { +function isEventMethod (F: string | NSPanel.EventMethod): F is NSPanel.EventMethod { switch (F as NSPanel.EventMethod) { case 'startup': case 'sleepReached': @@ -12391,7 +12553,7 @@ function isEventMethod(F: string | NSPanel.EventMethod): F is NSPanel.EventMetho * @param {NSPanel.PopupType | string} F - The string to check. * @returns {boolean} True if the string is a valid popup type, false otherwise. */ -function isPopupType(F: NSPanel.PopupType | string): F is NSPanel.PopupType { +function isPopupType (F: NSPanel.PopupType | string): F is NSPanel.PopupType { switch (F as NSPanel.PopupType) { case 'popupFan': case 'popupInSel': @@ -12408,21 +12570,21 @@ function isPopupType(F: NSPanel.PopupType | string): F is NSPanel.PopupType { } } // If u get a error here u forgot something in PagetypeType or PageType -function checkPageType(F: NSPanel.PagetypeType, A: NSPanel.PageType) { +function checkPageType (F: NSPanel.PagetypeType, A: NSPanel.PageType) { A.type = F; } -function isPageMediaItem(F: NSPanel.PageItem | NSPanel.PageMediaItem): F is NSPanel.PageMediaItem { +function isPageMediaItem (F: NSPanel.PageItem | NSPanel.PageMediaItem): F is NSPanel.PageMediaItem { return 'adapterPlayerInstance' in F; } -function isPageThermoItem(F: PageItem | NSPanel.PageThermoItem): F is NSPanel.PageThermoItem { +function isPageThermoItem (F: PageItem | NSPanel.PageThermoItem): F is NSPanel.PageThermoItem { return 'popupThermoMode1' in F; } -function isPageMedia(F: NSPanel.PageType | NSPanel.PageMedia): F is NSPanel.PageMedia { +function isPageMedia (F: NSPanel.PageType | NSPanel.PageMedia): F is NSPanel.PageMedia { return F.type == 'cardMedia'; } -function isPagePower(F: NSPanel.PageType | NSPanel.PagePower): F is NSPanel.PagePower { +function isPagePower (F: NSPanel.PageType | NSPanel.PagePower): F is NSPanel.PagePower { return F.type == 'cardPower'; } @@ -12437,15 +12599,15 @@ namespace NSPanel { export type SerialType = 'button' | 'light' | 'shutter' | 'text' | 'input_sel' | 'timer' | 'number' | 'fan'; - /** - * Defines the possible roles for entities in the NSPanel. - * - * This type represents the various roles that entities can have within the NSPanel system. - * - * @typedef {string} roles - * @enum {string} - */ - export type roles = | 'light' + /** + * Defines the possible roles for entities in the NSPanel. + * + * This type represents the various roles that entities can have within the NSPanel system. + * + * @typedef {string} roles + * @enum {string} + */ + export type roles = | 'light' | 'socket' | 'dimmer' | 'hue' @@ -12653,21 +12815,21 @@ namespace NSPanel { export type PageThermoItem = | ({ - popupThermoMode1?: string[]; - popupThermoMode2?: string[]; - popupThermoMode3?: string[]; - popUpThermoName?: string[]; - setThermoAlias?: string[]; - setThermoDestTemp2?: string; - } & PageBaseItem) + popupThermoMode1?: string[]; + popupThermoMode2?: string[]; + popupThermoMode3?: string[]; + popUpThermoName?: string[]; + setThermoAlias?: string[]; + setThermoDestTemp2?: string; + } & PageBaseItem) | ({ - popupThermoMode1?: string[]; - popupThermoMode2?: string[]; - popupThermoMode3?: string[]; - popUpThermoName?: string[]; - setThermoAlias?: string[]; - setThermoDestTemp2?: string; - } & PageBaseItem); + popupThermoMode1?: string[]; + popupThermoMode2?: string[]; + popupThermoMode3?: string[]; + popUpThermoName?: string[]; + setThermoAlias?: string[]; + setThermoDestTemp2?: string; + } & PageBaseItem); // mean string start with getState(' and end with ').val type getStateID = string; export type PageBaseItem = { @@ -12755,8 +12917,8 @@ namespace NSPanel { page: PageThermo | PageMedia | PageAlarm | PageQR | PageEntities | PageGrid | PageGrid2 | PagePower | PageChart | PageUnlock | null; entity: string | null; setValue: string | number | boolean | null; - setOn?: { dp: string; val: iobJS.StateValue }; - setOff?: { dp: string; val: iobJS.StateValue }; + setOn?: {dp: string; val: iobJS.StateValue}; + setOff?: {dp: string; val: iobJS.StateValue}; }; export type Config = { @@ -12777,7 +12939,7 @@ namespace NSPanel { button1: ConfigButtonFunction; button2: ConfigButtonFunction; }; - export type leftScreensaverEntityType = [ScreenSaverElementWithUndefined, ScreenSaverElementWithUndefined, ScreenSaverElementWithUndefined] | []; + export type leftScreensaverEntityType = [ScreenSaverElementWithUndefined?, ScreenSaverElementWithUndefined?, ScreenSaverElementWithUndefined?] | []; export type indicatorScreensaverEntityType = | [ScreenSaverElementWithUndefined?, ScreenSaverElementWithUndefined?, ScreenSaverElementWithUndefined?, ScreenSaverElementWithUndefined?, ScreenSaverElementWithUndefined?] | []; @@ -12785,9 +12947,9 @@ namespace NSPanel { export type ScreenSaverElement = { ScreensaverEntity: string; ScreensaverEntityText: string; - /** - * Value wird mit diesem Factor multipliziert. - */ + /** + * Value wird mit diesem Factor multipliziert. + */ ScreensaverEntityFactor?: number; ScreensaverEntityDecimalPlaces?: number; ScreensaverEntityDateFormat?: Intl.DateTimeFormatOptions; @@ -12800,12 +12962,29 @@ namespace NSPanel { ScreensaverEntityOnText?: string | null; ScreensaverEntityOffText?: string | null; ScreensaverEntityNaviToPage?: PageType; + /** + * To show different icons for different values in the screensaver + * + * Value is the threshold for the icon. Lower values are first. + * Example: + * [ + {icon: 'sun-thermometer', value:40}, + {icon: 'sun-thermometer-outline', value: 35}, + {icon: 'thermometer-high', value: 30}, + {icon: 'thermometer', value: 25}, + {icon: 'thermometer-low', value: 15}, + {icon: 'snowflake-alert', value: 2}, + {icon: 'snowflake-thermometer', value: -2}, + {icon: 'snowflake', value: -10}, + ] + */ + ScreensaverEntityIconSelect?: {icon:string, value: number}[] | null; }; export type ScreenSaverMRElement = { ScreensaverEntity: string | null; ScreensaverEntityIconOn: string | null; - ScreensaverEntityIconSelect?: { [key: string]: string } | null | undefined; + ScreensaverEntityIconSelect?: {[key: string]: string} | null | undefined; ScreensaverEntityIconOff: string | null; ScreensaverEntityValue: string | null; ScreensaverEntityValueDecimalPlace: number | null; @@ -12822,7 +13001,7 @@ namespace NSPanel { ScreensaverEntityValueUnit: string | null; ScreensaverEntityOnColor: RGB; ScreensaverEntityOffColor: RGB; - ScreensaverEntityIconSelect: { [key: string]: string } | null; + ScreensaverEntityIconSelect: {[key: string]: string} | null; }; export type IconScaleElement = {