Merge branch 'main' of github.com:joBr99/nspanel-lovelace-ui

This commit is contained in:
joBr99
2023-04-25 23:39:59 +02:00
11 changed files with 398 additions and 275 deletions

View File

@@ -1302,7 +1302,46 @@
│ tSend.txt="event,buttonPress2,"+entn.txt+","+"OnOff,"
│ covx btOnOff1.val,tTmp.txt,0,0
│ tSend.txt+=tTmp.txt
│ @@ -401,63 +473,48 @@
│ @@ -345,38 +417,14 @@
│ Period (ms): 100
│ Enabled : no
│ Events
│ Timer Event
│ tmCooldown.en=0
│ -Timer tmDrawCooldown
│ - Attributes
│ - Scope : local
│ - Period (ms): 500
│ - Enabled : no
│ -
│ - Events
│ - Timer Event
│ - //draw black background
│ - fill hBrightness.x,hBrightness.y,100,hBrightness.val*-25/10+250,8484
│ - //draw draw colored bar at the position of the current brightness value
│ - fill hBrightness.x,hBrightness.val*-25/10+314,100,hBrightness.val*25/10,col.val
│ - if(hBrightness.val>7)
│ - {
│ - //draw cursor
│ - fill hBrightness.x+25,hBrightness.val*-25/10+322,50,4,WHITE
│ - //paint corner
│ - xstr hBrightness.x,hBrightness.val*-25/10+314,100,hBrightness.h,7,8484,0,0,0,3,"a"
│ - }
│ - //paint corners
│ - xstr hBrightness.x,hBrightness.y,100,hBrightness.h,7,defaultBcoColor,0,0,0,3,"a"
│ - xstr hBrightness.x,hBrightness.y+hBrightness.h-15,100,hBrightness.h,7,defaultBcoColor,0,0,0,3,"b"
│ - tmDrawCooldown.en=0
│ -
│ Timer tmSerial
│ Attributes
│ Scope : local
│ Period (ms): 50
│ Enabled : yes
│ Events
│ @@ -425,48 +473,48 @@
│ // write instruction to tInstuction (debug output, but used as variable here, ui elements will be disabled by default)
│ spstr strCommand.txt,tInstruction.txt,"~",0
│ spstr strCommand.txt,tTmp.txt,"~",1
@@ -1339,25 +1378,13 @@
│ + vis t2,1
│ vis hBrightness,1
│ covx tTmp.txt,sys0,0,0
│ - if(tmCooldown.en==0&&hBrightness.val!=sys0)
│ - hBrightness.val=sys0
│ - tmDrawCooldown.en=1
│ - tmDrawCooldown.tim=500
│ + if(tmCooldown.en==0)
{
hBrightness.val=sys0
- //draw black background
│ - fill hBrightness.x,hBrightness.y,100,hBrightness.val*-25/10+250,8484
│ - //draw draw colored bar at the position of the current brightness value
│ - fill hBrightness.x,hBrightness.val*-25/10+314,100,hBrightness.val*25/10,col.val
│ - if(hBrightness.val>7)
│ - {
│ - //draw cursor
│ - fill hBrightness.x+25,hBrightness.val*-25/10+322,50,4,WHITE
│ - //paint corner
│ - xstr hBrightness.x,hBrightness.val*-25/10+314,100,hBrightness.h,7,8484,0,0,0,3,"a"
│ - }
│ - //paint corners
│ - xstr hBrightness.x,hBrightness.y,100,hBrightness.h,7,defaultBcoColor,0,0,0,3,"a"
│ - xstr hBrightness.x,hBrightness.y+hBrightness.h-15,100,hBrightness.h,7,defaultBcoColor,0,0,0,3,"b"
│ }
+ {
+ hBrightness.val=sys0
+ }
│ }
│ // get ColorTemp value
│ spstr strCommand.txt,tTmp.txt,"~",6
@@ -1375,7 +1402,7 @@
│ // switch mode
│ click bColor,1
│ click bColor,0
│ @@ -472,16 +529,16 @@
│ @@ -481,16 +529,16 @@
│ click bColor,1
│ click bColor,0
│ }
@@ -1394,7 +1421,7 @@
│ }
│ // mode == 0 is rgb controls currently shown
│ if(mode.val==0)
│ @@ -492,36 +549,36 @@
│ @@ -501,36 +549,36 @@
│ }
│ }
│ // get Color value

View File

@@ -2677,7 +2677,46 @@
│ tSend.txt="event,buttonPress2,"+entn.txt+","+"OnOff,"
│ covx btOnOff1.val,tTmp.txt,0,0
│ tSend.txt+=tTmp.txt
│ @@ -401,63 +473,48 @@
│ @@ -345,38 +417,14 @@
│ Period (ms): 100
│ Enabled : no
│ Events
│ Timer Event
│ tmCooldown.en=0
│ -Timer tmDrawCooldown
│ - Attributes
│ - Scope : local
│ - Period (ms): 500
│ - Enabled : no
│ -
│ - Events
│ - Timer Event
│ - //draw black background
│ - fill hBrightness.x,hBrightness.y,100,hBrightness.val*-25/10+250,8484
│ - //draw draw colored bar at the position of the current brightness value
│ - fill hBrightness.x,hBrightness.val*-25/10+314,100,hBrightness.val*25/10,col.val
│ - if(hBrightness.val>7)
│ - {
│ - //draw cursor
│ - fill hBrightness.x+25,hBrightness.val*-25/10+322,50,4,WHITE
│ - //paint corner
│ - xstr hBrightness.x,hBrightness.val*-25/10+314,100,hBrightness.h,7,8484,0,0,0,3,"a"
│ - }
│ - //paint corners
│ - xstr hBrightness.x,hBrightness.y,100,hBrightness.h,7,defaultBcoColor,0,0,0,3,"a"
│ - xstr hBrightness.x,hBrightness.y+hBrightness.h-15,100,hBrightness.h,7,defaultBcoColor,0,0,0,3,"b"
│ - tmDrawCooldown.en=0
│ -
│ Timer tmSerial
│ Attributes
│ Scope : local
│ Period (ms): 50
│ Enabled : yes
│ Events
│ @@ -425,48 +473,48 @@
│ // write instruction to tInstuction (debug output, but used as variable here, ui elements will be disabled by default)
│ spstr strCommand.txt,tInstruction.txt,"~",0
│ spstr strCommand.txt,tTmp.txt,"~",1
@@ -2714,25 +2753,13 @@
│ + vis t2,1
│ vis hBrightness,1
│ covx tTmp.txt,sys0,0,0
│ - if(tmCooldown.en==0&&hBrightness.val!=sys0)
│ - hBrightness.val=sys0
│ - tmDrawCooldown.en=1
│ - tmDrawCooldown.tim=500
│ + if(tmCooldown.en==0)
{
hBrightness.val=sys0
- //draw black background
│ - fill hBrightness.x,hBrightness.y,100,hBrightness.val*-25/10+250,8484
│ - //draw draw colored bar at the position of the current brightness value
│ - fill hBrightness.x,hBrightness.val*-25/10+314,100,hBrightness.val*25/10,col.val
│ - if(hBrightness.val>7)
│ - {
│ - //draw cursor
│ - fill hBrightness.x+25,hBrightness.val*-25/10+322,50,4,WHITE
│ - //paint corner
│ - xstr hBrightness.x,hBrightness.val*-25/10+314,100,hBrightness.h,7,8484,0,0,0,3,"a"
│ - }
│ - //paint corners
│ - xstr hBrightness.x,hBrightness.y,100,hBrightness.h,7,defaultBcoColor,0,0,0,3,"a"
│ - xstr hBrightness.x,hBrightness.y+hBrightness.h-15,100,hBrightness.h,7,defaultBcoColor,0,0,0,3,"b"
│ }
+ {
+ hBrightness.val=sys0
+ }
│ }
│ // get ColorTemp value
│ spstr strCommand.txt,tTmp.txt,"~",6
@@ -2750,7 +2777,7 @@
│ // switch mode
│ click bColor,1
│ click bColor,0
│ @@ -472,16 +529,16 @@
│ @@ -481,16 +529,16 @@
│ click bColor,1
│ click bColor,0
│ }
@@ -2769,7 +2796,7 @@
│ }
│ // mode == 0 is rgb controls currently shown
│ if(mode.val==0)
│ @@ -492,36 +549,36 @@
│ @@ -501,36 +549,36 @@
│ }
│ }
│ // get Color value

View File

