mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-23 16:04:25 +01:00
added code for model change in config
This commit is contained in:
@@ -101,7 +101,6 @@ class LuiBackendConfig(object):
|
||||
'panelSendTopic': "cmnd/tasmota_your_mqtt_topic/CustomSend",
|
||||
'updateMode': "auto-notify",
|
||||
'model': "eu",
|
||||
'orientation': "landscape",
|
||||
'timeoutScreensaver': 20,
|
||||
'brightnessScreensaver': 20,
|
||||
'brightnessScreensaverTracking': None,
|
||||
|
||||
@@ -32,7 +32,10 @@ class LuiMqttListener(object):
|
||||
if msg[0] == "event":
|
||||
if msg[1] == "startup":
|
||||
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
|
||||
msg_send = self._updater.check_updates()
|
||||
# send messages for current page
|
||||
|
||||
@@ -3,8 +3,9 @@ import logging
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
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_model = desired_display_firmware_model
|
||||
self.desired_display_firmware_url = desired_display_firmware_url
|
||||
self.desired_tasmota_driver_version = desired_tasmota_driver_version
|
||||
self.desired_tasmota_driver_url = desired_tasmota_driver_url
|
||||
@@ -14,11 +15,13 @@ class Updater:
|
||||
self.topic_send = topic_send
|
||||
self.current_tasmota_driver_version = None
|
||||
self.current_display_firmware_version = None
|
||||
self.current_display_model = None
|
||||
|
||||
def set_tasmota_driver_version(self, driver_version):
|
||||
self.current_tasmota_driver_version = driver_version
|
||||
def set_current_display_firmware_version(self, panel_version):
|
||||
self.current_tasmota_driver_version = driver_version
|
||||
def set_current_display_firmware_version(self, panel_version, panel_model=None):
|
||||
self.current_display_firmware_version = panel_version
|
||||
self.current_display_model = panel_model
|
||||
|
||||
def check_pre_req(self):
|
||||
# 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")
|
||||
return True
|
||||
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
|
||||
if self.current_display_firmware_version < self.desired_display_firmware_version:
|
||||
LOGGER.info("Update of Display Firmware needed")
|
||||
|
||||
@@ -65,20 +65,18 @@ class NsPanelLovelaceUIManager(hass.Hass):
|
||||
controller = LuiController(self, cfg, send_mqtt_msg)
|
||||
|
||||
desired_display_firmware_version = 22
|
||||
version = "v2.1.0"
|
||||
|
||||
version = "v2.0.0"
|
||||
model = cfg.get("model")
|
||||
orientation = cfg.get("orientation")
|
||||
if model == "us":
|
||||
if orientation == "landscape":
|
||||
# us landscape version
|
||||
desired_display_firmware_url = f"http://nspanel.pky.eu/lovelace-ui/github/nspanel-us-l-{version}.tft"
|
||||
else:
|
||||
# us portrait version
|
||||
desired_display_firmware_url = f"http://nspanel.pky.eu/lovelace-ui/github/nspanel-us-p-{version}.tft"
|
||||
if model == "us-l":
|
||||
# us landscape version
|
||||
desired_display_firmware_url = f"http://nspanel.pky.eu/lovelace-ui/github/nspanel-us-l-{version}.tft"
|
||||
elif: model == "us-p":
|
||||
# us portrait version
|
||||
desired_display_firmware_url = f"http://nspanel.pky.eu/lovelace-ui/github/nspanel-us-p-{version}.tft"
|
||||
else:
|
||||
# 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
|
||||
@@ -86,7 +84,7 @@ class NsPanelLovelaceUIManager(hass.Hass):
|
||||
|
||||
mode = cfg.get("updateMode")
|
||||
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")
|
||||
LuiMqttListener(mqtt_api, topic_recv, controller, updater)
|
||||
|
||||
Reference in New Issue
Block a user