From 9da519dce9500ec9765407d703a5618807ee1d18 Mon Sep 17 00:00:00 2001 From: britzelpuf <101716456+britzelpuf@users.noreply.github.com> Date: Mon, 11 Apr 2022 15:35:06 +0200 Subject: [PATCH 1/6] Documentation for display version 30 --- ioBroker/README.md | 61 +++++++--------------------------------------- 1 file changed, 9 insertions(+), 52 deletions(-) diff --git a/ioBroker/README.md b/ioBroker/README.md index 61f1a94d..47229a99 100644 --- a/ioBroker/README.md +++ b/ioBroker/README.md @@ -32,18 +32,8 @@ You can find this in the device raw settings. - Create a state with a mqtt client or create one per hand. The mqtt adapter will not create the state CustomSend - you only need to send a dummy message to cmnd//CustomSend - then the state will be created +- Put the file icon_mapping.ts in the global folder -## Update the screensaver string -The screensaver string which is send to the display looks something like this: -weatherUpdate,?23?11 °C?26?54%?Batterie?4?12 %?PV?23?123W -All fields are seperated by a question mark. In detail the fields are: -weatherUpdate,?Icon?Text?Icon (default humidity)?Text next to the last icon?Text for the left icon on the right side?Icon?Text under the icon?Text for the right icon on the left side?Icon?Text under the icon - -See the icons currently usable in the following table: - -[Icon Table](../HMI#icons-ids) - -You can change the string and devices in the config object. ## Hardware buttons If you like you can add special pages for the buttons. @@ -66,11 +56,11 @@ const BatteryEmpty: RGB = { red: 179, green: 45, blue: 25 } var config: Config = { panelRecvTopic: "mqtt.0.tele.WzDisplay.RESULT", // This is the object where the panel send the data to. panelSendTopic: "mqtt.0.cmnd.WzDisplay.CustomSend", // This is the object where data is send to the panel. - firstScreensaverEntity: { ScreensaverEntity: "alias.0.Wetter.HUMIDITY", ScreensaverEntityIcon: 26, ScreensaverEntityText: "Luft", ScreensaverEntityUnitText: "%" }, + firstScreensaverEntity: { ScreensaverEntity: "alias.0.Wetter.HUMIDITY", ScreensaverEntityIcon: "water-percent", ScreensaverEntityText: "Luft", ScreensaverEntityUnitText: "%" }, // Items which should be presented on the screensaver page - secondScreensaverEntity: { ScreensaverEntity: "alias.0.Wetter.PRECIPITATION_CHANCE", ScreensaverEntityIcon: 19, ScreensaverEntityText: "Regen", ScreensaverEntityUnitText: "%" }, - thirdScreensaverEntity: { ScreensaverEntity: "alias.0.Batterie.ACTUAL", ScreensaverEntityIcon: 34, ScreensaverEntityText: "Batterie", ScreensaverEntityUnitText: "%" }, - fourthScreensaverEntity: { ScreensaverEntity: "alias.0.Pv.ACTUAL", ScreensaverEntityIcon: 32, ScreensaverEntityText: "PV", ScreensaverEntityUnitText: "W" }, + secondScreensaverEntity: { ScreensaverEntity: "alias.0.Wetter.PRECIPITATION_CHANCE", ScreensaverEntityIcon: "weather-pouring", ScreensaverEntityText: "Regen", ScreensaverEntityUnitText: "%" }, + thirdScreensaverEntity: { ScreensaverEntity: "alias.0.Batterie.ACTUAL", ScreensaverEntityIcon: "battery-medium", ScreensaverEntityText: "Batterie", ScreensaverEntityUnitText: "%" }, + fourthScreensaverEntity: { ScreensaverEntity: "alias.0.Pv.ACTUAL", ScreensaverEntityIcon: "solar-power", ScreensaverEntityText: "PV", ScreensaverEntityUnitText: "W" }, screenSaverDoubleClick: false, // Doubletouch needed for leaving screensaver. timeoutScreensaver: 15, // Timeout for screensaver dimmode: 8, // Display dim @@ -82,45 +72,12 @@ var config: Config = { defaultOnColor: RGB, // Default on state color for items defaultOffColor: RGB, // Default off state color for page temperatureUnit: "°C", // Unit to append on temperature sensors -<<<<<<< HEAD pages: [Wohnen, Strom, { "type": "cardThermo", "heading": "Thermostat", "useColor": true, "items": [{ id: "alias.0.WzNsPanel" }] -======= - pages: [ - { - "type": "cardEntities", // card type (cardEntities, cardThermo) - "heading": "Testseite", // heading - "useColor": false, // should colors be enabled on this page, can be overridden in PageItem - "items": [ // items array (up to 4 on cardEntities, 1 for cardThermo) - { id: "alias.0.Rolladen_Eltern" }, // device which must be configured in the device panel. Use only the folder for the device, not the set, get states ... - { id: "alias.0.Erker" }, - { id: "alias.0.Küche", useColor: true }, - { id: "alias.0.Wand", useColor: true } - - ] - }, - { - "type": "cardEntities", - "heading": "Strom", - "useColor": true, // should colors be enabled on this page, can be overridden in PageItem - "items": [ - { id: "alias.0.Netz" }, - { id: "alias.0.Hausverbrauch", icon: 4, interpolateColor: true, offColor: BatteryFull, onColor: Red , maxValue: 1000 }, - { id: "alias.0.Pv" }, - { id: "alias.0.Batterie", icon: 34, interpolateColor: true, offColor: BatteryEmpty, onColor: BatteryFull } - - ] - }, - { - "type": "cardThermo", - "heading": "Thermostat", - "useColor": false, // should colors be enabled on this page, can be overridden in PageItem - "item": "alias.0.WzNsPanel" // Needs to be a thermostat in the device panel ->>>>>>> 8a48ff35d408a7712a3052ee3cf8fc84e8b699c7 } ], button1Page: button1Page, // A cardEntities, cardThermo or nothing. This will be opened when pressing button1 @@ -170,10 +127,10 @@ pages: [ "heading": "Strom", "useColor": true, // should colors be enabled on this page, can be overridden in PageItem "items": [ - { id: "alias.0.Netz" }, - { id: "alias.0.Hausverbrauch" }, - { id: "alias.0.Pv" }, - { id: "alias.0.Batterie" } + { id: "alias.0.Netz", icon: "flash", interpolateColor: true, offColor: BatteryFull, onColor: Red, minValue: -1000, maxValue: 1000 }, + { id: "alias.0.Hausverbrauch", icon: "flash", interpolateColor: true, offColor: BatteryFull, onColor: Red, maxValue: 1000 }, + { id: "alias.0.Pv", icon: "solar-power", interpolateColor: true, offColor: Off, onColor: BatteryFull, maxValue: 1000 }, + { id: "alias.0.Batterie", icon: "battery-medium", interpolateColor: true, offColor: BatteryEmpty, onColor: BatteryFull } ] }] ``` From 147e08aa5f75564ca19f3a5c2391a7197a52365d Mon Sep 17 00:00:00 2001 From: britzelpuf <101716456+britzelpuf@users.noreply.github.com> Date: Mon, 11 Apr 2022 15:38:13 +0200 Subject: [PATCH 2/6] Update for Panel version 30 --- ioBroker/NsPanelTs.ts | 172 +++++++++++++++++++++++++----------------- 1 file changed, 101 insertions(+), 71 deletions(-) diff --git a/ioBroker/NsPanelTs.ts b/ioBroker/NsPanelTs.ts index 4a83d12a..9b792eb9 100644 --- a/ioBroker/NsPanelTs.ts +++ b/ioBroker/NsPanelTs.ts @@ -1,3 +1,4 @@ +var Icons = new IconsSelector(); const Months = ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"]; const Days = ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"]; @@ -27,10 +28,10 @@ var Strom: PageEntities = "heading": "Strom", "useColor": true, "items": [ - { id: "alias.0.Netz", icon: 4, interpolateColor: true, offColor: BatteryFull, onColor: Red , minValue: -1000, maxValue: 1000 }, - { id: "alias.0.Hausverbrauch", icon: 4, interpolateColor: true, offColor: BatteryFull, onColor: Red , maxValue: 1000 }, - { id: "alias.0.Pv", icon: 4, interpolateColor: true, offColor: Off, onColor: BatteryFull , maxValue: 1000 }, - { id: "alias.0.Batterie", icon: 34, interpolateColor: true, offColor: BatteryEmpty, onColor: BatteryFull } + { id: "alias.0.Netz", icon: "flash", interpolateColor: true, offColor: BatteryFull, onColor: Red, minValue: -1000, maxValue: 1000 }, + { id: "alias.0.Hausverbrauch", icon: "flash", interpolateColor: true, offColor: BatteryFull, onColor: Red, maxValue: 1000 }, + { id: "alias.0.Pv", icon: "solar-power", interpolateColor: true, offColor: Off, onColor: BatteryFull, maxValue: 1000 }, + { id: "alias.0.Batterie", icon: "battery-medium", interpolateColor: true, offColor: BatteryEmpty, onColor: BatteryFull } ] }; @@ -62,10 +63,10 @@ var button2Page: PageEntities = export const config: Config = { panelRecvTopic: "mqtt.0.tele.WzDisplay.RESULT", panelSendTopic: "mqtt.0.cmnd.WzDisplay.CustomSend", - firstScreensaverEntity: { ScreensaverEntity: "alias.0.Wetter.HUMIDITY", ScreensaverEntityIcon: 26, ScreensaverEntityText: "Luft", ScreensaverEntityUnitText: "%" }, - secondScreensaverEntity: { ScreensaverEntity: "alias.0.Wetter.PRECIPITATION_CHANCE", ScreensaverEntityIcon: 19, ScreensaverEntityText: "Regen", ScreensaverEntityUnitText: "%" }, - thirdScreensaverEntity: { ScreensaverEntity: "alias.0.Batterie.ACTUAL", ScreensaverEntityIcon: 34, ScreensaverEntityText: "Batterie", ScreensaverEntityUnitText: "%" }, - fourthScreensaverEntity: { ScreensaverEntity: "alias.0.Pv.ACTUAL", ScreensaverEntityIcon: 32, ScreensaverEntityText: "PV", ScreensaverEntityUnitText: "W" }, + firstScreensaverEntity: { ScreensaverEntity: "alias.0.Wetter.HUMIDITY", ScreensaverEntityIcon: "water-percent", ScreensaverEntityText: "Luft", ScreensaverEntityUnitText: "%" }, + secondScreensaverEntity: { ScreensaverEntity: "alias.0.Wetter.PRECIPITATION_CHANCE", ScreensaverEntityIcon: "weather-pouring", ScreensaverEntityText: "Regen", ScreensaverEntityUnitText: "%" }, + thirdScreensaverEntity: { ScreensaverEntity: "alias.0.Batterie.ACTUAL", ScreensaverEntityIcon: "battery-medium", ScreensaverEntityText: "Batterie", ScreensaverEntityUnitText: "%" }, + fourthScreensaverEntity: { ScreensaverEntity: "alias.0.Pv.ACTUAL", ScreensaverEntityIcon: "solar-power", ScreensaverEntityText: "PV", ScreensaverEntityUnitText: "W" }, timeoutScreensaver: 15, dimmode: 8, screenSaverDoubleClick: false, @@ -90,7 +91,7 @@ export const config: Config = { }; var subscriptions: any = {}; - +var screensaverEnabled : boolean = false; var pageId = 0; schedule("* * * * *", function () { @@ -144,24 +145,29 @@ function HandleMessage(typ: string, method: string, page: number, words: Array e.id === words[3]); if (pageItem !== undefined) SendToPanel(GenerateDetailPage(words[2], pageItem)); case "buttonPress2": + screensaverEnabled = false; HandleButtonEvent(words); break; - case "screensaverOpen": - HandleScreensaver(); - break; case "button1": case "button2": + screensaverEnabled = false; HandleHardwareButton(method); default: break; @@ -200,8 +206,8 @@ function HandleHardwareButton(method: string): void { function HandleStartupProcess(): void { SendDate(); SendTime(); - SendToPanel({ payload: "timeout," + config.timeoutScreensaver }); - SendToPanel({ payload: "dimmode," + config.dimmode }); + SendToPanel({ payload: "timeout~" + config.timeoutScreensaver }); + SendToPanel({ payload: "dimmode~" + config.dimmode }); } function SendDate(): void { @@ -210,7 +216,7 @@ function SendDate(): void { var date = d.getDate(); var month = Months[d.getMonth()]; var year = d.getFullYear(); - var _sendDate = "date,?" + day + " " + date + " " + month + " " + year; + var _sendDate = "date~" + day + " " + date + " " + month + " " + year; SendToPanel({ payload: _sendDate }); } @@ -225,28 +231,40 @@ function SendTime(): void { if (d.getMinutes() < 10) { min = "0" + d.getMinutes().toString(); } - SendToPanel({ payload: "time," + hr + ":" + min }); + SendToPanel({ payload: "time~" + hr + ":" + min }); } function GenerateEntitiesPage(page: PageEntities): Payload[] { var out_msgs: Array = []; - out_msgs = [{ payload: "pageType,cardEntities" }, { payload: "entityUpdHeading," + page.heading }] - out_msgs.push({ payload: GeneratePageElements(page.items, 4, page.useColor) }); + out_msgs = [{ payload: "pageType~cardEntities" }] + out_msgs.push({ payload: GeneratePageElements(page) }); return out_msgs } function GenerateGridPage(page: PageGrid): Payload[] { var out_msgs: Array = []; - out_msgs = [{ payload: "pageType,cardGrid" }, { payload: "entityUpdHeading," + page.heading }] - out_msgs.push({ payload: GeneratePageElements(page.items, 6, page.useColor) }); + out_msgs = [{ payload: "pageType~cardGrid" }] + out_msgs.push({ payload: GeneratePageElements(page) }); return out_msgs } -function GeneratePageElements(pageItems: PageItem[], maxItems: number, useColors: boolean = false): string { - let pageData = "entityUpd"; +function GeneratePageElements(page: Page): string { + let maxItems = 0; + switch (page.type) { + case "cardThermo": + maxItems = 1; + break; + case "cardEntities": + maxItems = 4; + break; + case "cardGrid": + maxItems = 6; + break; + } + let pageData = "entityUpd~" + page.heading + "~" + GetNavigationString(pageId) for (let index = 0; index < maxItems; index++) { - if (pageItems[index] !== undefined) { - pageData += CreateEntity(pageItems[index], index + 1, useColors); + if (page.items[index] !== undefined) { + pageData += CreateEntity(page.items[index], index + 1, page.useColor); } else { pageData += CreateEntity({ id: "delete" }, index + 1); @@ -256,9 +274,9 @@ function GeneratePageElements(pageItems: PageItem[], maxItems: number, useColors } function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean = false): string { - var iconId = 0 + var iconId = "0" if (pageItem.id == "delete") { - return ",delete,,,,," + return "~delete~~~~~" } var name: string; var type: string; @@ -281,7 +299,7 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean = switch (o.common.role) { case "light": type = "light" - iconId = pageItem.icon !== undefined ? pageItem.icon : 1; + iconId = pageItem.icon !== undefined ? Icons.GetIcon(pageItem.icon) : Icons.GetIcon("thermometer"); var optVal = "0" if (val === true || val === "true") { @@ -289,11 +307,11 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean = iconColor = GetIconColor(pageItem, true, useColors); } - return "," + type + "," + pageItem.id + "," + iconId + "," + iconColor + "," + name + "," + optVal; + return "~" + type + "~" + pageItem.id + "~" + iconId + "~" + iconColor + "~" + name + "~" + optVal; case "dimmer": type = "light" - iconId = pageItem.icon !== undefined ? pageItem.icon : 1; + iconId = pageItem.icon !== undefined ? Icons.GetIcon(pageItem.icon) : Icons.GetIcon("lightbulb"); var optVal = "0" if (existsState(pageItem.id + ".ON_ACTUAL")) { val = getState(pageItem.id + ".ON_ACTUAL").val; @@ -308,19 +326,19 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean = iconColor = GetIconColor(pageItem, existsState(pageItem.id + ".ACTUAL") ? getState(pageItem.id + ".ACTUAL").val : true, useColors); } - return "," + type + "," + pageItem.id + "," + iconId + "," + iconColor + "," + name + "," + optVal; + return "~" + type + "~" + pageItem.id + "~" + iconId + "~" + iconColor + "~" + name + "~" + optVal; case "blind": type = "shutter" - iconId = pageItem.icon !== undefined ? pageItem.icon : 11; + 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); - return "," + type + "," + pageItem.id + "," + iconId + "," + iconColor + "," + name + "," + return "~" + type + "~" + pageItem.id + "~" + iconId + "~" + iconColor + "~" + name + "~" case "info": case "value.temperature": case "thermostat": type = "text"; - iconId = pageItem.icon !== undefined ? pageItem.icon : o.common.role == "value.temperature" || o.common.role == "thermostat" ? 2 : 0; + iconId = pageItem.icon !== undefined ? Icons.GetIcon(pageItem.icon) : o.common.role == "value.temperature" || o.common.role == "thermostat" ? Icons.GetIcon("thermometer") : Icons.GetIcon("information-outline"); let unit = ""; var optVal = "0" if (existsState(pageItem.id + ".ON_ACTUAL")) { @@ -335,26 +353,26 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean = } if (o.common.role == "value.temperature") { - iconId = pageItem.icon !== undefined ? pageItem.icon : 2; + iconId = pageItem.icon !== undefined ? Icons.GetIcon(pageItem.icon) : Icons.GetIcon("thermometer"); } iconColor = GetIconColor(pageItem, parseInt(optVal), useColors); - return "," + type + "," + pageItem.id + "," + iconId + "," + iconColor + "," + name + "," + optVal + " " + unit; + return "~" + type + "~" + pageItem.id + "~" + iconId + "~" + iconColor + "~" + name + "~" + optVal + " " + unit; case "button": type = "button"; - iconId = pageItem.icon !== undefined ? pageItem.icon : 3; + iconId = pageItem.icon !== undefined ? Icons.GetIcon(pageItem.icon) : Icons.GetIcon("gesture-tap-button"); let buttonText = pageItem.buttonText !== undefined ? pageItem.buttonText : "PRESS"; iconColor = GetIconColor(pageItem, true, useColors); - return "," + type + "," + pageItem.id + "," + iconId + "," + + iconColor + "," + name + "," + buttonText; + return "~" + type + "~" + pageItem.id + "~" + iconId + "~" + + iconColor + "~" + name + "~" + buttonText; default: - return ",delete,,,,"; + return "~delete~~~~~"; } } - return ",delete,,,,," + return "~delete~~~~~" } function GetIconColor(pageItem: PageItem, value: (boolean | number), useColors: boolean): number { @@ -384,8 +402,7 @@ function RegisterEntityWatcher(id: string): void { return; } subscriptions[id] = (on({ id: id, change: 'any' }, function (data) { - log("RegisterEntityWatcher PageId:" + pageId.toString()) - GeneratePage(config.pages[pageId]); + SendToPanel({ payload: GeneratePageElements(config.pages[pageId]) }); })) } @@ -437,11 +454,11 @@ function GenerateThermoPage(page: PageThermo): Payload[] { let status = "" if (existsState(id + ".MODE")) status = getState(id + ".MODE").val; - let minTemp = 180 - let maxTemp = 300 + let minTemp = 50 + let maxTemp = 350 let stepTemp = 5 - out_msgs.push({ payload: "entityUpd," + id + "," + name + "," + currentTemp + "," + destTemp + "," + status + "," + minTemp + "," + maxTemp + "," + stepTemp }) + out_msgs.push({ payload: "entityUpd~" + id + "~" + name + "~" + currentTemp + "~" + destTemp + "~" + status + "~" + minTemp + "~" + maxTemp + "~" + stepTemp }) } return out_msgs @@ -537,6 +554,18 @@ function HandleButtonEvent(words): void { break; } } +function GetNavigationString(pageId: number): string { + switch (pageId) { + case 0: + return "0|1"; + case config.pages.length: + log("asd") + return "1|0"; + default: + return "1|1"; + } +} + function GenerateDetailPage(type: string, pageItem: PageItem): Payload[] { @@ -545,7 +574,7 @@ function GenerateDetailPage(type: string, pageItem: PageItem): Payload[] { if (existsObject(id)) { var o = getObject(id) var val: (boolean | number) = 0; - let icon = 1; + let icon = Icons.GetIcon("lightbulb"); var iconColor = rgb_dec565(config.defaultColor); if (type == "popupLight") { let switchVal = "0" @@ -564,7 +593,7 @@ function GenerateDetailPage(type: string, pageItem: PageItem): Payload[] { iconColor = GetIconColor(pageItem, true, false); } - out_msgs.push({ payload: "entityUpdateDetail," + icon + "," + + iconColor + "," + switchVal + ",disable,disable,disable" }) + out_msgs.push({ payload: "entityUpdateDetail~" + icon + "~" + + iconColor + "~" + switchVal + ",disable,disable,disable" }) } if (o.common.role == "dimmer") { @@ -594,7 +623,7 @@ function GenerateDetailPage(type: string, pageItem: PageItem): Payload[] { //if (attr_support_color.includes("color_temp")) // colortemp = Math.trunc(scale(attr.color_temp, attr.min_mireds, attr.max_mireds, 0, 100)) - out_msgs.push({ payload: "entityUpdateDetail," + icon + "," + iconColor + "," + switchVal + "," + brightness + "," + colorTemp + "," + colorMode }) + out_msgs.push({ payload: "entityUpdateDetail~" + icon + "~" + iconColor + "~" + switchVal + "~" + brightness + "~" + colorTemp + "~" + colorMode }) } } @@ -622,12 +651,13 @@ function UnsubscribeWatcher(): void { } function HandleScreensaver(): void { + SendToPanel({ payload: "pageType~screensaver"}) UnsubscribeWatcher(); HandleScreensaverUpdate(); } function HandleScreensaverUpdate(): void { - if (config.weatherEntity != null && existsObject(config.weatherEntity)) { + if (screensaverEnabled && config.weatherEntity != null && existsObject(config.weatherEntity)) { var icon = getState(config.weatherEntity + ".ICON").val; let temperature: string = @@ -635,8 +665,8 @@ function HandleScreensaverUpdate(): void { existsState(config.weatherEntity + ".TEMP") ? getState(config.weatherEntity + ".TEMP").val : "null"; let payloadString = - "weatherUpdate,?" + GetAccuWeatherIcon(parseInt(icon)) + "?" - + temperature + " " + config.temperatureUnit + "?" + "weatherUpdate~" + Icons.GetIcon(GetAccuWeatherIcon(parseInt(icon))) + "~" + + temperature + " " + config.temperatureUnit + "~" payloadString += GetScreenSaverEntityString(config.firstScreensaverEntity); payloadString += GetScreenSaverEntityString(config.secondScreensaverEntity); @@ -650,54 +680,54 @@ function HandleScreensaverUpdate(): void { function GetScreenSaverEntityString(configElement: ScreenSaverElement | null): string { if (configElement != null && configElement.ScreensaverEntity != null && existsState(configElement.ScreensaverEntity)) { let u1 = getState(configElement.ScreensaverEntity).val; - return configElement.ScreensaverEntityText + "?" + configElement.ScreensaverEntityIcon + "?" + u1 + " " + configElement.ScreensaverEntityUnitText + "?"; + return configElement.ScreensaverEntityText + "~" + Icons.GetIcon(configElement.ScreensaverEntityIcon) + "~" + u1 + " " + configElement.ScreensaverEntityUnitText + "~"; } else { - return "???"; + return "~~~"; } } -function GetAccuWeatherIcon(icon: number): number { +function GetAccuWeatherIcon(icon: number): string { switch (icon) { case 24: // Ice case 30: // Hot case 31: // Cold - return 11; // exceptional + return "window-open"; // exceptional case 7: // Cloudy case 8: // Dreary (Overcast) case 38: // Mostly Cloudy - return 12; // cloudy + return "weather-cloudy"; // cloudy case 11: // fog - return 13; // fog + return "weather-fog"; // fog case 25: // Sleet - return 14; // Hail + return "weather-hail"; // Hail case 15: // T-Storms - return 15; // lightning + return "weather-lightning"; // lightning case 16: // Mostly Cloudy w/ T-Storms case 17: // Partly Sunny w/ T-Storms case 41: // Partly Cloudy w/ T-Storms case 42: // Mostly Cloudy w/ T-Storms - return 16; // lightning-rainy + return "weather-lightning-rainy"; // lightning-rainy case 33: // Clear case 34: // Mostly Clear case 37: // Hazy Moonlight - return 17; + return "weather-night"; case 3: // Partly Sunny case 4: // Intermittent Clouds case 6: // Mostly Cloudy case 35: // Partly Cloudy case 36: // Intermittent Clouds - return 18; // partlycloudy + return "weather-partly-cloudy"; // partlycloudy case 18: // pouring - return 19; // pouring + return "weather-pouring"; // pouring case 12: // Showers case 13: // Mostly Cloudy w/ Showers @@ -705,7 +735,7 @@ function GetAccuWeatherIcon(icon: number): number { case 26: // Freezing Rain case 39: // Partly Cloudy w/ Showers case 40: // Mostly Cloudy w/ Showers - return 20; // rainy + return "weather-rainy"; // rainy case 19: // Flurries case 20: // Mostly Cloudy w/ Flurries @@ -714,21 +744,21 @@ function GetAccuWeatherIcon(icon: number): number { case 23: // Mostly Cloudy w/ Snow case 43: // Mostly Cloudy w/ Flurries case 44: // Mostly Cloudy w/ Snow - return 21; // snowy + return "weather-snowy"; // snowy case 29: // Rain and Snow - return 22; // snowy-rainy + return "weather-snowy-rainy"; // snowy-rainy case 1: // Sunny case 2: // Mostly Sunny case 5: // Hazy Sunshine - return 23; // sunny + return "weather-sunny"; // sunny case 32: // windy - return 24; // windy + return "weather-windy"; // windy default: - return 1; + return "alert-circle-outline"; } } @@ -787,7 +817,7 @@ interface PageThermo extends Page { type PageItem = { id: string, - icon: (number | undefined), + icon: (string | undefined), onColor: (RGB | undefined), offColor: (RGB | undefined), useColor: (boolean | undefined), @@ -823,7 +853,7 @@ type Config = { type ScreenSaverElement = { ScreensaverEntity: string | null, - ScreensaverEntityIcon: number | null, + ScreensaverEntityIcon: string | null, ScreensaverEntityText: string | null, ScreensaverEntityUnitText: string | null, -} \ No newline at end of file +} From 50328fc38658e3142960510800299cf8a2061b94 Mon Sep 17 00:00:00 2001 From: britzelpuf <101716456+britzelpuf@users.noreply.github.com> Date: Mon, 11 Apr 2022 22:28:42 +0200 Subject: [PATCH 3/6] Fix CardThermo, added names --- ioBroker/NsPanelTs.ts | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/ioBroker/NsPanelTs.ts b/ioBroker/NsPanelTs.ts index 9b792eb9..9694f2d5 100644 --- a/ioBroker/NsPanelTs.ts +++ b/ioBroker/NsPanelTs.ts @@ -15,7 +15,7 @@ var Wohnen: PageEntities = "heading": "Haus", "useColor": true, "items": [ - { id: "alias.0.Stern"}, + { id: "alias.0.Stern", name: "Sternsteckdose"}, { id: "alias.0.Erker"}, { id: "alias.0.Küche", interpolateColor: true }, { id: "alias.0.Wand" } @@ -83,7 +83,7 @@ export const config: Config = { "type": "cardThermo", "heading": "Thermostat", "useColor": true, - "items": [{ id: "alias.0.WzNsPanel" }] + "items": [{ id: "alias.0.WzNsPanel", name: "Wohnzimmer" }] } ], button1Page: button1Page, @@ -284,7 +284,7 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean = if (existsObject(pageItem.id)) { let o = getObject(pageItem.id) var val = null; - name = o.common.name.de + name = pageItem.name !== undefined ? pageItem.name : o.common.name.de if (existsState(pageItem.id + ".GET")) { val = getState(pageItem.id + ".GET").val; @@ -299,7 +299,7 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean = switch (o.common.role) { case "light": type = "light" - iconId = pageItem.icon !== undefined ? Icons.GetIcon(pageItem.icon) : Icons.GetIcon("thermometer"); + iconId = pageItem.icon !== undefined ? Icons.GetIcon(pageItem.icon) : Icons.GetIcon("lightbulb"); var optVal = "0" if (val === true || val === "true") { @@ -363,7 +363,7 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean = case "button": type = "button"; iconId = pageItem.icon !== undefined ? Icons.GetIcon(pageItem.icon) : Icons.GetIcon("gesture-tap-button"); - let buttonText = pageItem.buttonText !== undefined ? pageItem.buttonText : "PRESS"; + let buttonText = pageItem.name !== undefined ? pageItem.name : "PRESS"; iconColor = GetIconColor(pageItem, true, useColors); return "~" + type + "~" + pageItem.id + "~" + iconId + "~" + + iconColor + "~" + name + "~" + buttonText; @@ -434,12 +434,12 @@ function GetUnitOfMeasurement(id: string): string { function GenerateThermoPage(page: PageThermo): Payload[] { var id = page.items[0].id var out_msgs: Array = []; - out_msgs.push({ payload: "pageType,cardThermo" }); + out_msgs.push({ payload: "pageType~cardThermo" }); // ioBroker if (existsObject(id)) { let o = getObject(id) - let name = o.common.name.de + let name = page.items[0].name !== undefined ? page.items[0].name : o.common.name.de let currentTemp = 0; if (existsState(id + ".ACTUAL")) currentTemp = parseInt(getState(id + ".ACTUAL").val) * 10; @@ -454,11 +454,11 @@ function GenerateThermoPage(page: PageThermo): Payload[] { let status = "" if (existsState(id + ".MODE")) status = getState(id + ".MODE").val; - let minTemp = 50 - let maxTemp = 350 + let minTemp = 180 + let maxTemp = 300 let stepTemp = 5 - out_msgs.push({ payload: "entityUpd~" + id + "~" + name + "~" + currentTemp + "~" + destTemp + "~" + status + "~" + minTemp + "~" + maxTemp + "~" + stepTemp }) + out_msgs.push({ payload: "entityUpd~" + name + "~" + GetNavigationString(pageId) + "~" + id + "~" + currentTemp + "~" + destTemp + "~" + status + "~" + minTemp + "~" + maxTemp + "~" + stepTemp }) } return out_msgs @@ -558,8 +558,7 @@ function GetNavigationString(pageId: number): string { switch (pageId) { case 0: return "0|1"; - case config.pages.length: - log("asd") + case config.pages.length - 1: return "1|0"; default: return "1|1"; @@ -824,7 +823,7 @@ type PageItem = { interpolateColor: (boolean | undefined), minValue: (number | undefined), maxValue: (number | undefined), - buttonText: (string | undefined) + name: (string | undefined) } type Config = { From d31ff9dde54b9b7b9e177c9aed5a0d676bc583b0 Mon Sep 17 00:00:00 2001 From: britzelpuf <101716456+britzelpuf@users.noreply.github.com> Date: Mon, 11 Apr 2022 22:30:51 +0200 Subject: [PATCH 4/6] Update Readme for name extension --- ioBroker/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ioBroker/README.md b/ioBroker/README.md index 47229a99..1e51ffb2 100644 --- a/ioBroker/README.md +++ b/ioBroker/README.md @@ -96,7 +96,7 @@ type PageItem = { interpolateColor: (boolean | undefined),// fade between color on and off, useColor on Page or PageItem must be enabled minValue: (number | undefined), // the minimum value for the fade calculation, if smaller the minimum value will be used maxValue: (number | undefined), // the maximum value for the fade calculation, if larger the maximum value will be used - buttonText: (string | undefined) // the Button Text, default is "Press" + name: (string | undefined) // the Name which should be displayed, default is the name of the object itself } ``` @@ -129,7 +129,7 @@ pages: [ "items": [ { id: "alias.0.Netz", icon: "flash", interpolateColor: true, offColor: BatteryFull, onColor: Red, minValue: -1000, maxValue: 1000 }, { id: "alias.0.Hausverbrauch", icon: "flash", interpolateColor: true, offColor: BatteryFull, onColor: Red, maxValue: 1000 }, - { id: "alias.0.Pv", icon: "solar-power", interpolateColor: true, offColor: Off, onColor: BatteryFull, maxValue: 1000 }, + { id: "alias.0.Pv", name: "Solar" ,icon: "solar-power", interpolateColor: true, offColor: Off, onColor: BatteryFull, maxValue: 1000 }, { id: "alias.0.Batterie", icon: "battery-medium", interpolateColor: true, offColor: BatteryEmpty, onColor: BatteryFull } ] }] From ad31b901285487ea553018006d8563d832740130 Mon Sep 17 00:00:00 2001 From: britzelpuf <101716456+britzelpuf@users.noreply.github.com> Date: Mon, 11 Apr 2022 22:37:36 +0200 Subject: [PATCH 5/6] Remove navigation items on hardware button pages --- ioBroker/NsPanelTs.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ioBroker/NsPanelTs.ts b/ioBroker/NsPanelTs.ts index 9694f2d5..5dcfa6ca 100644 --- a/ioBroker/NsPanelTs.ts +++ b/ioBroker/NsPanelTs.ts @@ -200,7 +200,12 @@ function HandleHardwareButton(method: string): void { else { return; } + + // Set pageId to -1, because of the navigation arrows + let tempPageId = pageId; + pageId = -1; GeneratePage(page); + pageId = tempPageId; } function HandleStartupProcess(): void { @@ -560,6 +565,8 @@ function GetNavigationString(pageId: number): string { return "0|1"; case config.pages.length - 1: return "1|0"; + case -1: + return "0|0"; default: return "1|1"; } From 6b82d5715b63ab5f5cc515563f48f72a46cae930 Mon Sep 17 00:00:00 2001 From: britzelpuf <101716456+britzelpuf@users.noreply.github.com> Date: Mon, 11 Apr 2022 23:08:47 +0200 Subject: [PATCH 6/6] Added fix suggested by Armilar https://forum.iobroker.net/topic/50888/sonoff-nspanel/151 --- ioBroker/NsPanelTs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ioBroker/NsPanelTs.ts b/ioBroker/NsPanelTs.ts index 5dcfa6ca..ab43a210 100644 --- a/ioBroker/NsPanelTs.ts +++ b/ioBroker/NsPanelTs.ts @@ -447,7 +447,7 @@ function GenerateThermoPage(page: PageThermo): Payload[] { let name = page.items[0].name !== undefined ? page.items[0].name : o.common.name.de let currentTemp = 0; if (existsState(id + ".ACTUAL")) - currentTemp = parseInt(getState(id + ".ACTUAL").val) * 10; + currentTemp = (Math.round(parseFloat(getState(id + ".ACTUAL").val) * 10)/10)*10; let destTemp = 0; if (existsState(id + ".SET")) {