@@ -1,4 +1,4 @@
+++ /dev/fd/62 2023-04-18 22:17:40.643093312 +0000
+++ /dev/fd/62 2023-04-19 16:16:22.100652931 +0000
+I/n2t-out/Program.s.txt
++ HMI/US/portrait/n2t-out/Program.s.txt
+1 +10,10 @@
@@ -57,13 +57,13 @@
+ributes
+ Scope : local
+ Text :
+ Max. Text Size: 80
+ Max. Text Size: 40
+
+e (string) nent2
+ributes
+ Scope : local
+ Text :
+ Max. Text Size: 80
+ Max. Text Size: 40
+14 +186,26 @@
+e (string) type6
@@ -1483,9 +1483,6 @@
+ Associated Keyboard: none
+ Text : newtxt
+ Max. Text Size : 100
+ Scope : local
+ Dragging : 0
+ Disable release event after dragging: 0
+ Send Component ID : disabled
+ Associated Keyboard : none
+ Text : newtxt
@@ -1541,6 +1538,9 @@
+ State : unpressed
+ Text : startup
+ Max. Text Size : 10
+ Scope : local
+ Dragging : 0
+ Disable release event after dragging: 0
+ Send Component ID : disabled
+ State : unpressed
+ Text : startup
@@ -2067,7 +2067,46 @@
+ tSend.txt="event,buttonPress2,"+entn.txt+","+"OnOff,"
+ covx btOnOff1.val,tTmp.txt,0,0
+ tSend.txt+=tTmp.txt
+63 +473,48 @@
+38 +417,14 @@
+ Period (ms): 100
+ Enabled : no
+
+nts
+ Timer Event
+ tmCooldown.en=0
+
+mDrawCooldown
+ributes
+ Scope : local
+ Period (ms): 500
+ Enabled : no
+
+nts
+ Timer Event
+ //draw black background
+ fill hBrightness.x,hBrightness.y,100,hBrightness.val*-25/10+250,8484
+ //draw draw colored bar at the position of the current brightness value
+ fill hBrightness.x,hBrightness.val*-25/10+314,100,hBrightness.val*25/10,col.val
+ if(hBrightness.val>7)
+ {
+ //draw cursor
+ fill hBrightness.x+25,hBrightness.val*-25/10+322,50,4,WHITE
+ //paint corner
+ xstr hBrightness.x,hBrightness.val*-25/10+314,100,hBrightness.h,7,8484,0,0,0,3,"a"
+ }
+ //paint corners
+ xstr hBrightness.x,hBrightness.y,100,hBrightness.h,7,defaultBcoColor,0,0,0,3,"a"
+ xstr hBrightness.x,hBrightness.y+hBrightness.h-15,100,hBrightness.h,7,defaultBcoColor,0,0,0,3,"b"
+ tmDrawCooldown.en=0
+
+mSerial
+ributes
+ Scope : local
+ Period (ms): 50
+ Enabled : yes
+
+nts
+48 +473,48 @@
+ // write instruction to tInstuction (debug output, but used as variable here, ui elements will be disabled by default)
+ spstr strCommand.txt,tInstruction.txt,"~",0
+ spstr strCommand.txt,tTmp.txt,"~",1
@@ -2104,24 +2143,12 @@
+ vis t2,1
+ vis hBrightness,1
+ covx tTmp.txt,sys0,0,0
+ if(tmCooldown.en==0&&hBrightness.val!=sys0)
+ hBrightness.val=sys0
+ tmDrawCooldown.en=1
+ tmDrawCooldown.tim=500
+ if(tmCooldown.en==0)
+ {
+ hBrightness.val=sys0
+ //draw black background
+ fill hBrightness.x,hBrightness.y,100,hBrightness.val*-25/10+250,8484
+ //draw draw colored bar at the position of the current brightness value
+ fill hBrightness.x,hBrightness.val*-25/10+314,100,hBrightness.val*25/10,col.val
+ if(hBrightness.val>7)
+ {
+ //draw cursor
+ fill hBrightness.x+25,hBrightness.val*-25/10+322,50,4,WHITE
+ //paint corner
+ xstr hBrightness.x,hBrightness.val*-25/10+314,100,hBrightness.h,7,8484,0,0,0,3,"a"
+ }
+ //paint corners
+ xstr hBrightness.x,hBrightness.y,100,hBrightness.h,7,defaultBcoColor,0,0,0,3,"a"
+ xstr hBrightness.x,hBrightness.y+hBrightness.h-15,100,hBrightness.h,7,defaultBcoColor,0,0,0,3,"b"
+ }
+ }
+ // get ColorTemp value

View File

@@ -10,10 +10,6 @@ pageTest
27 Component(s)
68 Line(s) of event code
66 Unique line(s) of event code
popupLight
22 Component(s)
406 Line(s) of event code
214 Unique line(s) of event code
popupNotify
19 Component(s)
263 Line(s) of event code
@@ -34,6 +30,10 @@ screensaver2
59 Component(s)
354 Line(s) of event code
251 Unique line(s) of event code
popupLight
23 Component(s)
406 Line(s) of event code
207 Unique line(s) of event code
cardChart
33 Component(s)
433 Line(s) of event code
@@ -89,6 +89,6 @@ cardEntities
Total
21 Page(s)
799 Component(s)
800 Component(s)
9262 Line(s) of event code
2348 Unique line(s) of event code
2343 Unique line(s) of event code

View File

@@ -511,6 +511,31 @@ Timer tmCooldown
Timer Event
tmCooldown.en=0
Timer tmDrawCooldown
Attributes
ID : 22
Scope : local
Period (ms): 500
Enabled : no
Events
Timer Event
//draw black background
fill hBrightness.x,hBrightness.y,100,hBrightness.val*-25/10+250,8484
//draw draw colored bar at the position of the current brightness value
fill hBrightness.x,hBrightness.val*-25/10+314,100,hBrightness.val*25/10,col.val
if(hBrightness.val>7)
{
//draw cursor
fill hBrightness.x+25,hBrightness.val*-25/10+322,50,4,WHITE
//paint corner
xstr hBrightness.x,hBrightness.val*-25/10+314,100,hBrightness.h,7,8484,0,0,0,3,"a"
}
//paint corners
xstr hBrightness.x,hBrightness.y,100,hBrightness.h,7,defaultBcoColor,0,0,0,3,"a"
xstr hBrightness.x,hBrightness.y+hBrightness.h-15,100,hBrightness.h,7,defaultBcoColor,0,0,0,3,"b"
tmDrawCooldown.en=0
Timer tmSerial
Attributes
ID : 8
@@ -591,24 +616,9 @@ Timer tmSerial
//vis t2,1
vis hBrightness,1
covx tTmp.txt,sys0,0,0
if(tmCooldown.en==0&&hBrightness.val!=sys0)
{
hBrightness.val=sys0
//draw black background
fill hBrightness.x,hBrightness.y,100,hBrightness.val*-25/10+250,8484
//draw draw colored bar at the position of the current brightness value
fill hBrightness.x,hBrightness.val*-25/10+314,100,hBrightness.val*25/10,col.val
if(hBrightness.val>7)
{
//draw cursor
fill hBrightness.x+25,hBrightness.val*-25/10+322,50,4,WHITE
//paint corner
xstr hBrightness.x,hBrightness.val*-25/10+314,100,hBrightness.h,7,8484,0,0,0,3,"a"
}
//paint corners
xstr hBrightness.x,hBrightness.y,100,hBrightness.h,7,defaultBcoColor,0,0,0,3,"a"
xstr hBrightness.x,hBrightness.y+hBrightness.h-15,100,hBrightness.h,7,defaultBcoColor,0,0,0,3,"b"
}
hBrightness.val=sys0
tmDrawCooldown.en=1
tmDrawCooldown.tim=500
}
// get ColorTemp value
spstr strCommand.txt,tTmp.txt,"~",6

View File

