Compare commits

...

4 Commits

Author SHA1 Message Date
Thomas
8d21c653ae Merge pull request #1164 from tt-tom17/patch-tt-tom17
update CardLChart_Influx2.ts
2024-02-06 15:06:58 +01:00
Thomas
d983c44db7 update CardLChart_Influx2.ts
- codeanpassungen
2024-02-06 15:04:13 +01:00
Thomas
467a1d92bb Merge pull request #1163 from tt-tom17/patch-tt-tom17
v4.3.3.41 Update NSPanel.ts
2024-02-06 10:35:45 +01:00
Thomas
157d3e3e66 v4.3.3.41 Update NSPanel.ts
- Fix: activeBrightness -> null
- Fix: bHome -> corrected PageId
2024-02-06 10:32:06 +01:00
3 changed files with 168 additions and 135 deletions

View File

@@ -1,109 +1,130 @@
const Debug = false; /**
* Dieses Script fragt eine influxDb ab, um Daten für die cardLcart (Liniendiagramm) zuberechnen und im richtigen Format bereitzustellen.
* Es erstellt automatisch einen Datenpunkt.
* Die Abfrage muss ggf. angepasst werden. Aktuell ermittelt sie Werte der letzten 24h, zu Stundenwerten zusammengefasst.
*/
const NSPanel_Path = '0_userdata.0.NSPanel.1.'; const Debug = false; // true für erweiterte Ausgaben im Log
const NSPanel_Path = '0_userdata.0.NSPanel.';
const Path = NSPanel_Path + 'Influx2NSPanel.cardLChart.'; const Path = NSPanel_Path + 'Influx2NSPanel.cardLChart.';
const InfluxInstance = 'influxdb.1'; const InfluxInstance = 'influxdb.0';
const influxDbBucket = 'iobroker'; const influxDbBucket = 'storage_short';
const numberOfHoursAgo = 24; const numberOfHoursAgo = 24;
const xAxisTicksEveryM = 60; const xAxisTicksEveryM = 60;
const xAxisLabelEveryM = 240; const xAxisLabelEveryM = 240;
//
// this records holds all sensors and their corresponding states which act as the data source for the charts const sensors : Record<string, Record <string, string>> = {};
// add all sensors which are to be displayed in this script, there is no need to use multiple scripts /**
const sensors : Record<string, string> = {}; * Hier werden die Sensoren festgelegt nach flogendem Schema
/* ↓ Id of the sensor ↓ Id of the data source for the charts */ *
sensors['deconz.0.Sensors.65.temperature'] = Path + 'buero_temperature.ACTUAL'; * sensors[Datenpunkt(kompletter Pfad) des Messwertes'] = {'taget': 'Name des Datenpunkt für die Chartwerte', 'measurement': 'genutzter Alias in der Influxdb für den Messwert'};
sensors['deconz.0.Sensors.65.humidity'] = Path + 'buero_luftfeuchte.ACTUAL'; *
* Wenn der Wert in der Datenbank keinen Alias hat bleibt der Wert 'measurement': weg.
* Jeder Messwert bekommt einen eigenen sensors[...] = {'target':....}
*/
sensors['netatmo-crawler.0.stationData.1.temperature'] = {'target':'AussenTemp', 'measurement':'wetter.temperatur'};
// ##### ab hier keine Änderungen mehr nötig #####
// create data source for NsPanel on script startup // create data source for NsPanel on script startup
Object.keys(sensors).forEach(async x => { Object.keys(sensors).forEach(async id => {
await generateDateAsync(x, sensors[x]); await generateDateAsync(id);
}); });
// then listen to the sensors and update the data source states accordingly // then listen to the sensors and update the data source states accordingly
on({ id: Object.keys(sensors), change: 'any' }, async function (obj) { on({ id: Object.keys(sensors), change: 'any' }, async function (obj) {
if (!obj.id) { if (!obj.id) {
return; return;
} }
await generateDateAsync(obj.id);
await generateDateAsync(obj.id, sensors[obj.id]);
}); });
async function generateDateAsync(sensorId: string, dataPointId: string) { //__________________________
const query =[ // Beschreibe diese Funktion: Daten generieren
'from(bucket: "' + influxDbBucket + '")', async function generateDateAsync(sensorId: string) {
'|> range(start: -' + numberOfHoursAgo + 'h)', let idMeasurement = sensors[sensorId].measurement;
'|> filter(fn: (r) => r["_measurement"] == "' + sensorId + '")', if (idMeasurement =='' ||idMeasurement == undefined) {idMeasurement = sensorId};
'|> filter(fn: (r) => r["_field"] == "value")', const dataPointId:string = Path + sensors[sensorId].target +'.ACTUAL';
'|> drop(columns: ["from", "ack", "q"])', if (Debug) log(`(f) generateDateAsync: ${sensorId} ${dataPointId} > ${idMeasurement}`);
'|> aggregateWindow(every: 1h, fn: last, createEmpty: false)',
'|> map(fn: (r) => ({ r with _rtime: int(v: r._time) - int(v: r._start)}))',
'|> yield(name: "_result")'].join('');
if (Debug) console.log('Query: ' + query); const query =[
'from(bucket: "' + influxDbBucket + '")',
'|> range(start: -' + numberOfHoursAgo + 'h)',
'|> filter(fn: (r) => r["_measurement"] == "' + idMeasurement + '")',
'|> filter(fn: (r) => r["_field"] == "value")',
'|> drop(columns: ["from", "ack", "q"])',
'|> aggregateWindow(every: 1h, fn: last, createEmpty: false)',
'|> map(fn: (r) => ({ r with _rtime: int(v: r._time) - int(v: r._start)}))',
'|> yield(name: "_result")'].join('');
const result : any = await sendToAsync(InfluxInstance, 'query', query); if (Debug) console.log('Query: ' + query);
if (result.error) {
console.error(result.error);
return;
}
if (Debug) console.log(result); const result : any = await sendToAsync(InfluxInstance, 'query', query);
const numResults = result.result.length; if (result.error) {
let coordinates : string = ''; console.error(result.error);
for (let r = 0; r < numResults; r++) return;
{ }
const list : string[] = [] if (Debug) console.log(JSON.stringify(result));
const numValues = result.result[r].length; const numResults = result.result.length;
let coordinates : string = '';
for (let r = 0; r < numResults; r++)
{
const list : string[] = [];
const numValues = result.result[r].length;
for (let i = 0; i < numValues; i++) for (let i = 0; i < numValues; i++)
{ {
const time = Math.round(result.result[r][i]._rtime/1000/1000/1000/60); const time = Math.round(result.result[r][i]._rtime/1000/1000/1000/60);
const value = Math.round(result.result[r][i]._value * 10); const value = Math.round(result.result[r][i]._value * 10);
list.push(time + ":" + value); list.push(time + ":" + value);
} }
coordinates = list.join("~"); coordinates = list.join("~");
if (Debug) console.log(coordinates);
}
if (Debug) console.log(coordinates); const ticksAndLabelsList : string[] = []
} const date = new Date();
date.setMinutes(0, 0, 0);
const ts = Math.round(date.getTime() / 1000);
const tsYesterday = ts - (numberOfHoursAgo * 3600);
if (Debug) console.log('Iterate from ' + tsYesterday + ' to ' + ts + ' stepsize=' + (xAxisTicksEveryM * 60));
for (let x = tsYesterday, i = 0; x < ts; x += (xAxisTicksEveryM * 60), i += xAxisTicksEveryM)
{
if ((i % xAxisLabelEveryM))
ticksAndLabelsList.push('' + i);
else
{
const currentDate = new Date(x * 1000);
// Hours part from the timestamp
const hours = "0" + String(currentDate.getHours());
// Minutes part from the timestamp
const minutes = "0" + String(currentDate.getMinutes());
const formattedTime = hours.slice(-2) + ':' + minutes.slice(-2);
const ticksAndLabelsList : string[] = [] ticksAndLabelsList.push(String(i) + "^" + formattedTime);
const date = new Date(); }
date.setMinutes(0, 0, 0); }
const ts = Math.round(date.getTime() / 1000); if (Debug) console.log('Ticks & Label: ' + ticksAndLabelsList);
const tsYesterday = ts - (numberOfHoursAgo * 3600); if (Debug) console.log('Coordinates: ' + coordinates);
if (Debug) console.log('Iterate from ' + tsYesterday + ' to ' + ts + ' stepsize=' + (xAxisTicksEveryM * 60)); await setOrCreate(dataPointId, ticksAndLabelsList.join("+") + '~' + coordinates, true);
for (let x = tsYesterday, i = 0; x < ts; x += (xAxisTicksEveryM * 60), i += xAxisTicksEveryM)
{
if ((i % xAxisLabelEveryM))
ticksAndLabelsList.push('' + i);
else
{
const currentDate = new Date(x * 1000);
// Hours part from the timestamp
const hours = "0" + String(currentDate.getHours());
// Minutes part from the timestamp
const minutes = "0" + String(currentDate.getMinutes());
const formattedTime = hours.slice(-2) + ':' + minutes.slice(-2);
ticksAndLabelsList.push(String(i) + "^" + formattedTime);
}
}
if (Debug) console.log('Ticks & Label: ' + ticksAndLabelsList);
if (Debug) console.log('Coordinates: ' + coordinates);
await setOrCreate(dataPointId, ticksAndLabelsList.join("+") + '~' + coordinates, true);
} }
//__________________________
// Beschreibe diese Funktion: Datenpunkte anlegen bzw. schreiben
async function setOrCreate(id : string, value : any, ack : boolean) { async function setOrCreate(id : string, value : any, ack : boolean) {
if (!(await existsStateAsync(id))) { if (!(await existsStateAsync(id))) {
await createStateAsync(id, value, { await createStateAsync(id, value, {
name: id.split('.').reverse()[0], name: id.split('.').reverse()[0],
desc: 'Sensor Values [~<time>:<value>]*', desc: 'Sensor Values [~<time>:<value>]*',
type: 'string', type: 'string',
role: 'value', role: 'value',
}); });
} else { } else {
await setStateAsync(id, value, ack); await setStateAsync(id, value, ack);
} }
} }

View File

@@ -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 - 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 @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
@@ -108,7 +108,9 @@ ReleaseNotes:
- 23.01.2024 - v4.3.3.39 Add: Optional setOn & setOff for HW button with mode 'set' - 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 - 28.01.2024 - v4.3.3.39 Fix: ack for read-only state
- 03.02.2024 - v4.3.3.40 Fix: RGB maxValueColorTemp - 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: Todo:
@@ -976,7 +978,7 @@ export const config: Config = {
// _________________________________ DE: Ab hier keine Konfiguration mehr _____________________________________ // _________________________________ DE: Ab hier keine Konfiguration mehr _____________________________________
// _________________________________ EN: No more configuration from here _____________________________________ // _________________________________ 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 tft_version: string = 'v4.3.3';
const desired_display_firmware_version = 53; const desired_display_firmware_version = 53;
const berry_driver_version = 9; const berry_driver_version = 9;
@@ -6485,17 +6487,21 @@ function HandleButtonEvent(words: any): void {
GeneratePage(activePage!); GeneratePage(activePage!);
} }
break; break;
case 'bHome': case 'bHome':
if (Debug) { if (Debug) {
log('HandleButtonEvent -> bHome: ' + words[4] + ' - ' + pageId, 'info'); log('HandleButtonEvent -> bHome: ' + words[4] + ' - ' + pageId, 'info');
} }
UnsubscribeWatcher(); UnsubscribeWatcher();
if (activePage!.home != undefined) { const home = activePage!.home;
GeneratePage(eval(activePage!.home)); if (home !== undefined) {
} else { pageId = config.pages.findIndex(a => a == eval(home))
GeneratePage(config.pages[0]); pageId = pageId === -1 ? 0 : pageId;
} GeneratePage(eval(home));
break; } else {
pageId = 0;
GeneratePage(config.pages[0]);
}
break;
case 'notifyAction': case 'notifyAction':
if (words[4] == 'yes') { if (words[4] == 'yes') {
setState(popupNotifyInternalName, <iobJS.State>{ val: words[2], ack: true }); setState(popupNotifyInternalName, <iobJS.State>{ val: words[2], ack: true });

View File

@@ -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 - 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 @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
@@ -108,7 +108,9 @@ ReleaseNotes:
- 23.01.2024 - v4.3.3.39 Add: Optional setOn & setOff for HW button with mode 'set' - 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 - 28.01.2024 - v4.3.3.39 Fix: ack for read-only state
- 03.02.2024 - v4.3.3.40 Fix: RGB maxValueColorTemp - 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: Todo:
@@ -976,7 +978,7 @@ export const config: Config = {
// _________________________________ DE: Ab hier keine Konfiguration mehr _____________________________________ // _________________________________ DE: Ab hier keine Konfiguration mehr _____________________________________
// _________________________________ EN: No more configuration from here _____________________________________ // _________________________________ 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 tft_version: string = 'v4.3.3';
const desired_display_firmware_version = 53; const desired_display_firmware_version = 53;
const berry_driver_version = 9; const berry_driver_version = 9;
@@ -1516,11 +1518,11 @@ InitActiveBrightness();
on({id: [NSPanel_Path + 'ScreensaverInfo.activeBrightness'], change: 'ne'}, async function (obj) { on({id: [NSPanel_Path + 'ScreensaverInfo.activeBrightness'], change: 'ne'}, async function (obj) {
try { 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) { if (obj.state.val >= 0 || obj.state.val <= 100) {
log('action at trigger activeBrightness: ' + obj.state.val + ' - activeDimmodeBrightness: ' + active, 'info'); 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(); InitDimmode();
} }
} catch (err:any) { } catch (err:any) {
log('error at trigger activeBrightness: ' + err.message, 'warn'); 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) { on({id: [NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness'], change: "ne"}, async function (obj) {
try { 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 != null && obj.state.val != -1) {
if (obj.state.val < -1 || obj.state.val > 100) { if (obj.state.val < -1 || obj.state.val > 100) {
log('activeDimmodeBrightness value only between -1 and 100', 'info'); 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) { on({id: String(NSPanel_Path) + 'ScreensaverInfo.Trigger_Dimmode', change: "ne"}, async function (obj) {
try { try {
let active = getState(NSPanel_Path + 'ScreensaverInfo.activeBrightness').val; let active = getState(NSPanel_Path + 'ScreensaverInfo.activeBrightness').val ?? 80;
if (obj.state.val) { 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 { } else {
@@ -1910,8 +1912,8 @@ on({id: [NSPanel_Path + 'PageNavi'], change: "any"}, async function (obj) {
//----------------------Begin Dimmode //----------------------Begin Dimmode
function ScreensaverDimmode(timeDimMode:NSPanel.DimMode) { function ScreensaverDimmode(timeDimMode:NSPanel.DimMode) {
try { try {
let active = getState(NSPanel_Path + 'ScreensaverInfo.activeBrightness').val let active = getState(NSPanel_Path + 'ScreensaverInfo.activeBrightness').val ?? 80
let dimmode = getState(NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness').val let dimmode = getState(NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness').val ?? -1
if (Debug) { if (Debug) {
log('function ScreensaverDimmode RGB-Wert HMIDark' + rgb_dec565(HMIDark), 'info'); log('function ScreensaverDimmode RGB-Wert HMIDark' + rgb_dec565(HMIDark), 'info');
} }
@@ -2018,12 +2020,12 @@ async function InitDimmode() {
ScreensaverDimmode(timeDimMode); ScreensaverDimmode(timeDimMode);
}); });
if (getState(NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness').val != null && getState(NSPanel_Path + 'ScreensaverInfo.activeDimmodeBrightness').val != -1) { 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 { } else {
if (isDimTimeInRange(timeDimMode.timeDay,timeDimMode.timeNight)) { 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 { } 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); ScreensaverDimmode(timeDimMode);
} }
@@ -6485,17 +6487,21 @@ function HandleButtonEvent(words: any): void {
GeneratePage(activePage!); GeneratePage(activePage!);
} }
break; break;
case 'bHome': case 'bHome':
if (Debug) { if (Debug) {
log('HandleButtonEvent -> bHome: ' + words[4] + ' - ' + pageId, 'info'); log('HandleButtonEvent -> bHome: ' + words[4] + ' - ' + pageId, 'info');
} }
UnsubscribeWatcher(); UnsubscribeWatcher();
if (activePage!.home != undefined) { const home = activePage!.home;
GeneratePage(eval(activePage!.home)); if (home !== undefined) {
} else { pageId = config.pages.findIndex(a => a == eval(home))
GeneratePage(config.pages[0]); pageId = pageId === -1 ? 0 : pageId;
} GeneratePage(eval(home));
break; } else {
pageId = 0;
GeneratePage(config.pages[0]);
}
break;
case 'notifyAction': case 'notifyAction':
if (words[4] == 'yes') { if (words[4] == 'yes') {
setState(popupNotifyInternalName, <iobJS.State>{ val: words[2], ack: true }); setState(popupNotifyInternalName, <iobJS.State>{ 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 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' | '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' | 'cie' | 'gate' | 'motion' | 'buttonSensor' | 'button' | 'value.time' | 'level.timer' | 'value.alarmtime' | 'level.mode.fan' | 'lock' | 'slider'
| 'switch.mode.wlan' | 'media' | 'timeTable' | 'airCondition' | 'switch.mode.wlan' | 'media' | 'timeTable' | 'airCondition'