mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2026-03-03 07:06:51 +01:00
start reworking navigation paramters (#644)
* modify cardGrid/cardEntities nav * rework backend nav for new style * fix some bugs * update other pages with new nav paramters * readd readme part
This commit is contained in:
@@ -1,18 +1,19 @@
|
||||
import json
|
||||
import apis
|
||||
|
||||
class LuiMqttListener(object):
|
||||
|
||||
def __init__(self, mqtt_api, topic, controller, updater):
|
||||
def __init__(self, topic, controller, updater):
|
||||
self._controller = controller
|
||||
self._updater = updater
|
||||
self._mqtt_api = mqtt_api
|
||||
|
||||
# Setup, mqtt subscription and callback
|
||||
mqtt_api.mqtt_subscribe(topic=topic)
|
||||
mqtt_api.listen_event(self.mqtt_event_callback, "MQTT_MESSAGE", topic=topic, namespace='mqtt')
|
||||
apis.mqtt_api.mqtt_subscribe(topic=topic)
|
||||
apis.mqtt_api.listen_event(self.mqtt_event_callback, "MQTT_MESSAGE", topic=topic, namespace='mqtt')
|
||||
|
||||
|
||||
def mqtt_event_callback(self, event_name, data, kwargs):
|
||||
self._mqtt_api.log(f'MQTT callback for: {data}')
|
||||
apis.mqtt_api.log(f'MQTT callback for: {data}')
|
||||
# Parse Json Message from Tasmota and strip out message from nextion display
|
||||
data = json.loads(data["payload"])
|
||||
if("nlui_driver_version" in data):
|
||||
@@ -22,7 +23,7 @@ class LuiMqttListener(object):
|
||||
if("CustomRecv" not in data):
|
||||
return
|
||||
msg = data["CustomRecv"]
|
||||
self._mqtt_api.log(f"Received Message from Screen: {msg}")
|
||||
apis.mqtt_api.log(f"Received Message from Screen: {msg}")
|
||||
# Split message into parts seperated by ","
|
||||
msg = msg.split(",")
|
||||
# run action based on received command
|
||||
@@ -30,9 +31,7 @@ class LuiMqttListener(object):
|
||||
if msg[1] == "startup":
|
||||
self._updater.request_berry_driver_version()
|
||||
display_firmware_version = int(msg[2])
|
||||
model = None
|
||||
if display_firmware_version >= 23:
|
||||
model = msg[3]
|
||||
model = msg[3]
|
||||
self._updater.set_current_display_firmware_version(display_firmware_version, model)
|
||||
# check for updates
|
||||
msg_send = self._updater.check_updates()
|
||||
@@ -60,9 +59,8 @@ class LuiMqttListener(object):
|
||||
self._controller.detail_open(msg[2], msg[3])
|
||||
|
||||
class LuiMqttSender(object):
|
||||
def __init__(self, api, mqttapi, topic_send):
|
||||
def __init__(self, api, topic_send):
|
||||
self._ha_api = api
|
||||
self._mqtt_api = mqttapi
|
||||
self._topic_send = topic_send
|
||||
self._prev_msg = ""
|
||||
|
||||
@@ -73,4 +71,4 @@ class LuiMqttSender(object):
|
||||
if topic is None:
|
||||
topic = self._topic_send
|
||||
self._ha_api.log(f"Sending MQTT Message: {msg}")
|
||||
self._mqtt_api.mqtt_publish(topic, msg)
|
||||
apis.mqtt_api.mqtt_publish(topic, msg)
|
||||
Reference in New Issue
Block a user