From 76d6105ecf586b74ca73d4ad93193647f5ac349e Mon Sep 17 00:00:00 2001 From: joBr99 <29555657+joBr99@users.noreply.github.com> Date: Wed, 17 Aug 2022 15:05:11 +0000 Subject: [PATCH 1/3] fix bench txt (add nextion2text) --- HMI/US/landscape/diff-eu-version.txt | 14 +++++++------- HMI/US/portrait/diff-eu-version.txt | 18 +++++++++--------- HMI/US/portrait/diff-filtered.txt | 20 ++++++++++---------- HMI/n2t-out-visual/pageTest.txt | 2 +- HMI/n2t-out/pageTest.txt | 2 +- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/HMI/US/landscape/diff-eu-version.txt b/HMI/US/landscape/diff-eu-version.txt index ebe44a6c..01e538b7 100644 --- a/HMI/US/landscape/diff-eu-version.txt +++ b/HMI/US/landscape/diff-eu-version.txt @@ -1,6 +1,6 @@ diff -bur HMI/n2t-out/Program.s.txt HMI/US/landscape/n2t-out/Program.s.txt ---- HMI/n2t-out/Program.s.txt 2022-08-17 14:53:10.719943618 +0000 -+++ HMI/US/landscape/n2t-out/Program.s.txt 2022-08-17 14:53:11.691958420 +0000 +--- HMI/n2t-out/Program.s.txt 2022-08-17 15:05:03.933958595 +0000 ++++ HMI/US/landscape/n2t-out/Program.s.txt 2022-08-17 15:05:05.245664384 +0000 @@ -14,6 +14,3 @@ //color vars int defaultFontColor=65535 @@ -9,8 +9,8 @@ diff -bur HMI/n2t-out/Program.s.txt HMI/US/landscape/n2t-out/Program.s.txt - lcd_dev fffb 0002 0000 0020 - page pageStartup diff -bur HMI/n2t-out/pageStartup.txt HMI/US/landscape/n2t-out/pageStartup.txt ---- HMI/n2t-out/pageStartup.txt 2022-08-17 14:53:10.719943618 +0000 -+++ HMI/US/landscape/n2t-out/pageStartup.txt 2022-08-17 14:53:11.691958420 +0000 +--- HMI/n2t-out/pageStartup.txt 2022-08-17 15:05:03.933958595 +0000 ++++ HMI/US/landscape/n2t-out/pageStartup.txt 2022-08-17 15:05:05.249664584 +0000 @@ -177,7 +177,7 @@ recmod=1 bauds=115200 @@ -21,8 +21,8 @@ diff -bur HMI/n2t-out/pageStartup.txt HMI/US/landscape/n2t-out/pageStartup.txt btlen tSend.txt,sys0 crcrest 1,0xffff // reset CRC diff -bur HMI/n2t-out/pageTest.txt HMI/US/landscape/n2t-out/pageTest.txt ---- HMI/n2t-out/pageTest.txt 2022-08-17 14:53:10.719943618 +0000 -+++ HMI/US/landscape/n2t-out/pageTest.txt 2022-08-17 14:53:11.691958420 +0000 +--- HMI/n2t-out/pageTest.txt 2022-08-17 15:05:03.933958595 +0000 ++++ HMI/US/landscape/n2t-out/pageTest.txt 2022-08-17 15:05:05.249664584 +0000 @@ -13,36 +13,6 @@ Events Preinitialize Event @@ -117,7 +117,7 @@ diff -bur HMI/n2t-out/pageTest.txt HMI/US/landscape/n2t-out/pageTest.txt - spstr strCommand.txt,tInstruction.txt,"~",0 - if(tInstruction.txt=="ping") - { -- spstr strCommand.txt,tBench.txt,"~",0 +- spstr strCommand.txt,tBench.txt,"~",1 - tSend.txt="pong,"+tBench.txt - //send calc crc - btlen tSend.txt,sys0 diff --git a/HMI/US/portrait/diff-eu-version.txt b/HMI/US/portrait/diff-eu-version.txt index 3973d76a..1fee3bb3 100644 --- a/HMI/US/portrait/diff-eu-version.txt +++ b/HMI/US/portrait/diff-eu-version.txt @@ -1,6 +1,6 @@ diff -bur HMI/n2t-out/Program.s.txt HMI/US/portrait/n2t-out/Program.s.txt ---- HMI/n2t-out/Program.s.txt 2022-08-17 14:53:10.719943618 +0000 -+++ HMI/US/portrait/n2t-out/Program.s.txt 2022-08-17 14:53:11.195950867 +0000 +--- HMI/n2t-out/Program.s.txt 2022-08-17 15:05:03.933958595 +0000 ++++ HMI/US/portrait/n2t-out/Program.s.txt 2022-08-17 15:05:04.569667901 +0000 @@ -14,6 +14,6 @@ //color vars int defaultFontColor=65535 @@ -11,8 +11,8 @@ diff -bur HMI/n2t-out/Program.s.txt HMI/US/portrait/n2t-out/Program.s.txt + //lcd_dev fffb 0002 0000 0020 page pageStartup diff -bur HMI/n2t-out/cardEntities.txt HMI/US/portrait/n2t-out/cardEntities.txt ---- HMI/n2t-out/cardEntities.txt 2022-08-17 14:53:10.723943679 +0000 -+++ HMI/US/portrait/n2t-out/cardEntities.txt 2022-08-17 14:53:11.195950867 +0000 +--- HMI/n2t-out/cardEntities.txt 2022-08-17 15:05:03.937956767 +0000 ++++ HMI/US/portrait/n2t-out/cardEntities.txt 2022-08-17 15:05:04.573666073 +0000 @@ -65,6 +65,16 @@ vis nNum4,0 vis bPrev,0 @@ -458,8 +458,8 @@ diff -bur HMI/n2t-out/cardEntities.txt HMI/US/portrait/n2t-out/cardEntities.txt if(tInstruction.txt=="pageType") { diff -bur HMI/n2t-out/pageStartup.txt HMI/US/portrait/n2t-out/pageStartup.txt ---- HMI/n2t-out/pageStartup.txt 2022-08-17 14:53:10.719943618 +0000 -+++ HMI/US/portrait/n2t-out/pageStartup.txt 2022-08-17 14:53:11.195950867 +0000 +--- HMI/n2t-out/pageStartup.txt 2022-08-17 15:05:03.933958595 +0000 ++++ HMI/US/portrait/n2t-out/pageStartup.txt 2022-08-17 15:05:04.573666073 +0000 @@ -142,7 +142,7 @@ Disable release event after dragging: 0 Send Component ID : disabled @@ -479,8 +479,8 @@ diff -bur HMI/n2t-out/pageStartup.txt HMI/US/portrait/n2t-out/pageStartup.txt btlen tSend.txt,sys0 crcrest 1,0xffff // reset CRC diff -bur HMI/n2t-out/pageTest.txt HMI/US/portrait/n2t-out/pageTest.txt ---- HMI/n2t-out/pageTest.txt 2022-08-17 14:53:10.719943618 +0000 -+++ HMI/US/portrait/n2t-out/pageTest.txt 2022-08-17 14:53:11.195950867 +0000 +--- HMI/n2t-out/pageTest.txt 2022-08-17 15:05:03.933958595 +0000 ++++ HMI/US/portrait/n2t-out/pageTest.txt 2022-08-17 15:05:04.569667901 +0000 @@ -13,36 +13,6 @@ Events Preinitialize Event @@ -575,7 +575,7 @@ diff -bur HMI/n2t-out/pageTest.txt HMI/US/portrait/n2t-out/pageTest.txt - spstr strCommand.txt,tInstruction.txt,"~",0 - if(tInstruction.txt=="ping") - { -- spstr strCommand.txt,tBench.txt,"~",0 +- spstr strCommand.txt,tBench.txt,"~",1 - tSend.txt="pong,"+tBench.txt - //send calc crc - btlen tSend.txt,sys0 diff --git a/HMI/US/portrait/diff-filtered.txt b/HMI/US/portrait/diff-filtered.txt index d934aaae..2b071bcb 100644 --- a/HMI/US/portrait/diff-filtered.txt +++ b/HMI/US/portrait/diff-filtered.txt @@ -1,12 +1,12 @@ -+++ HMI/US/portrait/diff-eu-version.txt 2022-08-17 14:53:11.211951111 +0000 -+--- HMI/n2t-out/Program.s.txt 2022-08-17 14:53:10.719943618 +0000 -++++ HMI/US/portrait/n2t-out/Program.s.txt 2022-08-17 14:53:11.195950867 +0000 ++++ HMI/US/portrait/diff-eu-version.txt 2022-08-17 15:05:04.589658760 +0000 ++--- HMI/n2t-out/Program.s.txt 2022-08-17 15:05:03.933958595 +0000 +++++ HMI/US/portrait/n2t-out/Program.s.txt 2022-08-17 15:05:04.569667901 +0000 +@@ -14,6 +14,6 @@ + //color vars + int defaultFontColor=65535 + int defaultBcoColor=6371 -+--- HMI/n2t-out/cardEntities.txt 2022-08-17 14:53:10.723943679 +0000 -++++ HMI/US/portrait/n2t-out/cardEntities.txt 2022-08-17 14:53:11.195950867 +0000 ++--- HMI/n2t-out/cardEntities.txt 2022-08-17 15:05:03.937956767 +0000 +++++ HMI/US/portrait/n2t-out/cardEntities.txt 2022-08-17 15:05:04.573666073 +0000 +@@ -65,6 +65,16 @@ + vis bPrev,0 + vis bNext,0 @@ -33,11 +33,11 @@ ++ spstr strCommand.txt,tTmp.txt,"~",32 ++ covx tTmp.txt,sys0,0,0 ++ btOnOff5.val=sys0 -+--- HMI/n2t-out/pageStartup.txt 2022-08-17 14:53:10.719943618 +0000 -++++ HMI/US/portrait/n2t-out/pageStartup.txt 2022-08-17 14:53:11.195950867 +0000 ++--- HMI/n2t-out/pageStartup.txt 2022-08-17 15:05:03.933958595 +0000 +++++ HMI/US/portrait/n2t-out/pageStartup.txt 2022-08-17 15:05:04.573666073 +0000 +diff -bur HMI/n2t-out/pageTest.txt HMI/US/portrait/n2t-out/pageTest.txt -+--- HMI/n2t-out/pageTest.txt 2022-08-17 14:53:10.719943618 +0000 -++++ HMI/US/portrait/n2t-out/pageTest.txt 2022-08-17 14:53:11.195950867 +0000 ++--- HMI/n2t-out/pageTest.txt 2022-08-17 15:05:03.933958595 +0000 +++++ HMI/US/portrait/n2t-out/pageTest.txt 2022-08-17 15:05:04.569667901 +0000 +@@ -13,36 +13,6 @@ + Events + Preinitialize Event @@ -132,7 +132,7 @@ +- spstr strCommand.txt,tInstruction.txt,"~",0 +- if(tInstruction.txt=="ping") +- { -+- spstr strCommand.txt,tBench.txt,"~",0 ++- spstr strCommand.txt,tBench.txt,"~",1 +- tSend.txt="pong,"+tBench.txt +- //send calc crc +- btlen tSend.txt,sys0 diff --git a/HMI/n2t-out-visual/pageTest.txt b/HMI/n2t-out-visual/pageTest.txt index 92cc9d5e..fdf0241b 100644 --- a/HMI/n2t-out-visual/pageTest.txt +++ b/HMI/n2t-out-visual/pageTest.txt @@ -579,7 +579,7 @@ Timer tmSerial spstr strCommand.txt,tInstruction.txt,"~",0 if(tInstruction.txt=="ping") { - spstr strCommand.txt,tBench.txt,"~",0 + spstr strCommand.txt,tBench.txt,"~",1 tSend.txt="pong,"+tBench.txt //send calc crc btlen tSend.txt,sys0 diff --git a/HMI/n2t-out/pageTest.txt b/HMI/n2t-out/pageTest.txt index ccf77ea9..a2a10692 100644 --- a/HMI/n2t-out/pageTest.txt +++ b/HMI/n2t-out/pageTest.txt @@ -273,7 +273,7 @@ Timer tmSerial spstr strCommand.txt,tInstruction.txt,"~",0 if(tInstruction.txt=="ping") { - spstr strCommand.txt,tBench.txt,"~",0 + spstr strCommand.txt,tBench.txt,"~",1 tSend.txt="pong,"+tBench.txt //send calc crc btlen tSend.txt,sys0 From fdb0dcb18d3ea59e98e1cf753c39227a58c441ed Mon Sep 17 00:00:00 2001 From: WM Date: Wed, 17 Aug 2022 22:03:35 +0200 Subject: [PATCH 2/3] implements #287 #398 by @WhistleMaster Add support for alarm_control_panel and sun --- apps/nspanel-lovelace-ui/luibackend/icons.py | 16 +++++++++++ apps/nspanel-lovelace-ui/luibackend/pages.py | 28 +++++++++++++++++--- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/apps/nspanel-lovelace-ui/luibackend/icons.py b/apps/nspanel-lovelace-ui/luibackend/icons.py index 81d5df4b..9b5fbccd 100644 --- a/apps/nspanel-lovelace-ui/luibackend/icons.py +++ b/apps/nspanel-lovelace-ui/luibackend/icons.py @@ -115,6 +115,22 @@ def map_to_mdi_name(ha_type, state=None, device_class="_", cardType=None): return sensor_mapping[device_class] if device_class in sensor_mapping else "alert-circle-outline" elif ha_type == "alarm-arm-fail": return "progress-alert" + elif ha_type == "alarm_control_panel": + if state == "disarmed": + return "shield-off" + if state == "armed_home": + return "shield-home" + if state == "armed_away": + return "shield-lock" + if state == "armed_night": + return "weather-night" + if state == "armed_vacation": + return "shield-airplane" + elif ha_type == "sun": + if state == "above_horizon": + return "weather-sunset-up" + if state == "below_horizon": + return "weather-sunset-down" else: return "alert-circle-outline" diff --git a/apps/nspanel-lovelace-ui/luibackend/pages.py b/apps/nspanel-lovelace-ui/luibackend/pages.py index 0ae54e4b..33f4e467 100644 --- a/apps/nspanel-lovelace-ui/luibackend/pages.py +++ b/apps/nspanel-lovelace-ui/luibackend/pages.py @@ -22,7 +22,7 @@ class LuiPagesGen(object): self._locale = config.get("locale") self._send_mqtt_msg = send_mqtt_msg - def get_entity_color(self, entity, overwrite=None): + def get_entity_color(self, entity, ha_type=None, overwrite=None): if overwrite is not None: if type(overwrite) is list: return rgb_dec565(overwrite) @@ -31,11 +31,23 @@ class LuiPagesGen(object): for overwrite_state, overwrite_val in overwrite.items(): if overwrite_state == state: return rgb_dec565(overwrite_val) - + attr = entity.attributes default_color_on = rgb_dec565([253, 216, 53]) default_color_off = rgb_dec565([68, 115, 158]) - icon_color = default_color_on if entity.state in ["on", "unlocked"] else default_color_off + icon_color = default_color_on if entity.state in ["on", "unlocked", "above_horizon"] else default_color_off + + if ha_type == "alarm_control_panel": + if entity.state == "disarmed": + icon_color = rgb_dec565([13,160,53]) + if entity.state == "armed_home": + icon_color = rgb_dec565([223,76,30]) + if entity.state == "armed_away": + icon_color = rgb_dec565([223,76,30]) + if entity.state == "armed_night": + icon_color = rgb_dec565([223,76,30]) + if entity.state == "armed_vacation": + icon_color = rgb_dec565([223,76,30]) if "rgb_color" in attr: color = attr.rgb_color @@ -307,6 +319,16 @@ class LuiPagesGen(object): else: text = "Return" return f"~button~{entityId}~{icon_id}~17299~{name}~{text}" + if entityType == "alarm_control_panel": + icon_color = self.get_entity_color(entity, ha_type=entityType, overwrite=colorOverride) + icon_id = get_icon_id_ha(entityType, state=entity.state, overwrite=icon) + text = get_translation(self._locale, f"frontend.state_badge.alarm_control_panel.{entity.state}") + return f"~text~{entityId}~{icon_id}~{icon_color}~{name}~{text}" + if entityType == "sun": + icon_color = self.get_entity_color(entity, overwrite=colorOverride) + icon_id = get_icon_id_ha(entityType, state=entity.state, overwrite=icon) + text = get_translation(self._locale, f"backend.component.sun.state._.{entity.state}") + return f"~text~{entityId}~{icon_id}~{icon_color}~{name}~{text}" return f"~text~{entityId}~{get_icon_id('alert-circle-outline')}~17299~unsupported~" def generate_entities_page(self, navigation, heading, items, cardType): From 2f45c26f412ba83968075b5379f6f298cdfe60d9 Mon Sep 17 00:00:00 2001 From: joBr99 <29555657+joBr99@users.noreply.github.com> Date: Thu, 18 Aug 2022 11:16:57 +0200 Subject: [PATCH 3/3] Update font-char.py --- HMI/code_gen/pages/font-char.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/HMI/code_gen/pages/font-char.py b/HMI/code_gen/pages/font-char.py index c1bd936a..58578443 100644 --- a/HMI/code_gen/pages/font-char.py +++ b/HMI/code_gen/pages/font-char.py @@ -173,8 +173,6 @@ char_res_string += "鎖離狀出目外斷態輔用運判閉碼助啟執轉閒" print("Out: ") #print(char_res_string) -import json - # check if translations.py is covered with open("test", 'r') as f: # open in readonly mode unique_chars = set(f.read()) @@ -187,4 +185,4 @@ with open("test", 'r') as f: # open in readonly mode print(f"char {char} missing") with open("charout.txt", "wb") as text_file: - text_file.write(char_res_string.encode('utf8')) \ No newline at end of file + text_file.write(char_res_string.encode('utf8'))