new config format

This commit is contained in:
joBr99
2022-04-02 16:45:28 +02:00
parent 76995d5666
commit 6aefe09ad9
6 changed files with 248 additions and 225 deletions

View File

@@ -51,42 +51,40 @@ class NsPanelLovelaceUIManager(hass.Hass):
mqtt_api = self._mqtt_api = self.get_plugin_api("MQTT")
cfg = self._cfg = LuiBackendConfig(self, self.args["config"])
#topic_send = cfg.get("panelSendTopic")
#def send_mqtt_msg(msg, topic=None):
# if topic is None:
# topic = topic_send
# LOGGER.info(f"Sending MQTT Message: {msg}")
# mqtt_api.mqtt_publish(topic, msg)
#
## Request Tasmota Driver Version
#mqtt_api.mqtt_publish(topic_send.replace("CustomSend", "GetDriverVersion"), "x")
#
#controller = LuiController(self, cfg, send_mqtt_msg)
#
#desired_display_firmware_version = 26
#version = "v2.4.0"
#
#model = cfg.get("model")
#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_tasmota_driver_version = 3
#desired_tasmota_driver_url = "https://raw.githubusercontent.com/joBr99/nspanel-lovelace-ui/main/tasmota/autoexec.be"
#
#mode = cfg.get("updateMode")
#topic_send = cfg.get("panelSendTopic")
#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)
#
#LOGGER.info('Started')
#
topic_send = cfg.get("panelSendTopic")
def send_mqtt_msg(msg, topic=None):
if topic is None:
topic = topic_send
LOGGER.info(f"Sending MQTT Message: {msg}")
mqtt_api.mqtt_publish(topic, msg)
# Request Tasmota Driver Version
mqtt_api.mqtt_publish(topic_send.replace("CustomSend", "GetDriverVersion"), "x")
controller = LuiController(self, cfg, send_mqtt_msg)
desired_display_firmware_version = 26
version = "v2.4.0"
model = cfg.get("model")
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_tasmota_driver_version = 3
desired_tasmota_driver_url = "https://raw.githubusercontent.com/joBr99/nspanel-lovelace-ui/main/tasmota/autoexec.be"
mode = cfg.get("updateMode")
topic_send = cfg.get("panelSendTopic")
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)
LOGGER.info('Started')