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
116 Unique line(s) of event code
popupNotify
16 Component(s)
167 Line(s) of event code
111 Unique line(s) of event code
17 Component(s)
171 Line(s) of event code
113 Unique line(s) of event code
pageStartup
19 Component(s)
146 Line(s) of event code
@@ -26,14 +26,14 @@ pageSwipeTest
18 Component(s)
62 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
14 Component(s)
14 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
25 Component(s)
173 Line(s) of event code
@@ -56,11 +56,11 @@ cardGrid
224 Unique line(s) of event code
popupLight
27 Component(s)
339 Line(s) of event code
171 Unique line(s) of event code
338 Line(s) of event code
170 Unique line(s) of event code
Total
14 Page(s)
342 Component(s)
3170 Line(s) of event code
787 Unique line(s) of event code
343 Component(s)
3172 Line(s) of event code
789 Unique line(s) of event code

View File

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

View File

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

View File

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

View File

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

Binary file not shown.

Binary file not shown.

View File

@@ -250,7 +250,8 @@ nspanel-1:
config:
panelRecvTopic: "tele/tasmota_your_mqtt_topic/RESULT"
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:
- time: "7:00:00"

View File

@@ -5,7 +5,8 @@ nspanel:
config:
panelRecvTopic: "tele/tasmota_your_mqtt_topic/RESULT"
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:
- time: "7:00:00"

View File

@@ -18,48 +18,66 @@ class NsPanelLovelaceUIManager(hass.Hass):
class Updater:
def __init__(self, nsplui, mode):
self.desired_display_firmware_version = 6
self.desired_display_firmware_url = "http://nspanel.pky.eu/lovelace-ui/github/nspanel-a023d2e.tft"
self.desired_display_firmware_version = 11
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_url = "https://raw.githubusercontent.com/joBr99/nspanel-lovelace-ui/main/tasmota/autoexec.be"
self.mode = mode
self.nsplui = nsplui
self.current_tasmota_driver_version = None
self.current_panel_version = None
self.current_tasmota_driver_version = None
self.current_display_firmware_version = None
def set_tasmota_driver_version(self, driver_version):
self.current_tasmota_driver_version = driver_version
def set_current_panel_version(self, panel_version):
self.current_panel_version = panel_version
def set_current_display_firmware_version(self, panel_version):
self.current_display_firmware_version = panel_version
def check_pre_req(self):
# 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:
# tasmota driver has to be at least version 2 for Update command and panel has to be at version 5 for notify commands
if self.current_tasmota_driver_version >= 2 and self.current_panel_version >= 5:
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 11 for notify commands
if self.current_tasmota_driver_version >= 2 and self.current_display_firmware_version >= 11:
return True
return False
def check_updates(self):
# return's true if a notification was send to the panel
# run pre req check
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")
# tasmota driver needs update
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")
# check if tasmota driver needs update
if self.current_tasmota_driver_version < self.desired_tasmota_driver_version:
self.nsplui.api.log("Update of Tasmota Driver needed")
# in auto mode just do the update
if self.mode == "auto":
self.update_berry_driver()
return
return False
# send notification about the update
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")
return
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. "
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:
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):
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):
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:
def __init__(self, api, config):
self.api = api
@@ -75,10 +93,10 @@ class NsPanelLovelaceUI:
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')
if "update_mode" in self.config:
update_mode = self.config["update_mode"]
if "updateMode" in self.config:
update_mode = self.config["updateMode"]
else:
update_mode = "manual"
update_mode = "auto-notify"
self.updater = Updater(self, update_mode)
@@ -123,7 +141,7 @@ class NsPanelLovelaceUI:
self.register_callbacks()
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)
def handle_mqtt_incoming_message(self, event_name, data, kwargs):
@@ -151,7 +169,7 @@ class NsPanelLovelaceUI:
self.api.log("Handling startup event", level="DEBUG")
# 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
self.update_time("")
@@ -164,11 +182,12 @@ class NsPanelLovelaceUI:
# send 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
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":
# Calculate current page
@@ -263,14 +282,15 @@ class NsPanelLovelaceUI:
def handle_button_press(self, entity_id, btype, optVal=None):
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.updater.update_berry_driver()
elif entity_id == "updateBerryNoYes" and optVal == "no":
self.generate_page(self.current_page_nr)
if entity_id == "updatePanelNoYes" and optVal == "yes":
self.update.update_panel_driver()
elif entity_id == "updatePanelNoYes" and optVal == "no":
if entity_id == "updateDisplayNoYes" and optVal == "yes":
self.updater.update_panel_driver()
elif entity_id == "updateDisplayNoYes" and optVal == "no":
self.generate_page(self.current_page_nr)
if btype == "OnOff":
@@ -462,7 +482,6 @@ class NsPanelLovelaceUI:
if item_type == "switch" or item_type == "input_boolean":
switch_val = 1 if entity.state == "on" else 0
icon_id = get_icon_id("flash")
self.api.log("test_test: %s", item_type)
if item_type == "input_boolean":
if switch_val == 1:
icon_id = get_icon_id("check-circle-outline")

View File

@@ -11,7 +11,8 @@ nspanel-1:
config:
panelRecvTopic: "tele/tasmota_your_mqtt_topic/RESULT"
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:
- time: "7:00:00"