This commit is contained in:
Johannes
2022-03-26 10:31:02 +01:00
5 changed files with 89 additions and 29 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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
@@ -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,36 @@ 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
`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
It is possible to schedule a brightness change for the screen at specific times.
```yaml
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.

View File

@@ -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'):

View File

@@ -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[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[1]['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):