From 1e2a7bc2caece55dbb48dcd98383d3453a45c7f4 Mon Sep 17 00:00:00 2001 From: joBr99 <29555657+joBr99@users.noreply.github.com> Date: Sat, 26 Mar 2022 00:28:30 +0000 Subject: [PATCH 1/8] allow empty type as alternative for delete (add nextion2text) --- HMI/n2t-out/cardEntities.txt | 8 ++++---- HMI/n2t-out/nspanel_Stats.txt | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/HMI/n2t-out/cardEntities.txt b/HMI/n2t-out/cardEntities.txt index 9ed5176c..78281fd3 100644 --- a/HMI/n2t-out/cardEntities.txt +++ b/HMI/n2t-out/cardEntities.txt @@ -1800,7 +1800,7 @@ Timer tmSerial spstr strCommand.txt,type1.txt,",",1 // get internal name spstr strCommand.txt,entn1.txt,",",2 - if(type1.txt=="delete") + if(type1.txt=="delete"||type1.txt=="") { vis bUp1,0 vis bStop1,0 @@ -1887,7 +1887,7 @@ Timer tmSerial spstr strCommand.txt,type2.txt,",",7 // get internal name spstr strCommand.txt,entn2.txt,",",8 - if(type2.txt=="delete") + if(type2.txt=="delete"||type2.txt=="") { vis bUp2,0 vis bStop2,0 @@ -1974,7 +1974,7 @@ Timer tmSerial spstr strCommand.txt,type3.txt,",",13 // get internal name spstr strCommand.txt,entn3.txt,",",14 - if(type3.txt=="delete") + if(type3.txt=="delete"||type3.txt=="") { vis bUp3,0 vis bStop3,0 @@ -2061,7 +2061,7 @@ Timer tmSerial spstr strCommand.txt,type4.txt,",",19 // get internal name spstr strCommand.txt,entn4.txt,",",20 - if(type4.txt=="delete") + if(type4.txt=="delete"||type4.txt=="") { vis bUp4,0 vis bStop4,0 diff --git a/HMI/n2t-out/nspanel_Stats.txt b/HMI/n2t-out/nspanel_Stats.txt index 0e1d96fc..25d14cd7 100644 --- a/HMI/n2t-out/nspanel_Stats.txt +++ b/HMI/n2t-out/nspanel_Stats.txt @@ -59,4 +59,4 @@ Total 13 Page(s) 330 Component(s) 3043 Line(s) of event code - 812 Unique line(s) of event code + 808 Unique line(s) of event code From bc40d09a03fa1cddec21c6e594bf11bcc5a67122 Mon Sep 17 00:00:00 2001 From: joBr99 <29555657+joBr99@users.noreply.github.com> Date: Sat, 26 Mar 2022 08:51:21 +0100 Subject: [PATCH 2/8] add overwrite for forecast's on screensaver --- apps/nspanel-lovelace-ui/luibackend/pages.py | 65 +++++++++++++++----- 1 file changed, 49 insertions(+), 16 deletions(-) diff --git a/apps/nspanel-lovelace-ui/luibackend/pages.py b/apps/nspanel-lovelace-ui/luibackend/pages.py index abeab1a7..66042351 100644 --- a/apps/nspanel-lovelace-ui/luibackend/pages.py +++ b/apps/nspanel-lovelace-ui/luibackend/pages.py @@ -56,6 +56,7 @@ class LuiPagesGen(object): self._send_mqtt_msg(f"pageType,{target_page}") def update_screensaver_weather(self, kwargs): + global babel_spec we_name = kwargs['weather'] unit = kwargs['unit'] @@ -70,23 +71,55 @@ class LuiPagesGen(object): icon_cur_detail = get_icon_id("water-percent") text_cur_detail = f"{we.attributes.humidity} %" - up1 = we.attributes.forecast[0]['datetime'] - up1 = datetime.datetime.fromisoformat(up1) - icon1 = get_icon_id_ha("weather", state=we.attributes.forecast[0]['condition']) - down1 = we.attributes.forecast[0]['temperature'] - - up2 = we.attributes.forecast[1]['datetime'] - up2 = datetime.datetime.fromisoformat(up2) - icon2 = get_icon_id_ha("weather", state=we.attributes.forecast[1]['condition']) - down2 = we.attributes.forecast[1]['temperature'] - - global babel_spec - if babel_spec is not None: - up1 = babel.dates.format_date(up1, "E", locale=self._locale) - up2 = babel.dates.format_date(up2, "E", locale=self._locale) + wOF1 = self._config.get("weatherOverrideForecast1") + if wOF1 is None: + up1 = we.attributes.forecast[0]['datetime'] + up1 = datetime.datetime.fromisoformat(up1) + if babel_spec is not None: + up1 = babel.dates.format_date(up1, "E", locale=self._locale) + else: + up1 = up1.strftime("%a") + icon1 = get_icon_id_ha("weather", state=we.attributes.forecast[0]['condition']) + down1 = we.attributes.forecast[0]['temperature'] else: - up1 = up1.strftime("%a") - up2 = up2.strftime("%a") + LOGGER.info(f"Forecast 1 is overrriden with {wOF1}") + entity = self._ha_api.get_entity(wOF1) + icon = None + name = None + if type(wOF1) is dict: + icon = next(iter(item.items()))[1].get('icon') + name = next(iter(item.items()))[1].get('name') + wOF1 = next(iter(item.items()))[0] + up1 = name if name is not None else entity.attributes.friendly_name + icon1 = get_icon_id_ha("sensor", state=entity.state, device_class=entity.attributes.get("device_class", ""), overwrite=icon) + unit_of_measurement = entity.attributes.get("unit_of_measurement", "") + down1 = entity.state + " " + unit_of_measurement + + + wOF2 = self._config.get("weatherOverrideForecast2") + if wOF2 is None: + up2 = we.attributes.forecast[0]['datetime'] + up2 = datetime.datetime.fromisoformat(up2) + if babel_spec is not None: + up2 = babel.dates.format_date(up2, "E", locale=self._locale) + else: + up2 = up2.strftime("%a") + icon2 = get_icon_id_ha("weather", state=we.attributes.forecast[0]['condition']) + down2 = we.attributes.forecast[1]['temperature'] + else: + LOGGER.info(f"Forecast 2 is overrriden with {wOF2}") + entity = self._ha_api.get_entity(wOF2) + icon = None + name = None + if type(wOF2) is dict: + icon = next(iter(item.items()))[1].get('icon') + name = next(iter(item.items()))[1].get('name') + wOF2 = next(iter(item.items()))[0] + up2 = name if name is not None else entity.attributes.friendly_name + icon2 = get_icon_id_ha("sensor", state=entity.state, device_class=entity.attributes.get("device_class", ""), overwrite=icon) + unit_of_measurement = entity.attributes.get("unit_of_measurement", "") + down2 = entity.state + " " + unit_of_measurement + self._send_mqtt_msg(f"weatherUpdate,?{icon_cur}?{text_cur}?{icon_cur_detail}?{text_cur_detail}?{up1}?{icon1}?{down1}?{up2}?{icon2}?{down2}") def generate_entities_item(self, item): From 03e4d7e44c7e51034ce87e7c468d0685d8bc51ad Mon Sep 17 00:00:00 2001 From: joBr99 <29555657+joBr99@users.noreply.github.com> Date: Sat, 26 Mar 2022 09:11:47 +0100 Subject: [PATCH 3/8] Update README.md --- README.md | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 705ea7a8..205e4c58 100644 --- a/README.md +++ b/README.md @@ -251,7 +251,6 @@ nspanel-1: config: panelRecvTopic: "tele/tasmota_your_mqtt_topic/RESULT" panelSendTopic: "cmnd/tasmota_your_mqtt_topic/CustomSend" - updateMode: "auto-notify" timeoutScreensaver: 20 #brightnessScreensaver: 10 brightnessScreensaver: @@ -259,9 +258,8 @@ nspanel-1: value: 10 - time: "23:00:00" value: 0 - locale: "de_DE" # only used if babel python package is installed - dateFormatBabel: "full" # only used if babel python package is installed - # formatting options on https://babel.pocoo.org/en/latest/dates.html?highlight=name%20of%20day#date-fields + locale: "de_DE" + dateFormatBabel: "full" timeFormat: "%H:%M" dateFormat: "%A, %d. %B %Y" # ignored if babel python package is installed weather: weather.example @@ -310,7 +308,34 @@ key | optional | type | default | description `class` | False | string | | The name of the Class. `config` | False | complex | | Config/Mapping between Homeassistant and your NsPanel -### Override Icons or Names +Possible configuration values for config key: + +key | optional | type | default | description +-- | -- | -- | -- | -- +`panelRecvTopic` | False | string | `tele/tasmota_your_mqtt_topic/RESULT` | The mqtt topic used to receive messages. +`panelSendTopic` | False | string | `cmnd/tasmota_your_mqtt_topic/CustomSend` | The mqtt topic used to send messages. +`timeoutScreensaver` | True | integer | `20` | Timeout for the screen to enter screensaver, to disable screensaver use 0 +`brightnessScreensaver` | True | integer/complex | `20` | Brightness for the screen to enter screensaver, see example below for complex/scheduled config. +`locale` | True | string | `en_US` | Used by babel to determinante Date format on screensaver, also used for localization. +`dateFormatBabel` | True | string | `full` | formatting options on https://babel.pocoo.org/en/latest/dates.html?highlight=name%20of%20day#date-fields +`timeFormat` | True | string | `%H:%M` | Time Format on screensaver. Substring after `?` is displayed in a seperate smaller textbox. Useful for 12h time format with AM/PM `"%I:%M ?%p"` +`dateFormat` | True | string | `%A, %d. %B %Y` | date format used if babel is not installed +`weather` | True | string | `weather.example` | weather entity from homeassistant +`pages` | False | complex | | configuration for pages on panel + +#### Schedule screensaver brightness + +It is possible to schedule a brightness change for the screen at specific times. + +``` + brightnessScreensaver: + - time: "7:00:00" + value: 10 + - time: "23:00:00" + value: 0 +``` + +#### Override Icons or Names To override Icons or Names of entities you can configure an icon and/or name in your configuration, please see the following example. Only the icons listed in the [Icon Table](HMI#icons-ids) are useable. From 033088e40fccbd1f26d62936fb339e568594f207 Mon Sep 17 00:00:00 2001 From: joBr99 <29555657+joBr99@users.noreply.github.com> Date: Sat, 26 Mar 2022 09:12:21 +0100 Subject: [PATCH 4/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 205e4c58..c7f830fb 100644 --- a/README.md +++ b/README.md @@ -327,7 +327,7 @@ key | optional | type | default | description It is possible to schedule a brightness change for the screen at specific times. -``` +```yaml brightnessScreensaver: - time: "7:00:00" value: 10 From 0038c038b5478bc9664cf74e4b4a950864966d6a Mon Sep 17 00:00:00 2001 From: joBr99 <29555657+joBr99@users.noreply.github.com> Date: Sat, 26 Mar 2022 09:14:49 +0100 Subject: [PATCH 5/8] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c7f830fb..7fbbe6d6 100644 --- a/README.md +++ b/README.md @@ -321,6 +321,8 @@ key | optional | type | default | description `timeFormat` | True | string | `%H:%M` | Time Format on screensaver. Substring after `?` is displayed in a seperate smaller textbox. Useful for 12h time format with AM/PM `"%I:%M ?%p"` `dateFormat` | True | string | `%A, %d. %B %Y` | date format used if babel is not installed `weather` | True | string | `weather.example` | weather entity from homeassistant +`weatherOverrideForecast1` | True | string | `None` | sensor entity from home assistant here to override the first weather forecast item on the screensaver +`weatherOverrideForecast2` | True | string | `None` | sensor entity from home assistant here to override the second weather forecast item on the screensaver `pages` | False | complex | | configuration for pages on panel #### Schedule screensaver brightness From 91c4ea567b11fce38f44edea4221dfdf0e916f94 Mon Sep 17 00:00:00 2001 From: Gerard Date: Sat, 26 Mar 2022 09:46:26 +0100 Subject: [PATCH 6/8] Fix weather forecast Show the correct day and icon for day 2 --- apps/nspanel-lovelace-ui/luibackend/pages.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/nspanel-lovelace-ui/luibackend/pages.py b/apps/nspanel-lovelace-ui/luibackend/pages.py index 66042351..17ec9994 100644 --- a/apps/nspanel-lovelace-ui/luibackend/pages.py +++ b/apps/nspanel-lovelace-ui/luibackend/pages.py @@ -98,13 +98,13 @@ class LuiPagesGen(object): wOF2 = self._config.get("weatherOverrideForecast2") if wOF2 is None: - up2 = we.attributes.forecast[0]['datetime'] + up2 = we.attributes.forecast[1]['datetime'] up2 = datetime.datetime.fromisoformat(up2) if babel_spec is not None: up2 = babel.dates.format_date(up2, "E", locale=self._locale) else: up2 = up2.strftime("%a") - icon2 = get_icon_id_ha("weather", state=we.attributes.forecast[0]['condition']) + icon2 = get_icon_id_ha("weather", state=we.attributes.forecast[1]['condition']) down2 = we.attributes.forecast[1]['temperature'] else: LOGGER.info(f"Forecast 2 is overrriden with {wOF2}") From d670ea9c29d3b2fa474e8fd3a5ef2d6c1c1afcf0 Mon Sep 17 00:00:00 2001 From: joBr99 <29555657+joBr99@users.noreply.github.com> Date: Sat, 26 Mar 2022 09:55:15 +0100 Subject: [PATCH 7/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7fbbe6d6..0879351d 100644 --- a/README.md +++ b/README.md @@ -202,7 +202,7 @@ Due the limitations of Berry, it's not possible to download the tft file directl The following Link has always the latest version from this repository, just execute the following Command in Tasmota: -`FlashNextion http://nspanel.pky.eu/lui.tft` +`FlashNextion http://nspanel.pky.eu/lui-release.tft` ## Configuration From a6747d8e9309998ad778f3541ecaf3e0c2578c26 Mon Sep 17 00:00:00 2001 From: joBr99 <29555657+joBr99@users.noreply.github.com> Date: Sat, 26 Mar 2022 09:57:37 +0100 Subject: [PATCH 8/8] fix current_page on nested page nav --- apps/nspanel-lovelace-ui/luibackend/controller.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/nspanel-lovelace-ui/luibackend/controller.py b/apps/nspanel-lovelace-ui/luibackend/controller.py index cd4db39e..defe5d09 100644 --- a/apps/nspanel-lovelace-ui/luibackend/controller.py +++ b/apps/nspanel-lovelace-ui/luibackend/controller.py @@ -144,8 +144,8 @@ class LuiController(object): if button_type == "button": if entity_id.startswith('navigate'): # internal for navigation to nested pages - topage = self._config.get_root_page().search_page_by_name(entity_id)[0] - self._pages_gen.render_page(topage) + self._current_page = self._config.get_root_page().search_page_by_name(entity_id)[0] + self._pages_gen.render_page(self._current_page) elif entity_id.startswith('scene'): self._ha_api.get_entity(entity_id).call_service("turn_on") elif entity_id.startswith('light') or entity_id.startswith('switch') or entity_id.startswith('input_boolean'):