diff --git a/ioBroker/DEV/NSPanelTs.ts b/ioBroker/DEV/NSPanelTs.ts index f9e4908f..b812a4a4 100644 --- a/ioBroker/DEV/NSPanelTs.ts +++ b/ioBroker/DEV/NSPanelTs.ts @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------- -TypeScript v4.3.3.40 zur Steuerung des SONOFF NSPanel mit dem ioBroker by @Armilar / @TT-Tom / @ticaki / @Britzelpuf / @Sternmiere / @ravenS0ne +TypeScript v4.3.3.41 zur Steuerung des SONOFF NSPanel mit dem ioBroker by @Armilar / @TT-Tom / @ticaki / @Britzelpuf / @Sternmiere / @ravenS0ne - abgestimmt auf TFT 53 / v4.3.3 / BerryDriver 9 / Tasmota 13.3.0 @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 @@ -108,7 +108,9 @@ ReleaseNotes: - 23.01.2024 - v4.3.3.39 Add: Optional setOn & setOff for HW button with mode 'set' - 28.01.2024 - v4.3.3.39 Fix: ack for read-only state - 03.02.2024 - v4.3.3.40 Fix: RGB maxValueColorTemp - - 05.02.2024 - v4.3.3.40 Fix SqueezeboxRPC-Media-Player and add some Functions + - 05.02.2024 - v4.3.3.40 Fix: SqueezeboxRPC-Media-Player and add some Functions + - 06.02.2024 - v4.3.3.41 Fix: activeBrightness -> null + - 06.02.2024 - v4.3.3.41 Fix: bHome -> corrected PageId Todo: @@ -976,7 +978,7 @@ export const config: Config = { // _________________________________ DE: Ab hier keine Konfiguration mehr _____________________________________ // _________________________________ EN: No more configuration from here _____________________________________ -const scriptVersion: string = 'v4.3.3.40'; +const scriptVersion: string = 'v4.3.3.41'; const tft_version: string = 'v4.3.3'; const desired_display_firmware_version = 53; const berry_driver_version = 9; @@ -6485,17 +6487,21 @@ function HandleButtonEvent(words: any): void { GeneratePage(activePage!); } break; - case 'bHome': - if (Debug) { - log('HandleButtonEvent -> bHome: ' + words[4] + ' - ' + pageId, 'info'); - } - UnsubscribeWatcher(); - if (activePage!.home != undefined) { - GeneratePage(eval(activePage!.home)); - } else { - GeneratePage(config.pages[0]); - } - break; + case 'bHome': + if (Debug) { + log('HandleButtonEvent -> bHome: ' + words[4] + ' - ' + pageId, 'info'); + } + UnsubscribeWatcher(); + const home = activePage!.home; + if (home !== undefined) { + pageId = config.pages.findIndex(a => a == eval(home)) + pageId = pageId === -1 ? 0 : pageId; + GeneratePage(eval(home)); + } else { + pageId = 0; + GeneratePage(config.pages[0]); + } + break; case 'notifyAction': if (words[4] == 'yes') { setState(popupNotifyInternalName, { val: words[2], ack: true }); diff --git a/ioBroker/NsPanelTs.ts b/ioBroker/NsPanelTs.ts index 5da8454f..b812a4a4 100644 --- a/ioBroker/NsPanelTs.ts +++ b/ioBroker/NsPanelTs.ts @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------- -TypeScript v4.3.3.40 zur Steuerung des SONOFF NSPanel mit dem ioBroker by @Armilar / @TT-Tom / @ticaki / @Britzelpuf / @Sternmiere / @ravenS0ne +TypeScript v4.3.3.41 zur Steuerung des SONOFF NSPanel mit dem ioBroker by @Armilar / @TT-Tom / @ticaki / @Britzelpuf / @Sternmiere / @ravenS0ne - abgestimmt auf TFT 53 / v4.3.3 / BerryDriver 9 / Tasmota 13.3.0 @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 @@ -108,7 +108,9 @@ ReleaseNotes: - 23.01.2024 - v4.3.3.39 Add: Optional setOn & setOff for HW button with mode 'set' - 28.01.2024 - v4.3.3.39 Fix: ack for read-only state - 03.02.2024 - v4.3.3.40 Fix: RGB maxValueColorTemp - - 05.02.2024 - v4.3.3.40 Fix SqueezeboxRPC-Media-Player and add some Functions + - 05.02.2024 - v4.3.3.40 Fix: SqueezeboxRPC-Media-Player and add some Functions + - 06.02.2024 - v4.3.3.41 Fix: activeBrightness -> null + - 06.02.2024 - v4.3.3.41 Fix: bHome -> corrected PageId Todo: @@ -976,7 +978,7 @@ export const config: Config = { // _________________________________ DE: Ab hier keine Konfiguration mehr _____________________________________ // _________________________________ EN: No more configuration from here _____________________________________ -const scriptVersion: string = 'v4.3.3.40'; +const scriptVersion: string = 'v4.3.3.41'; const tft_version: string = 'v4.3.3'; const desired_display_firmware_version = 53; const berry_driver_version = 9; @@ -1516,11 +1518,11 @@ InitActiveBrightness(); on({id: [NSPanel_Path + 'ScreensaverInfo.activeBrightness'], change: 'ne'}, async function (obj) { try { - let active = getState(NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness').val; + let active = getState(NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness').val ?? -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 }); - InitDimmode(); + 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 }); + InitDimmode(); } } catch (err:any) { log('error at trigger activeBrightness: ' + err.message, 'warn'); @@ -1529,7 +1531,7 @@ on({id: [NSPanel_Path + 'ScreensaverInfo.activeBrightness'], change: 'ne'}, asyn on({id: [NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness'], change: "ne"}, async function (obj) { try { - let active = getState(NSPanel_Path + 'ScreensaverInfo.activeBrightness').val; + let active = getState(NSPanel_Path + 'ScreensaverInfo.activeBrightness').val ?? 80; if (obj.state.val != null && obj.state.val != -1) { if (obj.state.val < -1 || obj.state.val > 100) { log('activeDimmodeBrightness value only between -1 and 100', 'info'); @@ -1559,7 +1561,7 @@ on({id: [NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness'], change: "ne" on({id: String(NSPanel_Path) + 'ScreensaverInfo.Trigger_Dimmode', change: "ne"}, async function (obj) { try { - let active = getState(NSPanel_Path + 'ScreensaverInfo.activeBrightness').val; + let active = getState(NSPanel_Path + 'ScreensaverInfo.activeBrightness').val ?? 80; if (obj.state.val) { SendToPanel({ payload: 'dimmode~' + 100 + '~' + active + '~' + rgb_dec565(config.defaultBackgroundColor) + '~' + rgb_dec565(globalTextColor) + '~' + Sliders2 }); } else { @@ -1910,8 +1912,8 @@ on({id: [NSPanel_Path + 'PageNavi'], change: "any"}, async function (obj) { //----------------------Begin Dimmode function ScreensaverDimmode(timeDimMode:NSPanel.DimMode) { try { - let active = getState(NSPanel_Path + 'ScreensaverInfo.activeBrightness').val - let dimmode = getState(NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness').val + let active = getState(NSPanel_Path + 'ScreensaverInfo.activeBrightness').val ?? 80 + let dimmode = getState(NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness').val ?? -1 if (Debug) { log('function ScreensaverDimmode RGB-Wert HMIDark' + rgb_dec565(HMIDark), 'info'); } @@ -2018,12 +2020,12 @@ async function InitDimmode() { ScreensaverDimmode(timeDimMode); }); 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 + '~' + rgb_dec565(config.defaultBackgroundColor) + '~' + rgb_dec565(globalTextColor) + '~' + Sliders2 }); + SendToPanel({ payload: 'dimmode~' + getState(NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness').val + '~' + 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 + '~' + rgb_dec565(config.defaultBackgroundColor) + '~' + rgb_dec565(globalTextColor) + '~' + Sliders2 }); + SendToPanel({ payload: 'dimmode~' + timeDimMode.brightnessDay + '~' + getState(NSPanel_Path + 'ScreensaverInfo.activeBrightness').val?? 80 + '~' + rgb_dec565(config.defaultBackgroundColor) + '~' + rgb_dec565(globalTextColor) + '~' + Sliders2 }); } else { - SendToPanel({ payload: 'dimmode~' + timeDimMode.brightnessNight + '~' + getState(NSPanel_Path + 'ScreensaverInfo.activeBrightness').val + '~' + rgb_dec565(config.defaultBackgroundColor) + '~' + rgb_dec565(globalTextColor) + '~' + Sliders2 }); + SendToPanel({ payload: 'dimmode~' + timeDimMode.brightnessNight + '~' + getState(NSPanel_Path + 'ScreensaverInfo.activeBrightness').val ?? 80 + '~' + rgb_dec565(config.defaultBackgroundColor) + '~' + rgb_dec565(globalTextColor) + '~' + Sliders2 }); } ScreensaverDimmode(timeDimMode); } @@ -6485,17 +6487,21 @@ function HandleButtonEvent(words: any): void { GeneratePage(activePage!); } break; - case 'bHome': - if (Debug) { - log('HandleButtonEvent -> bHome: ' + words[4] + ' - ' + pageId, 'info'); - } - UnsubscribeWatcher(); - if (activePage!.home != undefined) { - GeneratePage(eval(activePage!.home)); - } else { - GeneratePage(config.pages[0]); - } - break; + case 'bHome': + if (Debug) { + log('HandleButtonEvent -> bHome: ' + words[4] + ' - ' + pageId, 'info'); + } + UnsubscribeWatcher(); + const home = activePage!.home; + if (home !== undefined) { + pageId = config.pages.findIndex(a => a == eval(home)) + pageId = pageId === -1 ? 0 : pageId; + GeneratePage(eval(home)); + } else { + pageId = 0; + GeneratePage(config.pages[0]); + } + break; case 'notifyAction': if (words[4] == 'yes') { setState(popupNotifyInternalName, { val: words[2], ack: true }); @@ -9953,7 +9959,7 @@ namespace NSPanel { export type SerialType = 'button' | 'light' | 'shutter' | 'text' | 'input_sel' | 'timer' | 'number' | 'fan' - export type roles = 'light' |'socket'|'dimmer'| 'hue' | 'rgb' | 'rgbSingle' | 'cd' | 'blind' | 'door' | 'window' | 'volumeGroup' | 'volume' + export type roles = 'light' |'socket'|'dimmer'| 'hue' | 'rgb' | 'rgbSingle' | 'ct' | 'blind' | 'door' | 'window' | 'volumeGroup' | 'volume' | 'info' | 'humidity' | 'temperature' | 'value.temperature' | 'value.humidity' | 'sensor.door' | 'sensor.window' | 'thermostat' | 'warning' | 'ct' | 'cie' | 'gate' | 'motion' | 'buttonSensor' | 'button' | 'value.time' | 'level.timer' | 'value.alarmtime' | 'level.mode.fan' | 'lock' | 'slider' | 'switch.mode.wlan' | 'media' | 'timeTable' | 'airCondition'