@@ -349,6 +349,30 @@ Timer tmCooldown
Timer Event
tmCooldown.en=0
Timer tmDrawCooldown
Attributes
Scope : local
Period (ms): 500
Enabled : no
Events
Timer Event
//draw black background
fill hBrightness.x,hBrightness.y,100,hBrightness.val*-25/10+250,8484
//draw draw colored bar at the position of the current brightness value
fill hBrightness.x,hBrightness.val*-25/10+314,100,hBrightness.val*25/10,col.val
if(hBrightness.val>7)
{
//draw cursor
fill hBrightness.x+25,hBrightness.val*-25/10+322,50,4,WHITE
//paint corner
xstr hBrightness.x,hBrightness.val*-25/10+314,100,hBrightness.h,7,8484,0,0,0,3,"a"
}
//paint corners
xstr hBrightness.x,hBrightness.y,100,hBrightness.h,7,defaultBcoColor,0,0,0,3,"a"
xstr hBrightness.x,hBrightness.y+hBrightness.h-15,100,hBrightness.h,7,defaultBcoColor,0,0,0,3,"b"
tmDrawCooldown.en=0
Timer tmSerial
Attributes
Scope : local
@@ -428,24 +452,9 @@ Timer tmSerial
//vis t2,1
vis hBrightness,1
covx tTmp.txt,sys0,0,0
if(tmCooldown.en==0&&hBrightness.val!=sys0)
{
hBrightness.val=sys0
//draw black background
fill hBrightness.x,hBrightness.y,100,hBrightness.val*-25/10+250,8484
//draw draw colored bar at the position of the current brightness value
fill hBrightness.x,hBrightness.val*-25/10+314,100,hBrightness.val*25/10,col.val
if(hBrightness.val>7)
{
//draw cursor
fill hBrightness.x+25,hBrightness.val*-25/10+322,50,4,WHITE
//paint corner
xstr hBrightness.x,hBrightness.val*-25/10+314,100,hBrightness.h,7,8484,0,0,0,3,"a"
}
//paint corners
xstr hBrightness.x,hBrightness.y,100,hBrightness.h,7,defaultBcoColor,0,0,0,3,"a"
xstr hBrightness.x,hBrightness.y+hBrightness.h-15,100,hBrightness.h,7,defaultBcoColor,0,0,0,3,"b"
}
hBrightness.val=sys0
tmDrawCooldown.en=1
tmDrawCooldown.tim=500
}
// get ColorTemp value
spstr strCommand.txt,tTmp.txt,"~",6

View File

@@ -6898,6 +6898,7 @@ icons = {
}
import apis
import re
def get_icon_id(ma_name):
if isinstance(ma_name, re.Match):

View File

@@ -29,7 +29,8 @@ def lookup(path_frontend_file, path_backend_file, lookupstr):
if k in res:
res = res[k]
if type(res) is not str:
res = "error_tnf"
#res = "error_tnf"
res = lookupstr.split(".")[-1]
return res
def get_translation(locale, lookupstr):

View File

@@ -655,8 +655,8 @@ class LuiPagesGen(object):
speed = 0
if apis.ha_api.entity_exists(item.entityId):
entity = apis.ha_api.get_entity(item.entityId)
if float(entity.state) > 0:
speed = str(item.entity_input_config.get("speed", 1))
speed = str(item.entity_input_config.get("speed", 0))
if isinstance(speed, str):
speed = apis.ha_api.render_template(speed)
command += f"~{speed}"
self._send_mqtt_msg(command)

View File

