added code for model change in config

This commit is contained in:
joBr99
2022-03-30 12:18:38 +02:00
parent 89b35d39b3
commit c5de4863f9
4 changed files with 26 additions and 16 deletions

View File

@@ -101,7 +101,6 @@ class LuiBackendConfig(object):
'panelSendTopic': "cmnd/tasmota_your_mqtt_topic/CustomSend", 'panelSendTopic': "cmnd/tasmota_your_mqtt_topic/CustomSend",
'updateMode': "auto-notify", 'updateMode': "auto-notify",
'model': "eu", 'model': "eu",
'orientation': "landscape",
'timeoutScreensaver': 20, 'timeoutScreensaver': 20,
'brightnessScreensaver': 20, 'brightnessScreensaver': 20,
'brightnessScreensaverTracking': None, 'brightnessScreensaverTracking': None,

View File

@@ -32,7 +32,10 @@ class LuiMqttListener(object):
if msg[0] == "event": if msg[0] == "event":
if msg[1] == "startup": if msg[1] == "startup":
display_firmware_version = int(msg[2]) display_firmware_version = int(msg[2])
self._updater.set_current_display_firmware_version(display_firmware_version) model = None
if display_firmware_version >= 23:
model = msg[2]
self._updater.set_current_display_firmware_version(display_firmware_version, model)
# check for updates # check for updates
msg_send = self._updater.check_updates() msg_send = self._updater.check_updates()
# send messages for current page # send messages for current page

View File

@@ -3,8 +3,9 @@ import logging
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
class Updater: class Updater:
def __init__(self, send_mqtt_msg, topic_send, mode, desired_display_firmware_version, desired_display_firmware_url, desired_tasmota_driver_version, desired_tasmota_driver_url): def __init__(self, send_mqtt_msg, topic_send, mode, desired_display_firmware_version, desired_display_firmware_model, desired_display_firmware_url, desired_tasmota_driver_version, desired_tasmota_driver_url):
self.desired_display_firmware_version = desired_display_firmware_version self.desired_display_firmware_version = desired_display_firmware_version
self.desired_display_firmware_model = desired_display_firmware_model
self.desired_display_firmware_url = desired_display_firmware_url self.desired_display_firmware_url = desired_display_firmware_url
self.desired_tasmota_driver_version = desired_tasmota_driver_version self.desired_tasmota_driver_version = desired_tasmota_driver_version
self.desired_tasmota_driver_url = desired_tasmota_driver_url self.desired_tasmota_driver_url = desired_tasmota_driver_url
@@ -14,11 +15,13 @@ class Updater:
self.topic_send = topic_send self.topic_send = topic_send
self.current_tasmota_driver_version = None self.current_tasmota_driver_version = None
self.current_display_firmware_version = None self.current_display_firmware_version = None
self.current_display_model = 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_display_firmware_version(self, panel_version): def set_current_display_firmware_version(self, panel_version, panel_model=None):
self.current_display_firmware_version = panel_version self.current_display_firmware_version = panel_version
self.current_display_model = panel_model
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
@@ -52,6 +55,13 @@ class Updater:
self.send_message_page("updateBerryNoYes", "Driver Update available!", update_msg, "Dismiss", "Yes") self.send_message_page("updateBerryNoYes", "Driver Update available!", update_msg, "Dismiss", "Yes")
return True return True
return False return False
# check if model has changed
if self.current_display_model is not None and current_display_model != self.desired_display_firmware_model:
LOGGER.info("Mismatch between Display Firmware and configured model")
update_msg = "The configured display firmware model has changed, do you wanto to start the update now? If the update fails check the installation manual and flash your version again over the Tasmota console. Be patient, the update will take a while."
self.send_message_page("updateDisplayNoYes", "Display Update available!", update_msg, "Dismiss", "Yes")
return True
# check if display firmware needs an update # check if display firmware needs an update
if self.current_display_firmware_version < self.desired_display_firmware_version: if self.current_display_firmware_version < self.desired_display_firmware_version:
LOGGER.info("Update of Display Firmware needed") LOGGER.info("Update of Display Firmware needed")

View File

@@ -65,20 +65,18 @@ class NsPanelLovelaceUIManager(hass.Hass):
controller = LuiController(self, cfg, send_mqtt_msg) controller = LuiController(self, cfg, send_mqtt_msg)
desired_display_firmware_version = 22 desired_display_firmware_version = 22
version = "v2.1.0"
version = "v2.0.0"
model = cfg.get("model") model = cfg.get("model")
orientation = cfg.get("orientation") if model == "us-l":
if model == "us": # us landscape version
if orientation == "landscape": desired_display_firmware_url = f"http://nspanel.pky.eu/lovelace-ui/github/nspanel-us-l-{version}.tft"
# us landscape version elif: model == "us-p":
desired_display_firmware_url = f"http://nspanel.pky.eu/lovelace-ui/github/nspanel-us-l-{version}.tft" # us portrait version
else: desired_display_firmware_url = f"http://nspanel.pky.eu/lovelace-ui/github/nspanel-us-p-{version}.tft"
# us portrait version
desired_display_firmware_url = f"http://nspanel.pky.eu/lovelace-ui/github/nspanel-us-p-{version}.tft"
else: else:
# eu version # eu version
desired_display_firmware_url = f"http://nspanel.pky.eu/lovelace-ui/github/nspanel-{version}.tft" desired_display_firmware_url = f"http://nspanel.pky.eu/lovelace-ui/github/nspanel-{version}.tft"
desired_tasmota_driver_version = 3 desired_tasmota_driver_version = 3
@@ -86,7 +84,7 @@ class NsPanelLovelaceUIManager(hass.Hass):
mode = cfg.get("updateMode") mode = cfg.get("updateMode")
topic_send = cfg.get("panelSendTopic") topic_send = cfg.get("panelSendTopic")
updater = Updater(send_mqtt_msg, topic_send, mode, desired_display_firmware_version, desired_display_firmware_url, desired_tasmota_driver_version, desired_tasmota_driver_url) updater = Updater(send_mqtt_msg, topic_send, mode, desired_display_firmware_version, model, desired_display_firmware_url, desired_tasmota_driver_version, desired_tasmota_driver_url)
topic_recv = cfg.get("panelRecvTopic") topic_recv = cfg.get("panelRecvTopic")
LuiMqttListener(mqtt_api, topic_recv, controller, updater) LuiMqttListener(mqtt_api, topic_recv, controller, updater)