mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-22 07:24:24 +01:00
v4.3.2.1 - Update NsPanelTs.ts
- Upgrade TFT 53 / 4.3.2 - Fix formatDate/Date.parse with moment.js
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/*-----------------------------------------------------------------------
|
/*-----------------------------------------------------------------------
|
||||||
TypeScript v4.3.1.7 zur Steuerung des SONOFF NSPanel mit dem ioBroker by @Armilar / @TT-Tom / @Sternmiere / @Britzelpuf / @ravenS0ne
|
TypeScript v4.3.2.1 zur Steuerung des SONOFF NSPanel mit dem ioBroker by @Armilar / @TT-Tom / @Sternmiere / @Britzelpuf / @ravenS0ne
|
||||||
- abgestimmt auf TFT 53 / v4.3.1 / BerryDriver 9 / Tasmota 13.1.0
|
- abgestimmt auf TFT 53 / v4.3.2 / BerryDriver 9 / Tasmota 13.2.0
|
||||||
@joBr99 Projekt: https://github.com/joBr99/nspanel-lovelace-ui/tree/main/ioBroker
|
@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
|
NsPanelTs.ts (dieses TypeScript in ioBroker) Stable: https://github.com/joBr99/nspanel-lovelace-ui/blob/main/ioBroker/NsPanelTs.ts
|
||||||
icon_mapping.ts: https://github.com/joBr99/nspanel-lovelace-ui/blob/main/ioBroker/icon_mapping.ts (TypeScript muss in global liegen)
|
icon_mapping.ts: https://github.com/joBr99/nspanel-lovelace-ui/blob/main/ioBroker/icon_mapping.ts (TypeScript muss in global liegen)
|
||||||
@@ -19,7 +19,7 @@ Achtung Änderung des Sonoff ESP-Temperatursensors
|
|||||||
!!! Bitte "SetOption146 1" in der Tasmota-Console ausführen !!!
|
!!! Bitte "SetOption146 1" in der Tasmota-Console ausführen !!!
|
||||||
************************************************************************************************
|
************************************************************************************************
|
||||||
In bestimmten Situationen kommt es vor, dass sich das Panel mit FlashNextion
|
In bestimmten Situationen kommt es vor, dass sich das Panel mit FlashNextion
|
||||||
unter Tasmota > 12.2.0 nicht flashen lässt. Für den Fall ein Tasmota Dowengrade
|
unter Tasmota > 12.2.0 nicht flashen lässt. Für den Fall ein Tasmota Downgrade
|
||||||
durchführen und FlashNextion wiederholen.
|
durchführen und FlashNextion wiederholen.
|
||||||
************************************************************************************************
|
************************************************************************************************
|
||||||
Ab Tasmota > 13.0.0 ist für ein Upgrade ggfs. eine Umpartitionierung erforderlich
|
Ab Tasmota > 13.0.0 ist für ein Upgrade ggfs. eine Umpartitionierung erforderlich
|
||||||
@@ -178,8 +178,9 @@ ReleaseNotes:
|
|||||||
- 03.10.2023 - v4.3.1.4 Removing the examples from the NSPanelTs.ts --> https://github.com/joBr99/nspanel-lovelace-ui/wiki/NSPanel-Page-%E2%80%90-Typen_How-2_Beispiele
|
- 03.10.2023 - v4.3.1.4 Removing the examples from the NSPanelTs.ts --> https://github.com/joBr99/nspanel-lovelace-ui/wiki/NSPanel-Page-%E2%80%90-Typen_How-2_Beispiele
|
||||||
- 03.10.2023 - v4.3.1.4 Delete NsPanelTs_without_Examples.ts
|
- 03.10.2023 - v4.3.1.4 Delete NsPanelTs_without_Examples.ts
|
||||||
- 12.10.2023 - v4.3.1.5 Fix Datapoint for Role timetable -> Attention use new script from TT-Tom https://github.com/tt-tom17/MyScripts/blob/main/Sonoff_NSPanel/Fahrplan_to_NSPanel.ts
|
- 12.10.2023 - v4.3.1.5 Fix Datapoint for Role timetable -> Attention use new script from TT-Tom https://github.com/tt-tom17/MyScripts/blob/main/Sonoff_NSPanel/Fahrplan_to_NSPanel.ts
|
||||||
- 19.10.2023 - v4.3.1.6 Add more Alias Device-Types to Navigation (createEntity) / Minor Fixes
|
- 19.10.2023 - v4.3.1.6 Add more Alias Device-Types to Navigation / Minor Fixes
|
||||||
- 22.10.2023 - v4.3.1.7 Fix CreateEntity (navigate) role 'light' and 'socket' and 'temperature'
|
- 30.10.2023 - v4.3.2 Upgrade TFT 53 / 4.3.2
|
||||||
|
- 30.10.2023 - v4.3.2.1 Fix formatDate/Date.parse with moment.js (Bugs in JS-Methodes)
|
||||||
|
|
||||||
Todo:
|
Todo:
|
||||||
- XX.XX.XXXX - v4.4.0 Change the bottomScreensaverEntity (rolling) if more than 6 entries are defined
|
- XX.XX.XXXX - v4.4.0 Change the bottomScreensaverEntity (rolling) if more than 6 entries are defined
|
||||||
@@ -272,7 +273,7 @@ Erforderliche Adapter:
|
|||||||
|
|
||||||
Upgrades in Konsole:
|
Upgrades in Konsole:
|
||||||
Tasmota BerryDriver : Backlog UpdateDriverVersion https://raw.githubusercontent.com/joBr99/nspanel-lovelace-ui/main/tasmota/autoexec.be; Restart 1
|
Tasmota BerryDriver : Backlog UpdateDriverVersion https://raw.githubusercontent.com/joBr99/nspanel-lovelace-ui/main/tasmota/autoexec.be; Restart 1
|
||||||
TFT EU STABLE Version : FlashNextion http://nspanel.pky.eu/lovelace-ui/github/nspanel-v4.3.1.tft
|
TFT EU STABLE Version : FlashNextion http://nspanel.pky.eu/lovelace-ui/github/nspanel-v4.3.2.tft
|
||||||
---------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -743,7 +744,7 @@ export const config = <Config> {
|
|||||||
ScreensaverEntity: 'accuweather.0.Daily.Day1.Sunrise',
|
ScreensaverEntity: 'accuweather.0.Daily.Day1.Sunrise',
|
||||||
ScreensaverEntityFactor: 1,
|
ScreensaverEntityFactor: 1,
|
||||||
ScreensaverEntityDecimalPlaces: 0,
|
ScreensaverEntityDecimalPlaces: 0,
|
||||||
ScreensaverEntityDateFormat: 'hh:mm', // like DD.MM or DD.MM.YY or YYYY/MM/DD or hh:mm
|
ScreensaverEntityDateFormat: { hour: '2-digit', minute: '2-digit' }, // Description at Wiki-Pages
|
||||||
ScreensaverEntityIconOn: 'weather-sunset-up',
|
ScreensaverEntityIconOn: 'weather-sunset-up',
|
||||||
ScreensaverEntityIconOff: null,
|
ScreensaverEntityIconOff: null,
|
||||||
ScreensaverEntityText: 'Sonne',
|
ScreensaverEntityText: 'Sonne',
|
||||||
@@ -873,9 +874,12 @@ export const config = <Config> {
|
|||||||
// _________________________________ Ab hier keine Konfiguration mehr _____________________________________
|
// _________________________________ Ab hier keine Konfiguration mehr _____________________________________
|
||||||
|
|
||||||
const request = require('request');
|
const request = require('request');
|
||||||
|
const moment = require('moment');
|
||||||
|
const parseFormat = require('moment-parseformat');
|
||||||
|
moment.locale(getState(NSPanel_Path + 'Config.locale').val);
|
||||||
|
|
||||||
//Desired Firmware
|
//Desired Firmware
|
||||||
const tft_version: string = 'v4.3.1';
|
const tft_version: string = 'v4.3.2';
|
||||||
const desired_display_firmware_version = 53;
|
const desired_display_firmware_version = 53;
|
||||||
const berry_driver_version = 9;
|
const berry_driver_version = 9;
|
||||||
const tasmotaOtaUrl: string = 'http://ota.tasmota.com/tasmota32/release/';
|
const tasmotaOtaUrl: string = 'http://ota.tasmota.com/tasmota32/release/';
|
||||||
@@ -3020,8 +3024,9 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean =
|
|||||||
case 'sensor.window':
|
case 'sensor.window':
|
||||||
|
|
||||||
case 'thermostat':
|
case 'thermostat':
|
||||||
|
type = 'text';
|
||||||
|
|
||||||
iconId = pageItem.icon !== undefined ? Icons.GetIcon(pageItem.icon) : o.common.role == 'temperature' || o.common.role == 'value.temperature' || o.common.role == 'thermostat' ? Icons.GetIcon('thermometer') : Icons.GetIcon('information-outline');
|
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 = '';
|
let unit = '';
|
||||||
optVal = '0';
|
optVal = '0';
|
||||||
@@ -3034,6 +3039,10 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean =
|
|||||||
unit = pageItem.unit !== undefined ? pageItem.unit : GetUnitOfMeasurement(pageItem.id + '.ACTUAL');
|
unit = pageItem.unit !== undefined ? pageItem.unit : GetUnitOfMeasurement(pageItem.id + '.ACTUAL');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (o.common.role == 'value.temperature') {
|
||||||
|
iconId = pageItem.icon !== undefined ? Icons.GetIcon(pageItem.icon) : Icons.GetIcon('thermometer');
|
||||||
|
}
|
||||||
|
|
||||||
iconColor = GetIconColor(pageItem, parseInt(optVal), useColors);
|
iconColor = GetIconColor(pageItem, parseInt(optVal), useColors);
|
||||||
|
|
||||||
if (pageItem.colorScale != undefined) {
|
if (pageItem.colorScale != undefined) {
|
||||||
@@ -3075,8 +3084,9 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean =
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonText = pageItem.buttonText !== undefined ? pageItem.buttonText : existsState(pageItem.id + '.BUTTONTEXT') ? getState(pageItem.id + '.BUTTONTEXT').val : 'PRESS';
|
if (Debug) console.log('CreateEntity Icon role info, humidity, temperature, value.temperature, value.humidity, sensor.door, sensor.window, thermostat');
|
||||||
break;
|
if (Debug) console.log('CreateEntity ~' + type + 'navigate.' + pageItem.targetPage + '~' + iconId + '~' + iconColor + '~' + name + '~' + optVal + ' ' + unit);
|
||||||
|
return '~' + type + '~' + 'navigate.' + pageItem.targetPage + '~' + iconId + '~' + iconColor + '~' + name + '~' + optVal + ' ' + unit;
|
||||||
|
|
||||||
case 'warning':
|
case 'warning':
|
||||||
iconId = pageItem.icon !== undefined ? Icons.GetIcon(pageItem.icon) : Icons.GetIcon('gesture-tap-button');
|
iconId = pageItem.icon !== undefined ? Icons.GetIcon(pageItem.icon) : Icons.GetIcon('gesture-tap-button');
|
||||||
@@ -3343,7 +3353,7 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean =
|
|||||||
case 'thermostat':
|
case 'thermostat':
|
||||||
type = 'text';
|
type = 'text';
|
||||||
|
|
||||||
iconId = pageItem.icon !== undefined ? Icons.GetIcon(pageItem.icon) : o.common.role == 'temperature' || o.common.role == 'value.temperature' || o.common.role == 'thermostat' ? Icons.GetIcon('thermometer') : Icons.GetIcon('information-outline');
|
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 = '';
|
let unit = '';
|
||||||
optVal = '0';
|
optVal = '0';
|
||||||
@@ -3356,6 +3366,10 @@ function CreateEntity(pageItem: PageItem, placeId: number, useColors: boolean =
|
|||||||
unit = pageItem.unit !== undefined ? pageItem.unit : GetUnitOfMeasurement(pageItem.id + '.ACTUAL');
|
unit = pageItem.unit !== undefined ? pageItem.unit : GetUnitOfMeasurement(pageItem.id + '.ACTUAL');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (o.common.role == 'value.temperature') {
|
||||||
|
iconId = pageItem.icon !== undefined ? Icons.GetIcon(pageItem.icon) : Icons.GetIcon('thermometer');
|
||||||
|
}
|
||||||
|
|
||||||
iconColor = GetIconColor(pageItem, parseInt(optVal), useColors);
|
iconColor = GetIconColor(pageItem, parseInt(optVal), useColors);
|
||||||
|
|
||||||
if (pageItem.colorScale != undefined) {
|
if (pageItem.colorScale != undefined) {
|
||||||
@@ -6919,8 +6933,15 @@ function HandleScreensaverUpdate(): void {
|
|||||||
}
|
}
|
||||||
else if (typeof(val) == 'string') {
|
else if (typeof(val) == 'string') {
|
||||||
iconColor = GetScreenSaverEntityColor(config.leftScreensaverEntity[i]);
|
iconColor = GetScreenSaverEntityColor(config.leftScreensaverEntity[i]);
|
||||||
if (!isNaN(Date.parse(val))) {
|
let pformat = parseFormat(val);
|
||||||
val = formatDate(getDateObject(val), config.leftScreensaverEntity[i].ScreensaverEntityDateFormat);
|
if (Debug) console.log('moments.js --> Datum ' + val + ' valid?: ' + moment(val, pformat, true).isValid());
|
||||||
|
if (moment(val, pformat, true).isValid()) {
|
||||||
|
let DatumZeit = moment(val, pformat).unix(); // Umwandlung in Unix Time-Stamp
|
||||||
|
if (config.leftScreensaverEntity[i].ScreensaverEntityDateFormat !== undefined) {
|
||||||
|
val = new Date(DatumZeit * 1000).toLocaleString(getState(NSPanel_Path + 'Config.locale').val, config.leftScreensaverEntity[i].ScreensaverEntityDateFormat);
|
||||||
|
} else {
|
||||||
|
val = new Date(DatumZeit * 1000).toLocaleString(getState(NSPanel_Path + 'Config.locale').val);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7053,10 +7074,15 @@ function HandleScreensaverUpdate(): void {
|
|||||||
}
|
}
|
||||||
else if (typeof(val) == 'string') {
|
else if (typeof(val) == 'string') {
|
||||||
iconColor = GetScreenSaverEntityColor(config.bottomScreensaverEntity[4]);
|
iconColor = GetScreenSaverEntityColor(config.bottomScreensaverEntity[4]);
|
||||||
if (!isNaN(Date.parse(getState(config.bottomScreensaverEntity[4].ScreensaverEntity).val))) {
|
let pformat = parseFormat(val);
|
||||||
val = formatDate(getDateObject(getState(config.bottomScreensaverEntity[4].ScreensaverEntity).val), config.bottomScreensaverEntity[4].ScreensaverEntityDateFormat);
|
if (Debug) console.log('moments.js --> Datum ' + val + ' valid?: ' + moment(val, pformat, true).isValid());
|
||||||
|
if (moment(val, pformat, true).isValid()) {
|
||||||
|
let DatumZeit = moment(val, pformat).unix(); // Umwandlung in Unix Time-Stamp
|
||||||
|
if (config.bottomScreensaverEntity[4].ScreensaverEntityDateFormat !== undefined) {
|
||||||
|
val = new Date(DatumZeit * 1000).toLocaleString(getState(NSPanel_Path + 'Config.locale').val, config.bottomScreensaverEntity[4].ScreensaverEntityDateFormat);
|
||||||
} else {
|
} else {
|
||||||
val = getState(config.bottomScreensaverEntity[4].ScreensaverEntity).val;
|
val = new Date(DatumZeit * 1000).toLocaleString(getState(NSPanel_Path + 'Config.locale').val);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (existsObject(config.bottomScreensaverEntity[4].ScreensaverEntityIconColor)) {
|
if (existsObject(config.bottomScreensaverEntity[4].ScreensaverEntityIconColor)) {
|
||||||
@@ -7102,10 +7128,18 @@ function HandleScreensaverUpdate(): void {
|
|||||||
}
|
}
|
||||||
else if (typeof(val) == 'string') {
|
else if (typeof(val) == 'string') {
|
||||||
iconColor = GetScreenSaverEntityColor(config.bottomScreensaverEntity[i]);
|
iconColor = GetScreenSaverEntityColor(config.bottomScreensaverEntity[i]);
|
||||||
if (!isNaN(Date.parse(val))) {
|
let pformat = parseFormat(val);
|
||||||
val = formatDate(getDateObject(val), config.bottomScreensaverEntity[i].ScreensaverEntityDateFormat);
|
if (Debug) console.log('moments.js --> Datum ' + val + ' valid?: ' + moment(val, pformat, true).isValid());
|
||||||
|
if (moment(val, pformat, true).isValid()) {
|
||||||
|
let DatumZeit = moment(val, pformat).unix(); // Umwandlung in Unix Time-Stamp
|
||||||
|
if (config.bottomScreensaverEntity[i].ScreensaverEntityDateFormat !== undefined) {
|
||||||
|
val = new Date(DatumZeit * 1000).toLocaleString(getState(NSPanel_Path + 'Config.locale').val, config.bottomScreensaverEntity[i].ScreensaverEntityDateFormat);
|
||||||
|
} else {
|
||||||
|
val = new Date(DatumZeit * 1000).toLocaleString(getState(NSPanel_Path + 'Config.locale').val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (existsObject(config.bottomScreensaverEntity[i].ScreensaverEntityIconColor)) {
|
if (existsObject(config.bottomScreensaverEntity[i].ScreensaverEntityIconColor)) {
|
||||||
iconColor = getState(config.bottomScreensaverEntity[i].ScreensaverEntityIconColor).val;
|
iconColor = getState(config.bottomScreensaverEntity[i].ScreensaverEntityIconColor).val;
|
||||||
}
|
}
|
||||||
@@ -8174,7 +8208,7 @@ type ScreenSaverElement = {
|
|||||||
ScreensaverEntity: string | null,
|
ScreensaverEntity: string | null,
|
||||||
ScreensaverEntityFactor: number | 1,
|
ScreensaverEntityFactor: number | 1,
|
||||||
ScreensaverEntityDecimalPlaces: number | 0,
|
ScreensaverEntityDecimalPlaces: number | 0,
|
||||||
ScreensaverEntityDateFormat: string | null,
|
ScreensaverEntityDateFormat: any | null,
|
||||||
ScreensaverEntityIconOn: string | null,
|
ScreensaverEntityIconOn: string | null,
|
||||||
ScreensaverEntityIconOff: string | null,
|
ScreensaverEntityIconOff: string | null,
|
||||||
ScreensaverEntityText: string | null,
|
ScreensaverEntityText: string | null,
|
||||||
|
|||||||
Reference in New Issue
Block a user