@@ -1,6 +1,6 @@
/*-----------------------------------------------------------------------
TypeScript v4.0.5.7 zur Steuerung des SONOFF NSPanel mit dem ioBroker by @Armilar / @Sternmiere / @Britzelpuf / @ravenS0ne / @TT-Tom
- abgestimmt auf TFT 50 / v4.0.5 / BerryDriver 8 / Tasmota 12.4.0
TypeScript v4.0.5.10 zur Steuerung des SONOFF NSPanel mit dem ioBroker by @Armilar / @Sternmiere / @Britzelpuf / @ravenS0ne / @TT-Tom
- abgestimmt auf TFT 50 / v4.0.5 / BerryDriver 8 / Tasmota 12.5.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
icon_mapping.ts: https://github.com/joBr99/nspanel-lovelace-ui/blob/main/ioBroker/icon_mapping.ts (TypeScript muss in global liegen)
@@ -131,7 +131,10 @@ ReleaseNotes:
- 09.04.2023 - v4.0.5.5 Fix trigger popupNotifypage
- 11.04.2023 - v4.0.5.6 Fix function InitDimmode
- 18.04.2023 - v4.0.5.7 Fix Function check_updates
- 20.04.2023 - v4.0.5.8 Fix Layout Update message for TFT, Berry-Driver and Tasmota
- 21.04.2023 - v4.0.5.9 Add Parameter pageitem id0 to ActivePages (0_userdata)
- 23.04.2023 - v4.0.5.10 v4.0.5.10 Fixed error wrong icon index in GeneratePowerPage by fre4242
***********************************************************************************************************
* Für die Erstellung der Aliase durch das Skript, muss in der JavaScript Instanz "setObect" gesetzt sein! *
***********************************************************************************************************
@@ -223,6 +226,7 @@ Upgrades in Konsole:
TFT EU STABLE Version : FlashNextion http://nspanel.pky.eu/lovelace-ui/github/nspanel-v4.0.5.tft
---------------------------------------------------------------------------------------
*/
let Icons = new IconsSelector();
let timeoutSlider: any;
let vwIconColor = [];
@@ -1128,7 +1132,7 @@ export const config = <Config> {
ScreensaverEntityUnitText: '°',
ScreensaverEntityIconColor: White
},
// bottomScreensaverEntity 5 (only Advanced Screensaver)
// bottomScreensaverEntity 5 (for Alternative and Advanced Screensaver)
{
ScreensaverEntity: 'accuweather.0.Current.RelativeHumidity',
ScreensaverEntityFactor: 1,
@@ -1301,7 +1305,6 @@ export const config = <Config> {
}
};
// _________________________________ Ab hier keine Konfiguration mehr _____________________________________
const request = require('request');
@@ -1527,6 +1530,9 @@ async function Init_ActivePageData() {
if (existsState(NSPanel_Path + 'ActivePage.type') == false ) {
await createStateAsync(NSPanel_Path + 'ActivePage.type', '', true, { type: 'string' });
}
if (existsState(NSPanel_Path + 'ActivePage.id0') == false ) {
await createStateAsync(NSPanel_Path + 'ActivePage.id0', '', true, { type: 'string' });
}
} catch (err) {
console.warn('error at function Init_ActivePageData: ' + err.message);
}
@@ -2116,10 +2122,10 @@ async function InitPopupNotify() {
let notification: string;
let v_popupNotifyHeadingColor = (getState(popupNotifyHeadingColor).val != null) ? getState(popupNotifyHeadingColor).val : '65504'// Farbe Headline - gelb 65504
let v_popupNotifyButton1TextColor = (getState(popupNotifyButton1TextColor).val != null) ? getState(popupNotifyButton1TextColor).val : '63488'// Farbe Headline - gelb 65504
let v_popupNotifyButton2TextColor = (getState(popupNotifyButton2TextColor).val != null) ? getState(popupNotifyButton2TextColor).val : '2016'// Farbe Headline - gelb 65504
let v_popupNotifyTextColor = (getState(popupNotifyTextColor).val != null) ? getState(popupNotifyTextColor).val : '65535'// Farbe Headline - gelb 65504
let v_popupNotifyIconColor = (getState(popupNotifyIconColor).val != null) ? getState(popupNotifyIconColor).val : '65535'// Farbe Headline - gelb 65504
let v_popupNotifyButton1TextColor = (getState(popupNotifyButton1TextColor).val != null) ? getState(popupNotifyButton1TextColor).val : '63488'// Farbe Button 1 - rot 63488
let v_popupNotifyButton2TextColor = (getState(popupNotifyButton2TextColor).val != null) ? getState(popupNotifyButton2TextColor).val : '2016'// Farbe Button 2 - grün 2016
let v_popupNotifyTextColor = (getState(popupNotifyTextColor).val != null) ? getState(popupNotifyTextColor).val : '65535'// Farbe Text - weiss 65535
let v_popupNotifyIconColor = (getState(popupNotifyIconColor).val != null) ? getState(popupNotifyIconColor).val : '65535'// Farbe Icon - weiss 65535
let v_popupNotifyFontIdText = (getState(popupNotifyFontIdText).val != null) ? getState(popupNotifyFontIdText).val : '1'
let v_popupNotifyIcon = (getState(popupNotifyIcon).val != null) ? getState(popupNotifyIcon).val : 'alert'
@@ -2286,9 +2292,22 @@ function get_locales() {
async function check_updates() {
try {
if (Debug) {
console.log('Check-Updates');
}
if (Debug) console.log('Check-Updates');
let Update: boolean = false;
let InternalName: string = '';
let Headline: string = '';
let Text: string = '';
const HeadlineColor: string = '63488'; // Farbe Rot
const Button1: string = 'Nein';
const Button1Color: string = '63488'; // Farbe Rot
const Button2: string = 'Ja';
const Button2Color: string = '2016'; // Farbe Grün
const Timeout: number = 0;
const Layout: number = 1;
// Tasmota-Firmware-Vergleich
if (existsObject(NSPanel_Path + 'Tasmota_Firmware.currentVersion') && existsObject(NSPanel_Path + 'Tasmota_Firmware.onlineVersion')) {
let splitTasmotaVersion = (getState(NSPanel_Path + 'Tasmota_Firmware.currentVersion').val).split('.');
@@ -2296,9 +2315,9 @@ async function check_updates() {
if (shortTasmoataVersion !== getState(NSPanel_Path + 'Tasmota_Firmware.onlineVersion').val) {
if (existsState(NSPanel_Path + 'NSPanel_autoUpdate')) {
if (getState(NSPanel_Path + 'NSPanel_autoUpdate').val) {
if (Debug) {
console.log('Auto-Updates eingeschaltet - Update wird durchgeführt');
}
if (Debug) console.log('Auto-Updates eingeschaltet - Update Tasmota wird durchgeführt');
// Tasmota Upgrade durchführen
update_tasmota_firmware();
// Aktuelle Tasmota Version = Online Tasmota Version
@@ -2306,29 +2325,16 @@ async function check_updates() {
await setStateAsync(NSPanel_Path + 'Tasmota_Firmware.currentVersion', <iobJS.State>{ val: getState(NSPanel_Path + 'Tasmota_Firmware.onlineVersion').val, ack: true });
} else {
// Auf Tasmota-Updates hinweisen
if (Debug) {
console.log('Automatische Updates aus');
}
if (Debug) console.log('Tasmota-Firmware => Automatische Updates aus, manuelles Update nötig');
const InternalName = 'TasmotaFirmwareUpdate';
const Headline = 'Tasmota-Firmware Update';
const Text = ['Es ist eine neue Version der Tasmota-Firmware', '\r\n', 'verfügbar', '\r\n', '\r\n', 'Installierte Version: ' + String(getState((String(NSPanel_Path) + 'Tasmota_Firmware.currentVersion')).val), '\r\n', 'Verfügbare Version: ' + String(getState((String(NSPanel_Path) + 'Tasmota_Firmware.onlineVersion')).val), '\r\n', '\r\n', 'Upgrade durchführen?'].join('');
const Button1 = 'Nein';
const Button2 = 'Ja';
const Timeout = 0;
await setStateAsync(popupNotifyHeading, <iobJS.State>{ val: Headline, ack: false });
await setStateAsync(popupNotifyButton1Text, <iobJS.State>{ val: Button1, ack: false });
await setStateAsync(popupNotifyButton2Text, <iobJS.State>{ val: Button2, ack: false });
await setStateAsync(popupNotifySleepTimeout, <iobJS.State>{ val: Timeout, ack: false });
await setStateAsync(popupNotifyInternalName, <iobJS.State>{ val: InternalName, ack: false });
await setStateAsync(popupNotifyText, <iobJS.State>{ val: [formatDate(getDateObject((new Date().getTime())), 'TT.MM.JJJJ SS:mm:ss'), '\r\n', '\r\n', Text].join(''), ack: false });
InternalName = 'TasmotaFirmwareUpdate';
Headline = 'Tasmota-Firmware Update';
Text = ['Es ist eine neue Version der Tasmota-Firmware', '\r\n', 'verfügbar', '\r\n', '\r\n', 'Installierte Version: ' + String(getState((String(NSPanel_Path) + 'Tasmota_Firmware.currentVersion')).val), '\r\n', 'Verfügbare Version: ' + String(getState((String(NSPanel_Path) + 'Tasmota_Firmware.onlineVersion')).val), '\r\n', '\r\n', 'Upgrade durchführen?'].join('');
Update = true;
}
}
} else {
if (Debug) {
console.log('Tasmota-Version auf NSPanel aktuell');
}
if (Debug) console.log('Tasmota-Version auf NSPanel aktuell');
}
}
@@ -2337,39 +2343,28 @@ async function check_updates() {
if (parseFloat(getState(NSPanel_Path + 'Berry_Driver.currentVersion').val) < berry_driver_version) {
if (existsState(NSPanel_Path + 'NSPanel_autoUpdate')) {
if (getState(NSPanel_Path + 'NSPanel_autoUpdate').val) {
if (Debug) console.log('Auto-Updates eingeschaltet - Update Berry-Driver wird durchgeführt');
// 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', <iobJS.State>{ val: getState(NSPanel_Path + 'Berry_Driver.onlineVersion').val, ack: true });
if (Debug) {
console.log('Berry-Driver automatisch aktualisiert');
}
if (Debug) console.log('Berry-Driver automatisch aktualisiert');
} else {
//Auf BerryDriver-Update hinweisen
if (Debug) {
console.log('Automatische Updates aus');
}
if (Debug) console.log('Berry-Driver => Automatische Updates aus, manuelles Update nötig');
const InternalName = 'BerryDriverUpdate';
const Headline = 'Berry-Driver Update';
const Text = ['Es ist eine neue Version des Berry-Drivers', '\r\n', '(Tasmota) verfügbar', '\r\n', '\r\n', 'Installierte Version: ' + String(getState((String(NSPanel_Path) + 'Berry_Driver.currentVersion')).val), '\r\n', 'Verfügbare Version: ' + String(berry_driver_version), '\r\n', '\r\n', 'Upgrade durchführen?'].join('');
const Button1 = 'Nein';
const Button2 = 'Ja';
const Timeout = 0;
await setStateAsync(popupNotifyHeading, <iobJS.State>{ val: Headline, ack: false });
await setStateAsync(popupNotifyButton1Text, <iobJS.State>{ val: Button1, ack: false });
await setStateAsync(popupNotifyButton2Text, <iobJS.State>{ val: Button2, ack: false });
await setStateAsync(popupNotifySleepTimeout, <iobJS.State>{ val: Timeout, ack: false });
await setStateAsync(popupNotifyInternalName, <iobJS.State>{ val: InternalName, ack: false });
await setStateAsync(popupNotifyText, <iobJS.State>{ val: [formatDate(getDateObject((new Date().getTime())), 'TT.MM.JJJJ SS:mm:ss'), '\r\n', '\r\n', Text].join(''), ack: false });
InternalName = 'BerryDriverUpdate';
Headline = 'Berry-Driver Update';
Text = ['Es ist eine neue Version des Berry-Drivers', '\r\n', '(Tasmota) verfügbar', '\r\n', '\r\n', 'Installierte Version: ' + String(getState((String(NSPanel_Path) + 'Berry_Driver.currentVersion')).val), '\r\n', 'Verfügbare Version: ' + String(berry_driver_version), '\r\n', '\r\n', 'Upgrade durchführen?'].join('');
Update = true;
}
}
} else {
if (Debug) {
console.log('Berry-Driver auf NSPanel aktuell');
}
if (Debug) console.log('Berry-Driver auf NSPanel aktuell');
}
}
@@ -2378,41 +2373,43 @@ async function check_updates() {
if (parseInt(getState(NSPanel_Path + 'Display_Firmware.currentVersion').val) < desired_display_firmware_version) {
if (existsState(NSPanel_Path + 'NSPanel_autoUpdate')) {
if (getState(NSPanel_Path + 'NSPanel_autoUpdate').val) {
if (Debug) console.log('Auto-Updates eingeschaltet - Update TFT-Firmware wird durchgeführt');
// TFT-Firmware Update durchführen
update_tft_firmware();
// Aktuelle TFT-Firmware Version = Online TFT-Firmware Version
await setStateAsync(NSPanel_Path + 'Display_Firmware.currentVersion', <iobJS.State>{ val: getState(NSPanel_Path + 'Display_Firmware.onlineVersion').val, ack: true });
if (Debug) {
console.log('Display_Firmware automatisch aktualisiert');
}
if (Debug) console.log('Display_Firmware automatisch aktualisiert');
} else {
// Auf TFT-Firmware hinweisen
if (Debug) {
console.log('Automatische Updates aus');
}
if (Debug) console.log('Display-Firmware => Automatische Updates aus, manuelles Update nötig');
const InternalName = 'TFTFirmwareUpdate';
const Headline = 'TFT-Firmware Update';
const 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), '\r\n', 'Verfügbare Version: ' + String(desired_display_firmware_version), '\r\n', '\r\n', 'Upgrade durchführen?'].join('');
const Button1 = 'Nein';
const Button2 = 'Ja';
const Timeout = 0;
await setStateAsync(popupNotifyHeading, <iobJS.State>{ val: Headline, ack: false });
await setStateAsync(popupNotifyButton1Text, <iobJS.State>{ val: Button1, ack: false });
await setStateAsync(popupNotifyButton2Text, <iobJS.State>{ val: Button2, ack: false });
await setStateAsync(popupNotifySleepTimeout, <iobJS.State>{ val: Timeout, ack: false });
await setStateAsync(popupNotifyInternalName, <iobJS.State>{ val: InternalName, ack: false });
await setStateAsync(popupNotifyText, <iobJS.State>{ val: [formatDate(getDateObject((new Date().getTime())), 'TT.MM.JJJJ SS:mm:ss'), '\r\n', '\r\n', Text].join(''), ack: false });
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), '\r\n', 'Verfügbare Version: ' + String(desired_display_firmware_version), '\r\n', '\r\n', 'Upgrade durchführen?'].join('');
Update = true;
}
}
} else {
if (Debug) {
console.log('Display_Firmware auf NSPanel aktuell');
}
if (Debug) console.log('Display_Firmware auf NSPanel aktuell');
}
}
if (Update) {
await setStateAsync(popupNotifyHeading, <iobJS.State>{ val: Headline, ack: false });
await setStateAsync(popupNotifyHeadingColor, <iobJS.State>{ val: HeadlineColor, ack: false });
await setStateAsync(popupNotifyButton1Text, <iobJS.State>{ val: Button1, ack: false });
await setStateAsync(popupNotifyButton1TextColor, <iobJS.State>{ val: Button1Color, ack: false });
await setStateAsync(popupNotifyButton2Text, <iobJS.State>{ val: Button2, ack: false });
await setStateAsync(popupNotifyButton2TextColor, <iobJS.State>{ val: Button2Color, ack: false });
await setStateAsync(popupNotifySleepTimeout, <iobJS.State>{ val: Timeout, ack: false });
await setStateAsync(popupNotifyInternalName, <iobJS.State>{ val: InternalName, ack: false });
await setStateAsync(popupNotifyLayout, <iobJS.State>{ val: Layout, ack: false });
await setStateAsync(popupNotifyText, <iobJS.State>{ val: [formatDate(getDateObject((new Date().getTime())), 'TT.MM.JJJJ SS:mm:ss'), '\r\n', '\r\n', Text].join(''), ack: false });
}
} catch (err) {
console.warn('error at function check_updates: ' + err.message);
}
@@ -2505,6 +2502,7 @@ function get_online_tasmota_firmware_version() {
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, <iobJS.StateCommon>{ type: 'string', role: 'state', name: 'ACTUAL' });
await setStateAsync(NSPanel_Path + 'Tasmota_Firmware.onlineVersion', <iobJS.State>{ val: TasmotaVersionOnline, ack: true });
if (Debug) console.log('online tasmota firmware version => ' + TasmotaVersionOnline);
} catch (err) {
console.warn('error result in function get_online_tasmota_firmware_version: ' + err.message);
}
@@ -2533,12 +2531,14 @@ function get_current_berry_driver_version() {
}
}, async (error, response, result) => {
try {
const BerryDriverVersionCurrent: string = JSON.parse(result).nlui_driver_version;
await createStateAsync(NSPanel_Path + 'Berry_Driver.currentVersion', <iobJS.StateCommon>{ type: 'string' });
await setStateAsync(NSPanel_Path + 'Berry_Driver.currentVersion', <iobJS.State>{ val: JSON.parse(result).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, <iobJS.StateCommon>{ type: 'string', role: 'state', name: 'ACTUAL' });
}
if (Debug) console.log('current berry driver version => ' + BerryDriverVersionCurrent);
} catch (err) {
console.warn('error result in function get_current_berry_driver_version: ' + err.message);
}
@@ -2595,6 +2595,7 @@ function get_tasmota_status0() {
await setStateAsync(NSPanel_Path + 'Tasmota.Wifi.RSSI', <iobJS.State>{ val: Tasmota_JSON.StatusSTS.Wifi.RSSI, ack: true });
await setStateAsync(NSPanel_Path + 'Tasmota.Wifi.Signal', <iobJS.State>{ val: Tasmota_JSON.StatusSTS.Wifi.Signal, ack: true });
await setStateAsync(NSPanel_Path + 'Tasmota.Product', <iobJS.State>{ val: 'SONOFF NSPanel', ack: true });
if (Debug) console.log('current tasmota firmware version => ' + tasmoVersion);
} catch (err) {
console.warn('error setState in function get_tasmota_status0' + err.message);
}
@@ -2647,6 +2648,7 @@ function get_online_berry_driver_version() {
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, <iobJS.StateCommon>{ type: 'string', role: 'state', name: 'ACTUAL' });
await setStateAsync(NSPanel_Path + 'Berry_Driver.onlineVersion', <iobJS.State>{ val: BerryDriverVersionOnline, ack: true });
if (Debug) console.log('online berry driver version => ' + BerryDriverVersionOnline);
} catch (err) {
console.warn('error result in function get_online_berry_driver_version' + err.message);
}
@@ -2677,6 +2679,7 @@ function check_version_tft_firmware() {
await createStateAsync(NSPanel_Path + 'TFT_Firmware.onlineVersion', <iobJS.StateCommon>{ type: 'string' });
await setStateAsync(NSPanel_Path + 'TFT_Firmware.onlineVersion', <iobJS.State>{ val: NSPanelVersion, ack: true });
if (Debug) console.log('online TFT firmware version => ' + NSPanelVersion);
} catch (err) {
console.warn('error result in function check_version_tft_firmware: ' + err.message);
}
@@ -2704,6 +2707,7 @@ function check_online_display_firmware() {
await createStateAsync(NSPanel_Path + 'Display_Firmware.onlineVersion', <iobJS.StateCommon>{ type: 'string' });
await setStateAsync(NSPanel_Path + 'Display_Firmware.onlineVersion', <iobJS.State>{ val: desired_display_firmware_version, ack: true });
if (Debug) console.log('online display firmware version => ' + desired_display_firmware_version);
} catch (err) {
console.warn('error result in function check_online_display_firmware' + err.message);
}
@@ -2842,7 +2846,7 @@ on({ id: config.panelRecvTopic.substring(0, config.panelRecvTopic.length - 'RESU
} else {
console.log('Tasmota upgrade complete. New Version: ' + Tasmota_JSON.Info1.Version);
get_tasmota_status0();
check_updates();
//check_updates();
}
}
} catch (err) {
@@ -2985,6 +2989,7 @@ function GeneratePage(page: Page): void {
activePage = page;
setIfExists(NSPanel_Path + 'ActivePage.type', activePage.type);
setIfExists(NSPanel_Path + 'ActivePage.heading', activePage.heading);
setIfExists(NSPanel_Path + 'ActivePage.id0', activePage.items[0].id);
switch (page.type) {
case 'cardEntities':
SendToPanel(GenerateEntitiesPage(<PageEntities>page));
@@ -5067,17 +5072,17 @@ function GeneratePowerPage(page: PagePower): Payload[] {
let arrayColorScale = [colorScale0, colorScale1, colorScale2, colorScale3, colorScale4, colorScale5, colorScale6, colorScale7, colorScale8, colorScale9, colorScale10];
let homeIconColor = 0;
if (!demoMode) {
for (let obji = 1; obji < 7; obji++) {
array_icon_color[obji] = arrayColorScale[obj[obji].iconColor !== '' ? obj[obji].iconColor : 0];
const color = obj[obji].iconColor !== '' ? obj[obji].iconColor : 0;
array_icon_color[obji] = arrayColorScale[color];
array_icon[obji] = obj[obji].icon;
array_powerspeed[obji] = obj[obji].speed;
array_powerstate[obji] = obj[obji].value + ' ' + obj[obji].unit ;
}
array_icon[0] = obj[0].icon;
array_powerstate[0] = obj[0].value + ' ' + obj[0].unit;
homeIconColor = obj[0].iconColor;
array_icon_color[0] = arrayColorScale[obj[0].iconColor];
}
let power_string : any = '';
@@ -5092,7 +5097,6 @@ function GeneratePowerPage(page: PagePower): Payload[] {
power_string = power_string + array_powerspeed[i+1] + '~'; // speed~
if (Debug) console.log(power_string);
console.log(power_string);
}
power_string = power_string.substring(0, power_string.length - 1);
@@ -5105,7 +5109,7 @@ function GeneratePowerPage(page: PagePower): Payload[] {
'' + '~' + // type (ignored)
'' + '~' + // intNameEntity (ignored)
Icons.GetIcon(array_icon[0]) + '~' + // icon
rgb_dec565(array_icon_color[homeIconColor]) + '~' + // icon_color
rgb_dec565(array_icon_color[0]) + '~' + // icon_color
'' + '~' + // display (ignored in TS)
array_powerstate[0] + '~' + // optionalValue
'' + '~' + // speed
@@ -6867,6 +6871,7 @@ function UnsubscribeWatcher(): void {
function HandleScreensaver(): void {
setIfExists(NSPanel_Path + 'ActivePage.type', 'screensaver');
setIfExists(NSPanel_Path + 'ActivePage.id0', 'screensaver');
setIfExists(NSPanel_Path + 'ActivePage.heading', 'Screensaver');
if (existsObject(NSPanel_Path + 'Config.Screensaver.ScreensaverAdvanced')) {
if (getState(NSPanel_Path + 'Config.Screensaver.ScreensaverAdvanced').val) {

View File

@@ -1,6 +1,6 @@
/*-----------------------------------------------------------------------
TypeScript v4.0.5.7 zur Steuerung des SONOFF NSPanel mit dem ioBroker by @Armilar / @Sternmiere / @Britzelpuf / @ravenS0ne / @TT-Tom
- abgestimmt auf TFT 50 / v4.0.5 / BerryDriver 8 / Tasmota 12.4.0
TypeScript v4.0.5.10 zur Steuerung des SONOFF NSPanel mit dem ioBroker by @Armilar / @Sternmiere / @Britzelpuf / @ravenS0ne / @TT-Tom
- abgestimmt auf TFT 50 / v4.0.5 / BerryDriver 8 / Tasmota 12.5.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
icon_mapping.ts: https://github.com/joBr99/nspanel-lovelace-ui/blob/main/ioBroker/icon_mapping.ts (TypeScript muss in global liegen)
@@ -131,6 +131,9 @@ ReleaseNotes:
- 09.04.2023 - v4.0.5.5 Fix trigger popupNotifypage
- 11.04.2023 - v4.0.5.6 Fix function InitDimmode
- 18.04.2023 - v4.0.5.7 Fix Function check_updates
- 20.04.2023 - v4.0.5.8 Fix Layout Update message for TFT, Berry-Driver and Tasmota
- 21.04.2023 - v4.0.5.9 Add Parameter pageitem id0 to ActivePages (0_userdata)
- 21.04.2023 - v4.0.5.10 Fixed error wrong icon index in GeneratePowerPage by fre4242
***********************************************************************************************************
* Für die Erstellung der Aliase durch das Skript, muss in der JavaScript Instanz "setObect" gesetzt sein! *
@@ -223,6 +226,7 @@ Upgrades in Konsole:
TFT EU STABLE Version : FlashNextion http://nspanel.pky.eu/lovelace-ui/github/nspanel-v4.0.5.tft
---------------------------------------------------------------------------------------
*/
let Icons = new IconsSelector();
let timeoutSlider: any;
let vwIconColor = [];
@@ -716,7 +720,18 @@ export const config = <Config> {
ScreensaverEntityUnitText: '°',
ScreensaverEntityIconColor: White
},
// Examples for Advanced-Screensaver: https://github.com/joBr99/nspanel-lovelace-ui/wiki/ioBroker-Config-Screensaver#entity-status-icons-ab-v400
// bottomScreensaverEntity 5 (for Alternative and Advanced Screensaver)
{
ScreensaverEntity: 'accuweather.0.Current.RelativeHumidity',
ScreensaverEntityFactor: 1,
ScreensaverEntityDecimalPlaces: 1,
ScreensaverEntityIconOn: 'water-percent',
ScreensaverEntityIconOff: null,
ScreensaverEntityText: 'Feuchte',
ScreensaverEntityUnitText: '%',
ScreensaverEntityIconColor: {'val_min': 0, 'val_max': 100, 'val_best': 65}
},
// Examples for Advanced-Screensaver: https://github.com/joBr99/nspanel-lovelace-ui/wiki/ioBroker-Config-Screensaver#entity-status-icons-ab-v400
],
indicatorScreensaverEntity:
@@ -791,7 +806,6 @@ export const config = <Config> {
}
};
// _________________________________ Ab hier keine Konfiguration mehr _____________________________________
const request = require('request');
@@ -1017,6 +1031,9 @@ async function Init_ActivePageData() {
if (existsState(NSPanel_Path + 'ActivePage.type') == false ) {
await createStateAsync(NSPanel_Path + 'ActivePage.type', '', true, { type: 'string' });
}
if (existsState(NSPanel_Path + 'ActivePage.id0') == false ) {
await createStateAsync(NSPanel_Path + 'ActivePage.id0', '', true, { type: 'string' });
}
} catch (err) {
console.warn('error at function Init_ActivePageData: ' + err.message);
}
@@ -1606,10 +1623,10 @@ async function InitPopupNotify() {
let notification: string;
let v_popupNotifyHeadingColor = (getState(popupNotifyHeadingColor).val != null) ? getState(popupNotifyHeadingColor).val : '65504'// Farbe Headline - gelb 65504
let v_popupNotifyButton1TextColor = (getState(popupNotifyButton1TextColor).val != null) ? getState(popupNotifyButton1TextColor).val : '63488'// Farbe Headline - gelb 65504
let v_popupNotifyButton2TextColor = (getState(popupNotifyButton2TextColor).val != null) ? getState(popupNotifyButton2TextColor).val : '2016'// Farbe Headline - gelb 65504
let v_popupNotifyTextColor = (getState(popupNotifyTextColor).val != null) ? getState(popupNotifyTextColor).val : '65535'// Farbe Headline - gelb 65504
let v_popupNotifyIconColor = (getState(popupNotifyIconColor).val != null) ? getState(popupNotifyIconColor).val : '65535'// Farbe Headline - gelb 65504
let v_popupNotifyButton1TextColor = (getState(popupNotifyButton1TextColor).val != null) ? getState(popupNotifyButton1TextColor).val : '63488'// Farbe Button 1 - rot 63488
let v_popupNotifyButton2TextColor = (getState(popupNotifyButton2TextColor).val != null) ? getState(popupNotifyButton2TextColor).val : '2016'// Farbe Button 2 - grün 2016
let v_popupNotifyTextColor = (getState(popupNotifyTextColor).val != null) ? getState(popupNotifyTextColor).val : '65535'// Farbe Text - weiss 65535
let v_popupNotifyIconColor = (getState(popupNotifyIconColor).val != null) ? getState(popupNotifyIconColor).val : '65535'// Farbe Icon - weiss 65535
let v_popupNotifyFontIdText = (getState(popupNotifyFontIdText).val != null) ? getState(popupNotifyFontIdText).val : '1'
let v_popupNotifyIcon = (getState(popupNotifyIcon).val != null) ? getState(popupNotifyIcon).val : 'alert'
@@ -1776,9 +1793,22 @@ function get_locales() {
async function check_updates() {
try {
if (Debug) {
console.log('Check-Updates');
}
if (Debug) console.log('Check-Updates');
let Update: boolean = false;
let InternalName: string = '';
let Headline: string = '';
let Text: string = '';
const HeadlineColor: string = '63488'; // Farbe Rot
const Button1: string = 'Nein';
const Button1Color: string = '63488'; // Farbe Rot
const Button2: string = 'Ja';
const Button2Color: string = '2016'; // Farbe Grün
const Timeout: number = 0;
const Layout: number = 1;
// Tasmota-Firmware-Vergleich
if (existsObject(NSPanel_Path + 'Tasmota_Firmware.currentVersion') && existsObject(NSPanel_Path + 'Tasmota_Firmware.onlineVersion')) {
let splitTasmotaVersion = (getState(NSPanel_Path + 'Tasmota_Firmware.currentVersion').val).split('.');
@@ -1786,9 +1816,9 @@ async function check_updates() {
if (shortTasmoataVersion !== getState(NSPanel_Path + 'Tasmota_Firmware.onlineVersion').val) {
if (existsState(NSPanel_Path + 'NSPanel_autoUpdate')) {
if (getState(NSPanel_Path + 'NSPanel_autoUpdate').val) {
if (Debug) {
console.log('Auto-Updates eingeschaltet - Update wird durchgeführt');
}
if (Debug) console.log('Auto-Updates eingeschaltet - Update Tasmota wird durchgeführt');
// Tasmota Upgrade durchführen
update_tasmota_firmware();
// Aktuelle Tasmota Version = Online Tasmota Version
@@ -1796,29 +1826,16 @@ async function check_updates() {
await setStateAsync(NSPanel_Path + 'Tasmota_Firmware.currentVersion', <iobJS.State>{ val: getState(NSPanel_Path + 'Tasmota_Firmware.onlineVersion').val, ack: true });
} else {
// Auf Tasmota-Updates hinweisen
if (Debug) {
console.log('Automatische Updates aus');
}
if (Debug) console.log('Tasmota-Firmware => Automatische Updates aus, manuelles Update nötig');
const InternalName = 'TasmotaFirmwareUpdate';
const Headline = 'Tasmota-Firmware Update';
const Text = ['Es ist eine neue Version der Tasmota-Firmware', '\r\n', 'verfügbar', '\r\n', '\r\n', 'Installierte Version: ' + String(getState((String(NSPanel_Path) + 'Tasmota_Firmware.currentVersion')).val), '\r\n', 'Verfügbare Version: ' + String(getState((String(NSPanel_Path) + 'Tasmota_Firmware.onlineVersion')).val), '\r\n', '\r\n', 'Upgrade durchführen?'].join('');
const Button1 = 'Nein';
const Button2 = 'Ja';
const Timeout = 0;
await setStateAsync(popupNotifyHeading, <iobJS.State>{ val: Headline, ack: false });
await setStateAsync(popupNotifyButton1Text, <iobJS.State>{ val: Button1, ack: false });
await setStateAsync(popupNotifyButton2Text, <iobJS.State>{ val: Button2, ack: false });
await setStateAsync(popupNotifySleepTimeout, <iobJS.State>{ val: Timeout, ack: false });
await setStateAsync(popupNotifyInternalName, <iobJS.State>{ val: InternalName, ack: false });
await setStateAsync(popupNotifyText, <iobJS.State>{ val: [formatDate(getDateObject((new Date().getTime())), 'TT.MM.JJJJ SS:mm:ss'), '\r\n', '\r\n', Text].join(''), ack: false });
InternalName = 'TasmotaFirmwareUpdate';
Headline = 'Tasmota-Firmware Update';
Text = ['Es ist eine neue Version der Tasmota-Firmware', '\r\n', 'verfügbar', '\r\n', '\r\n', 'Installierte Version: ' + String(getState((String(NSPanel_Path) + 'Tasmota_Firmware.currentVersion')).val), '\r\n', 'Verfügbare Version: ' + String(getState((String(NSPanel_Path) + 'Tasmota_Firmware.onlineVersion')).val), '\r\n', '\r\n', 'Upgrade durchführen?'].join('');
Update = true;
}
}
} else {
if (Debug) {
console.log('Tasmota-Version auf NSPanel aktuell');
}
if (Debug) console.log('Tasmota-Version auf NSPanel aktuell');
}
}
@@ -1827,39 +1844,28 @@ async function check_updates() {
if (parseFloat(getState(NSPanel_Path + 'Berry_Driver.currentVersion').val) < berry_driver_version) {
if (existsState(NSPanel_Path + 'NSPanel_autoUpdate')) {
if (getState(NSPanel_Path + 'NSPanel_autoUpdate').val) {
if (Debug) console.log('Auto-Updates eingeschaltet - Update Berry-Driver wird durchgeführt');
// 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', <iobJS.State>{ val: getState(NSPanel_Path + 'Berry_Driver.onlineVersion').val, ack: true });
if (Debug) {
console.log('Berry-Driver automatisch aktualisiert');
}
if (Debug) console.log('Berry-Driver automatisch aktualisiert');
} else {
//Auf BerryDriver-Update hinweisen
if (Debug) {
console.log('Automatische Updates aus');
}
if (Debug) console.log('Berry-Driver => Automatische Updates aus, manuelles Update nötig');
const InternalName = 'BerryDriverUpdate';
const Headline = 'Berry-Driver Update';
const Text = ['Es ist eine neue Version des Berry-Drivers', '\r\n', '(Tasmota) verfügbar', '\r\n', '\r\n', 'Installierte Version: ' + String(getState((String(NSPanel_Path) + 'Berry_Driver.currentVersion')).val), '\r\n', 'Verfügbare Version: ' + String(berry_driver_version), '\r\n', '\r\n', 'Upgrade durchführen?'].join('');
const Button1 = 'Nein';
const Button2 = 'Ja';
const Timeout = 0;
await setStateAsync(popupNotifyHeading, <iobJS.State>{ val: Headline, ack: false });
await setStateAsync(popupNotifyButton1Text, <iobJS.State>{ val: Button1, ack: false });
await setStateAsync(popupNotifyButton2Text, <iobJS.State>{ val: Button2, ack: false });
await setStateAsync(popupNotifySleepTimeout, <iobJS.State>{ val: Timeout, ack: false });
await setStateAsync(popupNotifyInternalName, <iobJS.State>{ val: InternalName, ack: false });
await setStateAsync(popupNotifyText, <iobJS.State>{ val: [formatDate(getDateObject((new Date().getTime())), 'TT.MM.JJJJ SS:mm:ss'), '\r\n', '\r\n', Text].join(''), ack: false });
InternalName = 'BerryDriverUpdate';
Headline = 'Berry-Driver Update';
Text = ['Es ist eine neue Version des Berry-Drivers', '\r\n', '(Tasmota) verfügbar', '\r\n', '\r\n', 'Installierte Version: ' + String(getState((String(NSPanel_Path) + 'Berry_Driver.currentVersion')).val), '\r\n', 'Verfügbare Version: ' + String(berry_driver_version), '\r\n', '\r\n', 'Upgrade durchführen?'].join('');
Update = true;
}
}
} else {
if (Debug) {
console.log('Berry-Driver auf NSPanel aktuell');
}
if (Debug) console.log('Berry-Driver auf NSPanel aktuell');
}
}
@@ -1868,41 +1874,43 @@ async function check_updates() {
if (parseInt(getState(NSPanel_Path + 'Display_Firmware.currentVersion').val) < desired_display_firmware_version) {
if (existsState(NSPanel_Path + 'NSPanel_autoUpdate')) {
if (getState(NSPanel_Path + 'NSPanel_autoUpdate').val) {
if (Debug) console.log('Auto-Updates eingeschaltet - Update TFT-Firmware wird durchgeführt');
// TFT-Firmware Update durchführen
update_tft_firmware();
// Aktuelle TFT-Firmware Version = Online TFT-Firmware Version
await setStateAsync(NSPanel_Path + 'Display_Firmware.currentVersion', <iobJS.State>{ val: getState(NSPanel_Path + 'Display_Firmware.onlineVersion').val, ack: true });
if (Debug) {
console.log('Display_Firmware automatisch aktualisiert');
}
if (Debug) console.log('Display_Firmware automatisch aktualisiert');
} else {
// Auf TFT-Firmware hinweisen
if (Debug) {
console.log('Automatische Updates aus');
}
if (Debug) console.log('Display-Firmware => Automatische Updates aus, manuelles Update nötig');
const InternalName = 'TFTFirmwareUpdate';
const Headline = 'TFT-Firmware Update';
const 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), '\r\n', 'Verfügbare Version: ' + String(desired_display_firmware_version), '\r\n', '\r\n', 'Upgrade durchführen?'].join('');
const Button1 = 'Nein';
const Button2 = 'Ja';
const Timeout = 0;
await setStateAsync(popupNotifyHeading, <iobJS.State>{ val: Headline, ack: false });
await setStateAsync(popupNotifyButton1Text, <iobJS.State>{ val: Button1, ack: false });
await setStateAsync(popupNotifyButton2Text, <iobJS.State>{ val: Button2, ack: false });
await setStateAsync(popupNotifySleepTimeout, <iobJS.State>{ val: Timeout, ack: false });
await setStateAsync(popupNotifyInternalName, <iobJS.State>{ val: InternalName, ack: false });
await setStateAsync(popupNotifyText, <iobJS.State>{ val: [formatDate(getDateObject((new Date().getTime())), 'TT.MM.JJJJ SS:mm:ss'), '\r\n', '\r\n', Text].join(''), ack: false });
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), '\r\n', 'Verfügbare Version: ' + String(desired_display_firmware_version), '\r\n', '\r\n', 'Upgrade durchführen?'].join('');
Update = true;
}
}
} else {
if (Debug) {
console.log('Display_Firmware auf NSPanel aktuell');
}
if (Debug) console.log('Display_Firmware auf NSPanel aktuell');
}
}
if (Update) {
await setStateAsync(popupNotifyHeading, <iobJS.State>{ val: Headline, ack: false });
await setStateAsync(popupNotifyHeadingColor, <iobJS.State>{ val: HeadlineColor, ack: false });
await setStateAsync(popupNotifyButton1Text, <iobJS.State>{ val: Button1, ack: false });
await setStateAsync(popupNotifyButton1TextColor, <iobJS.State>{ val: Button1Color, ack: false });
await setStateAsync(popupNotifyButton2Text, <iobJS.State>{ val: Button2, ack: false });
await setStateAsync(popupNotifyButton2TextColor, <iobJS.State>{ val: Button2Color, ack: false });
await setStateAsync(popupNotifySleepTimeout, <iobJS.State>{ val: Timeout, ack: false });
await setStateAsync(popupNotifyInternalName, <iobJS.State>{ val: InternalName, ack: false });
await setStateAsync(popupNotifyLayout, <iobJS.State>{ val: Layout, ack: false });
await setStateAsync(popupNotifyText, <iobJS.State>{ val: [formatDate(getDateObject((new Date().getTime())), 'TT.MM.JJJJ SS:mm:ss'), '\r\n', '\r\n', Text].join(''), ack: false });
}
} catch (err) {
console.warn('error at function check_updates: ' + err.message);
}
@@ -1995,6 +2003,7 @@ function get_online_tasmota_firmware_version() {
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, <iobJS.StateCommon>{ type: 'string', role: 'state', name: 'ACTUAL' });
await setStateAsync(NSPanel_Path + 'Tasmota_Firmware.onlineVersion', <iobJS.State>{ val: TasmotaVersionOnline, ack: true });
if (Debug) console.log('online tasmota firmware version => ' + TasmotaVersionOnline);
} catch (err) {
console.warn('error result in function get_online_tasmota_firmware_version: ' + err.message);
}
@@ -2023,12 +2032,14 @@ function get_current_berry_driver_version() {
}
}, async (error, response, result) => {
try {
const BerryDriverVersionCurrent: string = JSON.parse(result).nlui_driver_version;
await createStateAsync(NSPanel_Path + 'Berry_Driver.currentVersion', <iobJS.StateCommon>{ type: 'string' });
await setStateAsync(NSPanel_Path + 'Berry_Driver.currentVersion', <iobJS.State>{ val: JSON.parse(result).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, <iobJS.StateCommon>{ type: 'string', role: 'state', name: 'ACTUAL' });
}
if (Debug) console.log('current berry driver version => ' + BerryDriverVersionCurrent);
} catch (err) {
console.warn('error result in function get_current_berry_driver_version: ' + err.message);
}
@@ -2085,6 +2096,7 @@ function get_tasmota_status0() {
await setStateAsync(NSPanel_Path + 'Tasmota.Wifi.RSSI', <iobJS.State>{ val: Tasmota_JSON.StatusSTS.Wifi.RSSI, ack: true });
await setStateAsync(NSPanel_Path + 'Tasmota.Wifi.Signal', <iobJS.State>{ val: Tasmota_JSON.StatusSTS.Wifi.Signal, ack: true });
await setStateAsync(NSPanel_Path + 'Tasmota.Product', <iobJS.State>{ val: 'SONOFF NSPanel', ack: true });
if (Debug) console.log('current tasmota firmware version => ' + tasmoVersion);
} catch (err) {
console.warn('error setState in function get_tasmota_status0' + err.message);
}
@@ -2137,6 +2149,7 @@ function get_online_berry_driver_version() {
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, <iobJS.StateCommon>{ type: 'string', role: 'state', name: 'ACTUAL' });
await setStateAsync(NSPanel_Path + 'Berry_Driver.onlineVersion', <iobJS.State>{ val: BerryDriverVersionOnline, ack: true });
if (Debug) console.log('online berry driver version => ' + BerryDriverVersionOnline);
} catch (err) {
console.warn('error result in function get_online_berry_driver_version' + err.message);
}
@@ -2167,6 +2180,7 @@ function check_version_tft_firmware() {
await createStateAsync(NSPanel_Path + 'TFT_Firmware.onlineVersion', <iobJS.StateCommon>{ type: 'string' });
await setStateAsync(NSPanel_Path + 'TFT_Firmware.onlineVersion', <iobJS.State>{ val: NSPanelVersion, ack: true });
if (Debug) console.log('online TFT firmware version => ' + NSPanelVersion);
} catch (err) {
console.warn('error result in function check_version_tft_firmware: ' + err.message);
}
@@ -2194,6 +2208,7 @@ function check_online_display_firmware() {
await createStateAsync(NSPanel_Path + 'Display_Firmware.onlineVersion', <iobJS.StateCommon>{ type: 'string' });
await setStateAsync(NSPanel_Path + 'Display_Firmware.onlineVersion', <iobJS.State>{ val: desired_display_firmware_version, ack: true });
if (Debug) console.log('online display firmware version => ' + desired_display_firmware_version);
} catch (err) {
console.warn('error result in function check_online_display_firmware' + err.message);
}
@@ -2332,7 +2347,7 @@ on({ id: config.panelRecvTopic.substring(0, config.panelRecvTopic.length - 'RESU
} else {
console.log('Tasmota upgrade complete. New Version: ' + Tasmota_JSON.Info1.Version);
get_tasmota_status0();
check_updates();
//check_updates();
}
}
} catch (err) {
@@ -2475,6 +2490,7 @@ function GeneratePage(page: Page): void {
activePage = page;
setIfExists(NSPanel_Path + 'ActivePage.type', activePage.type);
setIfExists(NSPanel_Path + 'ActivePage.heading', activePage.heading);
setIfExists(NSPanel_Path + 'ActivePage.id0', activePage.items[0].id);
switch (page.type) {
case 'cardEntities':
SendToPanel(GenerateEntitiesPage(<PageEntities>page));
@@ -4557,17 +4573,17 @@ function GeneratePowerPage(page: PagePower): Payload[] {
let arrayColorScale = [colorScale0, colorScale1, colorScale2, colorScale3, colorScale4, colorScale5, colorScale6, colorScale7, colorScale8, colorScale9, colorScale10];
let homeIconColor = 0;
if (!demoMode) {
for (let obji = 1; obji < 7; obji++) {
array_icon_color[obji] = arrayColorScale[obj[obji].iconColor !== '' ? obj[obji].iconColor : 0];
const color = obj[obji].iconColor !== '' ? obj[obji].iconColor : 0;
array_icon_color[obji] = arrayColorScale[color];
array_icon[obji] = obj[obji].icon;
array_powerspeed[obji] = obj[obji].speed;
array_powerstate[obji] = obj[obji].value + ' ' + obj[obji].unit ;
}
array_icon[0] = obj[0].icon;
array_powerstate[0] = obj[0].value + ' ' + obj[0].unit;
homeIconColor = obj[0].iconColor;
array_icon_color[0] = arrayColorScale[obj[0].iconColor];
}
let power_string : any = '';
@@ -4582,7 +4598,6 @@ function GeneratePowerPage(page: PagePower): Payload[] {
power_string = power_string + array_powerspeed[i+1] + '~'; // speed~
if (Debug) console.log(power_string);
console.log(power_string);
}
power_string = power_string.substring(0, power_string.length - 1);
@@ -4595,7 +4610,7 @@ function GeneratePowerPage(page: PagePower): Payload[] {
'' + '~' + // type (ignored)
'' + '~' + // intNameEntity (ignored)
Icons.GetIcon(array_icon[0]) + '~' + // icon
rgb_dec565(array_icon_color[homeIconColor]) + '~' + // icon_color
rgb_dec565(array_icon_color[0]) + '~' + // icon_color
'' + '~' + // display (ignored in TS)
array_powerstate[0] + '~' + // optionalValue
'' + '~' + // speed
@@ -6357,6 +6372,7 @@ function UnsubscribeWatcher(): void {
function HandleScreensaver(): void {
setIfExists(NSPanel_Path + 'ActivePage.type', 'screensaver');
setIfExists(NSPanel_Path + 'ActivePage.id0', 'screensaver');
setIfExists(NSPanel_Path + 'ActivePage.heading', 'Screensaver');
if (existsObject(NSPanel_Path + 'Config.Screensaver.ScreensaverAdvanced')) {
if (getState(NSPanel_Path + 'Config.Screensaver.ScreensaverAdvanced').val) {