Merge branch 'joBr99:main' into main

This commit is contained in:
britzelpuf
2022-03-20 21:52:18 +01:00
committed by GitHub
11 changed files with 83 additions and 52 deletions

View File

@@ -15,9 +15,9 @@ cardMedia
210 Line(s) of event code 210 Line(s) of event code
116 Unique line(s) of event code 116 Unique line(s) of event code
popupNotify popupNotify
16 Component(s) 17 Component(s)
167 Line(s) of event code 171 Line(s) of event code
111 Unique line(s) of event code 113 Unique line(s) of event code
pageStartup pageStartup
19 Component(s) 19 Component(s)
146 Line(s) of event code 146 Line(s) of event code
@@ -26,14 +26,14 @@ pageSwipeTest
18 Component(s) 18 Component(s)
62 Line(s) of event code 62 Line(s) of event code
44 Unique line(s) of event code 44 Unique line(s) of event code
popupShutter
19 Component(s)
195 Line(s) of event code
107 Unique line(s) of event code
pageTest pageTest
14 Component(s) 14 Component(s)
14 Line(s) of event code 14 Line(s) of event code
14 Unique line(s) of event code 14 Unique line(s) of event code
popupShutter
19 Component(s)
194 Line(s) of event code
106 Unique line(s) of event code
screensaver screensaver
25 Component(s) 25 Component(s)
173 Line(s) of event code 173 Line(s) of event code
@@ -56,11 +56,11 @@ cardGrid
224 Unique line(s) of event code 224 Unique line(s) of event code
popupLight popupLight
27 Component(s) 27 Component(s)
339 Line(s) of event code 338 Line(s) of event code
171 Unique line(s) of event code 170 Unique line(s) of event code
Total Total
14 Page(s) 14 Page(s)
342 Component(s) 343 Component(s)
3170 Line(s) of event code 3172 Line(s) of event code
787 Unique line(s) of event code 789 Unique line(s) of event code

View File

@@ -402,7 +402,7 @@ Text tVersion
Horizontal Alignment : center Horizontal Alignment : center
Vertical Alignment : center Vertical Alignment : center
Input Type : character Input Type : character
Text : 6 Text : 11
Max. Text Size : 10 Max. Text Size : 10
Word wrap : disabled Word wrap : disabled
Horizontal Spacing : 0 Horizontal Spacing : 0
@@ -605,7 +605,7 @@ Timer tmSerial
{ {
page pageStartup page pageStartup
} }
if(tId.txt=="pageNotify") if(tId.txt=="popupNotify")
{ {
page popupNotify page popupNotify
} }

View File

@@ -942,7 +942,6 @@ Timer tmSerial
// get value // get value
spstr strCommand.txt,tTmp.txt,",",1 spstr strCommand.txt,tTmp.txt,",",1
covx tTmp.txt,dimValue,0,0 covx tTmp.txt,dimValue,0,0
dim=dimValue
} }
if(tInstruction.txt=="timeout") if(tInstruction.txt=="timeout")
{ {

View File

@@ -31,7 +31,7 @@ Variable (string) strCommand
ID : 8 ID : 8
Scope : local Scope : local
Text : Text :
Max. Text Size: 600 Max. Text Size: 1000
Variable (string) entn Variable (string) entn
Attributes Attributes
@@ -40,6 +40,12 @@ Variable (string) entn
Text : Text :
Max. Text Size: 30 Max. Text Size: 30
Variable (int32) vaOldSleepT
Attributes
ID : 16
Scope: local
Value: 0
Text tSend Text tSend
Attributes Attributes
ID : 3 ID : 3
@@ -271,6 +277,7 @@ Button b0
Events Events
Touch Press Event Touch Press Event
sleepTimeout=vaOldSleepT.val
//page open event //page open event
// event,pageOpen,cardEntities,pageNumber // event,pageOpen,cardEntities,pageNumber
// craft command // craft command
@@ -323,6 +330,7 @@ Button b2
Events Events
Touch Press Event Touch Press Event
sleepTimeout=vaOldSleepT.val
//craft command //craft command
tSend.txt="event,buttonPress,D,D,"+entn.txt+",1,notifyAction,yes" tSend.txt="event,buttonPress,D,D,"+entn.txt+",1,notifyAction,yes"
//send calc crc //send calc crc
@@ -371,6 +379,7 @@ Button b1
Events Events
Touch Press Event Touch Press Event
sleepTimeout=vaOldSleepT.val
//craft command //craft command
tSend.txt="event,buttonPress,D,D,"+entn.txt+",1,notifyAction,no" tSend.txt="event,buttonPress,D,D,"+entn.txt+",1,notifyAction,no"
//send calc crc //send calc crc
@@ -493,6 +502,8 @@ Timer tmSerial
spstr strCommand.txt,tTmp.txt,"|",9 spstr strCommand.txt,tTmp.txt,"|",9
covx tTmp.txt,sys0,0,0 covx tTmp.txt,sys0,0,0
tText.pco=sys0 tText.pco=sys0
//preserve old sleepTimeout
vaOldSleepT.val=sleepTimeout
// sleep timeout // sleep timeout
spstr strCommand.txt,tTmp.txt,"|",9 spstr strCommand.txt,tTmp.txt,"|",9
covx tTmp.txt,sys0,0,0 covx tTmp.txt,sys0,0,0
@@ -513,7 +524,6 @@ Timer tmSerial
// get value // get value
spstr strCommand.txt,tTmp.txt,",",1 spstr strCommand.txt,tTmp.txt,",",1
covx tTmp.txt,dimValue,0,0 covx tTmp.txt,dimValue,0,0
dim=dimValue
} }
if(tInstruction.txt=="timeout") if(tInstruction.txt=="timeout")
{ {
@@ -523,6 +533,7 @@ Timer tmSerial
} }
if(tInstruction.txt=="pageType") if(tInstruction.txt=="pageType")
{ {
sleepTimeout=vaOldSleepT.val
//command format pageType,specialPageName //command format pageType,specialPageName
//write name of speical page to tId //write name of speical page to tId
spstr strCommand.txt,tId.txt,",",1 spstr strCommand.txt,tId.txt,",",1

View File

@@ -631,7 +631,6 @@ Timer tmSerial
// get value // get value
spstr strCommand.txt,tTmp.txt,",",1 spstr strCommand.txt,tTmp.txt,",",1
covx tTmp.txt,dimValue,0,0 covx tTmp.txt,dimValue,0,0
dim=dimValue
} }
if(tInstruction.txt=="time") if(tInstruction.txt=="time")
{ {

Binary file not shown.

Binary file not shown.

View File

@@ -250,7 +250,8 @@ nspanel-1:
config: config:
panelRecvTopic: "tele/tasmota_your_mqtt_topic/RESULT" panelRecvTopic: "tele/tasmota_your_mqtt_topic/RESULT"
panelSendTopic: "cmnd/tasmota_your_mqtt_topic/CustomSend" panelSendTopic: "cmnd/tasmota_your_mqtt_topic/CustomSend"
timeoutScreensaver: 15 #in seconds, values between 5 and 60 are allowed updateMode: auto-notify # possible values are auto, auto-notify and manual
timeoutScreensaver: 15 #in seconds
#brightnessScreensaver: 10 #brightnessScreensaver: 10
brightnessScreensaver: brightnessScreensaver:
- time: "7:00:00" - time: "7:00:00"

View File

@@ -5,7 +5,8 @@ nspanel:
config: config:
panelRecvTopic: "tele/tasmota_your_mqtt_topic/RESULT" panelRecvTopic: "tele/tasmota_your_mqtt_topic/RESULT"
panelSendTopic: "cmnd/tasmota_your_mqtt_topic/CustomSend" panelSendTopic: "cmnd/tasmota_your_mqtt_topic/CustomSend"
timeoutScreensaver: 15 #in seconds, values between 5 and 60 are allowed updateMode: auto-notify # possible values are auto, auto-notify and manual
timeoutScreensaver: 15 #in seconds
#brightnessScreensaver: 10 #brightnessScreensaver: 10
brightnessScreensaver: brightnessScreensaver:
- time: "7:00:00" - time: "7:00:00"

View File

@@ -18,48 +18,66 @@ class NsPanelLovelaceUIManager(hass.Hass):
class Updater: class Updater:
def __init__(self, nsplui, mode): def __init__(self, nsplui, mode):
self.desired_display_firmware_version = 6 self.desired_display_firmware_version = 11
self.desired_display_firmware_url = "http://nspanel.pky.eu/lovelace-ui/github/nspanel-a023d2e.tft" self.desired_display_firmware_url = "http://nspanel.pky.eu/lovelace-ui/github/nspanel-b0027d4.tft"
self.desired_tasmota_driver_version = 3 self.desired_tasmota_driver_version = 3
self.desired_tasmota_driver_url = "https://raw.githubusercontent.com/joBr99/nspanel-lovelace-ui/main/tasmota/autoexec.be" self.desired_tasmota_driver_url = "https://raw.githubusercontent.com/joBr99/nspanel-lovelace-ui/main/tasmota/autoexec.be"
self.mode = mode self.mode = mode
self.nsplui = nsplui self.nsplui = nsplui
self.current_tasmota_driver_version = None self.current_tasmota_driver_version = None
self.current_panel_version = None self.current_display_firmware_version = None
def set_tasmota_driver_version(self, driver_version): def set_tasmota_driver_version(self, driver_version):
self.current_tasmota_driver_version = driver_version self.current_tasmota_driver_version = driver_version
def set_current_panel_version(self, panel_version): def set_current_display_firmware_version(self, panel_version):
self.current_panel_version = panel_version self.current_display_firmware_version = panel_version
def check_pre_req(self): def check_pre_req(self):
# we need to know both versions to continue # we need to know both versions to continue
if self.current_tasmota_driver_version is not None and self.current_panel_version is not None: if self.current_tasmota_driver_version is not None and self.current_display_firmware_version is not None:
# tasmota driver has to be at least version 2 for Update command and panel has to be at version 5 for notify commands # tasmota driver has to be at least version 2 for Update command and panel has to be at version 11 for notify commands
if self.current_tasmota_driver_version >= 2 and self.current_panel_version >= 5: if self.current_tasmota_driver_version >= 2 and self.current_display_firmware_version >= 11:
return True return True
return False return False
def check_updates(self): def check_updates(self):
# return's true if a notification was send to the panel
# run pre req check # run pre req check
if self.check_pre_req(): if self.check_pre_req():
self.nsplui.api.log("Update Pre-Check sucessful Tasmota Driver Version: %s Panel Version: %s", self.current_tasmota_driver_version, self.current_panel_version, level="DEBUG") self.nsplui.api.log("Update Pre-Check sucessful Tasmota Driver Version: %s Panel Version: %s", self.current_tasmota_driver_version, self.current_display_firmware_version, level="DEBUG")
# tasmota driver needs update # check if tasmota driver needs update
if self.current_tasmota_driver_version < self.desired_tasmota_driver_version: if self.current_tasmota_driver_version < self.desired_tasmota_driver_version:
self.nsplui.api.log("Update of Tasmota Driver needed") self.nsplui.api.log("Update of Tasmota Driver needed")
# in auto mode just do the update # in auto mode just do the update
if self.mode == "auto": if self.mode == "auto":
self.update_berry_driver() self.update_berry_driver()
return return False
# send notification about the update # send notification about the update
if self.mode == "auto-notify": if self.mode == "auto-notify":
self.nsplui.send_message_page("updateBerryNoYes", "Driver Update available!", "There's an update avalible for the tasmota berry driver, do you want to start the update now?", "Dismiss", "Yes") update_msg = "There's an update avalible for the tasmota berry driver, do you want to start the update now? If you encounter issues after the update or this message appears frequently, please checkthe manual and repeat the installation steps for the tasmota berry driver. "
return self.nsplui.send_message_page("updateBerryNoYes", "Driver Update available!", update_msg, "Dismiss", "Yes")
return True
return False
# check if display firmware needs an update
if self.current_display_firmware_version < self.desired_display_firmware_version:
self.nsplui.api.log("Update of Display Firmware needed")
# in auto mode just do the update
if self.mode == "auto":
self.update_panel_driver()
return False
# send notification about the update
if self.mode == "auto-notify":
update_msg = "There's a firmware update avalible for the nextion sceen inside of nspanel, do you want to start the update now? If the update fails check the installation manual and flash again over the tasmota console. Be pationed the update will take a while."
self.nsplui.send_message_page("updateDisplayNoYes", "Display Update available!", update_msg, "Dismiss", "Yes")
return True
return False
else: else:
self.nsplui.api.log("Update Pre-Check failed Tasmota Driver Version: %s Panel Version: %s", self.current_tasmota_driver_version, self.current_panel_version) self.nsplui.api.log("Update Pre-Check failed Tasmota Driver Version: %s Panel Version: %s", self.current_tasmota_driver_version, self.current_display_firmware_version)
return False
def update_berry_driver(self): def update_berry_driver(self):
self.nsplui.mqtt.mqtt_publish(self.config["panelSendTopic"].replace("CustomSend", "UpdateDriverVersion"), desired_tasmota_driver_url) self.nsplui.mqtt.mqtt_publish(self.nsplui.config["panelSendTopic"].replace("CustomSend", "UpdateDriverVersion"), self.desired_tasmota_driver_url)
def update_panel_driver(self): def update_panel_driver(self):
self.nsplui.mqtt.mqtt_publish(self.config["panelSendTopic"].replace("CustomSend", "FlashNextion"), desired_display_firmware_url) self.nsplui.mqtt.mqtt_publish(self.nsplui.config["panelSendTopic"].replace("CustomSend", "FlashNextion"), self.desired_display_firmware_url)
class NsPanelLovelaceUI: class NsPanelLovelaceUI:
def __init__(self, api, config): def __init__(self, api, config):
self.api = api self.api = api
@@ -75,10 +93,10 @@ class NsPanelLovelaceUI:
self.mqtt.mqtt_subscribe(topic=self.config["panelRecvTopic"]) self.mqtt.mqtt_subscribe(topic=self.config["panelRecvTopic"])
self.mqtt.listen_event(self.handle_mqtt_incoming_message, "MQTT_MESSAGE", topic=self.config["panelRecvTopic"], namespace='mqtt') self.mqtt.listen_event(self.handle_mqtt_incoming_message, "MQTT_MESSAGE", topic=self.config["panelRecvTopic"], namespace='mqtt')
if "update_mode" in self.config: if "updateMode" in self.config:
update_mode = self.config["update_mode"] update_mode = self.config["updateMode"]
else: else:
update_mode = "manual" update_mode = "auto-notify"
self.updater = Updater(self, update_mode) self.updater = Updater(self, update_mode)
@@ -123,7 +141,7 @@ class NsPanelLovelaceUI:
self.register_callbacks() self.register_callbacks()
def send_mqtt_msg(self,msg): def send_mqtt_msg(self,msg):
self.api.log("Send Message from Tasmota: %s", msg) #, level="DEBUG" self.api.log("Send Message to Tasmota: %s", msg) #, level="DEBUG"
self.mqtt.mqtt_publish(self.config["panelSendTopic"], msg) self.mqtt.mqtt_publish(self.config["panelSendTopic"], msg)
def handle_mqtt_incoming_message(self, event_name, data, kwargs): def handle_mqtt_incoming_message(self, event_name, data, kwargs):
@@ -151,7 +169,7 @@ class NsPanelLovelaceUI:
self.api.log("Handling startup event", level="DEBUG") self.api.log("Handling startup event", level="DEBUG")
# grab version from screen and pass to updater class # grab version from screen and pass to updater class
self.updater.set_current_panel_version(int(msg[2])) self.updater.set_current_display_firmware_version(int(msg[2]))
# send date and time # send date and time
self.update_time("") self.update_time("")
@@ -164,11 +182,12 @@ class NsPanelLovelaceUI:
# send screensaver brightness # send screensaver brightness
self.update_screensaver_brightness(kwargs={"value": self.current_screensaver_brightness}) self.update_screensaver_brightness(kwargs={"value": self.current_screensaver_brightness})
# send messages for current page
self.generate_page(self.current_page_nr)
# check for updates # check for updates
self.updater.check_updates() msg_send = self.updater.check_updates()
# send messages for current page
if not msg_send:
self.generate_page(self.current_page_nr)
if msg[1] == "pageOpen": if msg[1] == "pageOpen":
# Calculate current page # Calculate current page
@@ -263,14 +282,15 @@ class NsPanelLovelaceUI:
def handle_button_press(self, entity_id, btype, optVal=None): def handle_button_press(self, entity_id, btype, optVal=None):
if entity_id == "updateBerryNoYes" and optVal == "yes": if entity_id == "updateBerryNoYes" and optVal == "yes":
self.update.update_berry_driver() # go back to main page before starting the update
self.generate_page(self.current_page_nr) self.generate_page(self.current_page_nr)
self.updater.update_berry_driver()
elif entity_id == "updateBerryNoYes" and optVal == "no": elif entity_id == "updateBerryNoYes" and optVal == "no":
self.generate_page(self.current_page_nr) self.generate_page(self.current_page_nr)
if entity_id == "updatePanelNoYes" and optVal == "yes": if entity_id == "updateDisplayNoYes" and optVal == "yes":
self.update.update_panel_driver() self.updater.update_panel_driver()
elif entity_id == "updatePanelNoYes" and optVal == "no": elif entity_id == "updateDisplayNoYes" and optVal == "no":
self.generate_page(self.current_page_nr) self.generate_page(self.current_page_nr)
if btype == "OnOff": if btype == "OnOff":
@@ -462,7 +482,6 @@ class NsPanelLovelaceUI:
if item_type == "switch" or item_type == "input_boolean": if item_type == "switch" or item_type == "input_boolean":
switch_val = 1 if entity.state == "on" else 0 switch_val = 1 if entity.state == "on" else 0
icon_id = get_icon_id("flash") icon_id = get_icon_id("flash")
self.api.log("test_test: %s", item_type)
if item_type == "input_boolean": if item_type == "input_boolean":
if switch_val == 1: if switch_val == 1:
icon_id = get_icon_id("check-circle-outline") icon_id = get_icon_id("check-circle-outline")

View File

@@ -11,7 +11,8 @@ nspanel-1:
config: config:
panelRecvTopic: "tele/tasmota_your_mqtt_topic/RESULT" panelRecvTopic: "tele/tasmota_your_mqtt_topic/RESULT"
panelSendTopic: "cmnd/tasmota_your_mqtt_topic/CustomSend" panelSendTopic: "cmnd/tasmota_your_mqtt_topic/CustomSend"
timeoutScreensaver: 15 #in seconds, values between 5 and 60 are allowed updateMode: auto-notify # possible values are auto, auto-notify and manual
timeoutScreensaver: 15 #in seconds
#brightnessScreensaver: 10 #brightnessScreensaver: 10
brightnessScreensaver: brightnessScreensaver:
- time: "7:00:00" - time: "7:00:00"