Compare commits

..

4 Commits

Author SHA1 Message Date
Johannes
69e52c3c20 bump version 2022-04-16 09:06:53 +02:00
Johannes
7a88eb1baa fix config override bug 2022-04-16 09:02:25 +02:00
Johannes
1ec7558ec0 remove custom logging stuff 2022-04-16 08:29:40 +02:00
joBr99
660007f188 bump version (add nextion2text) 2022-04-15 16:21:25 +00:00
18 changed files with 147 additions and 187 deletions

View File

@@ -1,6 +1,6 @@
diff -bur HMI/n2t-out/Program.s.txt HMI/US/landscape/n2t-out/Program.s.txt
--- HMI/n2t-out/Program.s.txt 2022-04-13 20:21:34.698226402 +0000
+++ HMI/US/landscape/n2t-out/Program.s.txt 2022-04-13 20:21:35.478242275 +0000
--- HMI/n2t-out/Program.s.txt 2022-04-15 16:21:24.696789846 +0000
+++ HMI/US/landscape/n2t-out/Program.s.txt 2022-04-15 16:21:25.464799585 +0000
@@ -11,6 +11,6 @@
// dim value
int dimValue=40
@@ -11,8 +11,8 @@ diff -bur HMI/n2t-out/Program.s.txt HMI/US/landscape/n2t-out/Program.s.txt
+ //lcd_dev fffb 0002 0000 0020
page pageStartup
diff -bur HMI/n2t-out/pageStartup.txt HMI/US/landscape/n2t-out/pageStartup.txt
--- HMI/n2t-out/pageStartup.txt 2022-04-13 20:21:34.698226402 +0000
+++ HMI/US/landscape/n2t-out/pageStartup.txt 2022-04-13 20:21:35.478242275 +0000
--- HMI/n2t-out/pageStartup.txt 2022-04-15 16:21:24.696789846 +0000
+++ HMI/US/landscape/n2t-out/pageStartup.txt 2022-04-15 16:21:25.464799585 +0000
@@ -177,7 +177,7 @@
recmod=1
bauds=115200
@@ -23,8 +23,8 @@ diff -bur HMI/n2t-out/pageStartup.txt HMI/US/landscape/n2t-out/pageStartup.txt
btlen tSend.txt,sys0
crcrest 1,0xffff // reset CRC
diff -bur HMI/n2t-out/popupLight.txt HMI/US/landscape/n2t-out/popupLight.txt
--- HMI/n2t-out/popupLight.txt 2022-04-13 20:21:34.698226402 +0000
+++ HMI/US/landscape/n2t-out/popupLight.txt 2022-04-13 20:21:35.478242275 +0000
--- HMI/n2t-out/popupLight.txt 2022-04-15 16:21:24.696789846 +0000
+++ HMI/US/landscape/n2t-out/popupLight.txt 2022-04-15 16:21:25.464799585 +0000
@@ -570,43 +570,25 @@
//we are going to exit this page with this command, so we have to clear the buffer, so we are not getting into a stupid loop ...
udelete payloadLength-1
@@ -76,8 +76,8 @@ diff -bur HMI/n2t-out/popupLight.txt HMI/US/landscape/n2t-out/popupLight.txt
if(tId.txt=="cardAlarm")
{
diff -bur HMI/n2t-out/screensaver.txt HMI/US/landscape/n2t-out/screensaver.txt
--- HMI/n2t-out/screensaver.txt 2022-04-13 20:21:34.698226402 +0000
+++ HMI/US/landscape/n2t-out/screensaver.txt 2022-04-13 20:21:35.478242275 +0000
--- HMI/n2t-out/screensaver.txt 2022-04-15 16:21:24.696789846 +0000
+++ HMI/US/landscape/n2t-out/screensaver.txt 2022-04-15 16:21:25.464799585 +0000
@@ -48,18 +48,6 @@
Scope: local
Value: 0

View File

@@ -10,6 +10,10 @@ pageTest
13 Component(s)
13 Line(s) of event code
13 Unique line(s) of event code
pageStartup
19 Component(s)
150 Line(s) of event code
113 Unique line(s) of event code
cardMedia
30 Component(s)
329 Line(s) of event code
@@ -18,10 +22,6 @@ popupNotify
17 Component(s)
196 Line(s) of event code
123 Unique line(s) of event code
pageStartup
19 Component(s)
150 Line(s) of event code
113 Unique line(s) of event code
cardAlarm
35 Component(s)
343 Line(s) of event code

View File

@@ -402,7 +402,7 @@ Text tVersion
Horizontal Alignment : center
Vertical Alignment : center
Input Type : character
Text : 31
Text : 32
Max. Text Size : 10
Word wrap : disabled
Horizontal Spacing : 0

View File

@@ -152,7 +152,7 @@ Text tVersion
Disable release event after dragging: 0
Send Component ID : disabled
Associated Keyboard : none
Text : 31
Text : 32
Max. Text Size : 10
Picture p0

View File

@@ -1,6 +1,6 @@
diff -bur HMI/n2t-out/Program.s.txt HMI/US/portrait/n2t-out/Program.s.txt
--- HMI/n2t-out/Program.s.txt 2022-04-13 20:21:34.698226402 +0000
+++ HMI/US/portrait/n2t-out/Program.s.txt 2022-04-13 20:21:35.070233972 +0000
--- HMI/n2t-out/Program.s.txt 2022-04-15 16:21:24.696789846 +0000
+++ HMI/US/portrait/n2t-out/Program.s.txt 2022-04-15 16:21:25.032794102 +0000
@@ -11,6 +11,6 @@
// dim value
int dimValue=40
@@ -11,8 +11,8 @@ diff -bur HMI/n2t-out/Program.s.txt HMI/US/portrait/n2t-out/Program.s.txt
+ //lcd_dev fffb 0002 0000 0020
page pageStartup
diff -bur HMI/n2t-out/cardEntities.txt HMI/US/portrait/n2t-out/cardEntities.txt
--- HMI/n2t-out/cardEntities.txt 2022-04-13 20:21:34.698226402 +0000
+++ HMI/US/portrait/n2t-out/cardEntities.txt 2022-04-13 20:21:35.070233972 +0000
--- HMI/n2t-out/cardEntities.txt 2022-04-15 16:21:24.696789846 +0000
+++ HMI/US/portrait/n2t-out/cardEntities.txt 2022-04-15 16:21:25.032794102 +0000
@@ -62,6 +62,16 @@
vis bText4,0
vis hSlider4,0
@@ -427,8 +427,8 @@ diff -bur HMI/n2t-out/cardEntities.txt HMI/US/portrait/n2t-out/cardEntities.txt
if(tInstruction.txt=="pageType")
{
diff -bur HMI/n2t-out/pageStartup.txt HMI/US/portrait/n2t-out/pageStartup.txt
--- HMI/n2t-out/pageStartup.txt 2022-04-13 20:21:34.698226402 +0000
+++ HMI/US/portrait/n2t-out/pageStartup.txt 2022-04-13 20:21:35.070233972 +0000
--- HMI/n2t-out/pageStartup.txt 2022-04-15 16:21:24.696789846 +0000
+++ HMI/US/portrait/n2t-out/pageStartup.txt 2022-04-15 16:21:25.032794102 +0000
@@ -142,7 +142,7 @@
Disable release event after dragging: 0
Send Component ID : disabled

View File

@@ -1,8 +1,8 @@
+++ HMI/US/portrait/diff-eu-version.txt 2022-04-13 20:21:35.094234461 +0000
+--- HMI/n2t-out/Program.s.txt 2022-04-13 20:21:34.698226402 +0000
++++ HMI/US/portrait/n2t-out/Program.s.txt 2022-04-13 20:21:35.070233972 +0000
+--- HMI/n2t-out/cardEntities.txt 2022-04-13 20:21:34.698226402 +0000
++++ HMI/US/portrait/n2t-out/cardEntities.txt 2022-04-13 20:21:35.070233972 +0000
+++ HMI/US/portrait/diff-eu-version.txt 2022-04-15 16:21:25.068794558 +0000
+--- HMI/n2t-out/Program.s.txt 2022-04-15 16:21:24.696789846 +0000
++++ HMI/US/portrait/n2t-out/Program.s.txt 2022-04-15 16:21:25.032794102 +0000
+--- HMI/n2t-out/cardEntities.txt 2022-04-15 16:21:24.696789846 +0000
++++ HMI/US/portrait/n2t-out/cardEntities.txt 2022-04-15 16:21:25.032794102 +0000
+@@ -62,6 +62,16 @@
+@@ -117,6 +127,18 @@
+@@ -153,6 +175,15 @@
@@ -15,5 +15,5 @@
+ }
+ if(tInstruction.txt=="pageType")
+ {
+--- HMI/n2t-out/pageStartup.txt 2022-04-13 20:21:34.698226402 +0000
++++ HMI/US/portrait/n2t-out/pageStartup.txt 2022-04-13 20:21:35.070233972 +0000
+--- HMI/n2t-out/pageStartup.txt 2022-04-15 16:21:24.696789846 +0000
++++ HMI/US/portrait/n2t-out/pageStartup.txt 2022-04-15 16:21:25.032794102 +0000

View File

@@ -402,7 +402,7 @@ Text tVersion
Horizontal Alignment : center
Vertical Alignment : center
Input Type : character
Text : 31
Text : 32
Max. Text Size : 10
Word wrap : disabled
Horizontal Spacing : 0

View File

@@ -152,7 +152,7 @@ Text tVersion
Disable release event after dragging: 0
Send Component ID : disabled
Associated Keyboard : none
Text : 31
Text : 32
Max. Text Size : 10
Picture p0

View File

@@ -10,10 +10,6 @@ pageTest
13 Component(s)
13 Line(s) of event code
13 Unique line(s) of event code
pageStartup
19 Component(s)
150 Line(s) of event code
113 Unique line(s) of event code
popupLight
27 Component(s)
338 Line(s) of event code
@@ -26,6 +22,10 @@ popupNotify
17 Component(s)
196 Line(s) of event code
123 Unique line(s) of event code
pageStartup
19 Component(s)
150 Line(s) of event code
113 Unique line(s) of event code
cardMedia
30 Component(s)
329 Line(s) of event code

View File

@@ -402,7 +402,7 @@ Text tVersion
Horizontal Alignment : center
Vertical Alignment : center
Input Type : character
Text : 31
Text : 32
Max. Text Size : 10
Word wrap : disabled
Horizontal Spacing : 0

View File

@@ -152,7 +152,7 @@ Text tVersion
Disable release event after dragging: 0
Send Component ID : disabled
Associated Keyboard : none
Text : 31
Text : 32
Max. Text Size : 10
Picture p0

View File

@@ -1,14 +1,7 @@
from helper import dict_recursive_update
import logging
LOGGER = logging.getLogger(__name__)
HA_API = None
class Entity(object):
def __init__(self, entity_input_config):
if type(entity_input_config) is not dict:
LOGGER.error("Config error, not a dict check your entity configs")
#self._ha_api.log("Config error, not a dict check your entity configs")
self.entityId = "error"
self.nameOverride = None
self.iconOverride = None
@@ -33,7 +26,7 @@ class Card(object):
for e in card_input_config.get("entities", []):
self.entities.append(Entity(e))
self.id = f"{self.cardType}_{self.key}".replace(".","_").replace("~","_").replace(" ","_")
LOGGER.info(f"Created Card {self.cardType} with pos {pos} and id {self.id}")
#self._ha_api.log(f"Created Card {self.cardType} with pos {pos} and id {self.id}")
def get_entity_list(self):
entityIds = []
@@ -52,7 +45,22 @@ class Card(object):
class LuiBackendConfig(object):
_DEFAULT_CONFIG = {
def dict_recursive_update(self, source: dict, target: dict) -> dict:
for sk, sv in source.items():
if sk in target and isinstance(target[sk], dict):
target[sk] = self.dict_recursive_update(sv, target[sk])
else:
target[sk] = sv
return target
def __init__(self, ha_api, config_in):
self._ha_api = ha_api
self._config = {}
self._config_cards = []
self._config_screensaver = None
self._config_hidden_cards = []
self._DEFAULT_CONFIG = {
'panelRecvTopic': "tele/tasmota_your_mqtt_topic/RESULT",
'panelSendTopic': "cmnd/tasmota_your_mqtt_topic/CustomSend",
'updateMode': "auto-notify",
@@ -104,19 +112,12 @@ class LuiBackendConfig(object):
'hiddenCards': []
}
def __init__(self, ha_api, config_in):
global HA_API
HA_API = ha_api
self._config = {}
self._config_cards = []
self._config_screensaver = None
self._config_hidden_cards = []
self.load(config_in)
def load(self, inconfig):
self._config = dict_recursive_update(inconfig, self._DEFAULT_CONFIG)
LOGGER.info(f"Loaded config: {self._config}")
self._ha_api.log("Input config: %s", inconfig)
self._config = self.dict_recursive_update(inconfig, self._DEFAULT_CONFIG)
self._ha_api.log("Loaded config: %s", self._config)
# parse cards displayed on panel
pos = 0

View File

@@ -1,11 +1,8 @@
import logging
import datetime
from helper import scale, pos_to_color
from pages import LuiPagesGen
LOGGER = logging.getLogger(__name__)
class LuiController(object):
def __init__(self, ha_api, config, send_mqtt_msg):
@@ -40,13 +37,19 @@ class LuiController(object):
# calculate current brightness
self.current_screensaver_brightness = self.calc_current_screensaver_brightness()
# call update_screensaver_brightness on changes of entity configured in brightnessScreensaverTracking
bst = self._config.get("sleepTracking")
if bst is not None and self._ha_api.entity_exists(bst):
self._ha_api.listen_state(self.update_screensaver_brightness_state_callback, entity_id=bst)
# register callback for state changes on tracked value
sleep_brightness_config = self._config.get("sleepBrightness")
if type(sleep_brightness_config) == str and self._ha_api.entity_exists(sleep_brightness_config):
self._ha_api.listen_state(self.update_screensaver_brightness_state_callback, entity_id=sleep_brightness_config)
def startup(self):
LOGGER.info(f"Startup Event")
self._ha_api.log(f"Startup Event")
# send time and date on startup
self._pages_gen.update_time("")
self._pages_gen.update_date("")
@@ -63,6 +66,10 @@ class LuiController(object):
def update_screensaver_brightness_state_callback(self, entity, attribute, old, new, kwargs):
x = type(self._config.get("sleepBrightness"))
y = self._config.get("sleepBrightness")
if type(self._config.get("sleepBrightness")) == str:
self.current_screensaver_brightness = self.calc_current_screensaver_brightness()
self.update_screensaver_brightness(kwargs={"value": self.current_screensaver_brightness})
def update_screensaver_brightness(self, kwargs):
@@ -77,19 +84,22 @@ class LuiController(object):
def calc_current_screensaver_brightness(self):
current_screensaver_brightness = 20
sleep_brightness_config = self._config.get("sleepBrightness")
# set brightness of screensaver
if type(self._config.get("sleepBrightness")) == int:
current_screensaver_brightness = self._config.get("sleepBrightness")
elif type(self._config.get("sleepBrightness")) == list:
sorted_timesets = sorted(self._config.get("sleepBrightness"), key=lambda d: self._ha_api.parse_time(d['time']))
if type(sleep_brightness_config) == int:
current_screensaver_brightness = sleep_brightness_config
elif type(sleep_brightness_config) == str:
current_screensaver_brightness = int(float(self._ha_api.get_state(sleep_brightness_config)))
elif type(sleep_brightness_config) == list:
sorted_timesets = sorted(sleep_brightness_config, key=lambda d: self._ha_api.parse_time(d['time']))
# calc current screensaver brightness
found_current_dim_value = False
for index, timeset in enumerate(sorted_timesets):
LOGGER.info("Current time %s", self._ha_api.get_now().time())
self._ha_api.log("Current time %s", self._ha_api.get_now().time())
if self._ha_api.parse_time(timeset["time"]) > self._ha_api.get_now().time() and not found_current_dim_value:
# first time after current time, set dim value
current_screensaver_brightness = sorted_timesets[index-1]["value"]
LOGGER.info("Setting dim value to %s", sorted_timesets[index-1])
self._ha_api.log("Setting dim value to %s", sorted_timesets[index-1])
found_current_dim_value = True
# still no dim value
if not found_current_dim_value:
@@ -98,16 +108,16 @@ class LuiController(object):
def register_callbacks(self):
items = self._config.get_all_entity_names()
LOGGER.info(f"Registering callbacks for the following items: {items}")
self._ha_api.log(f"Registering callbacks for the following items: {items}")
for item in items:
if self._ha_api.entity_exists(item):
self._ha_api.listen_state(self.state_change_callback, entity_id=item, attribute="all")
def state_change_callback(self, entity, attribute, old, new, kwargs):
LOGGER.debug(f"Got callback for: {entity}")
LOGGER.debug(f"Current page has the following items: {self._current_card.get_entity_list()}")
self._ha_api.log(f"Got callback for: {entity}", level="DEBUG")
self._ha_api.log(f"Current page has the following items: {self._current_card.get_entity_list()}", level="DEBUG")
if entity in self._current_card.get_entity_list():
LOGGER.debug(f"Callback Entity is on current page: {entity}")
self._ha_api.log(f"Callback Entity is on current page: {entity}", level="DEBUG")
self._pages_gen.render_card(self._current_card, send_page_type=False)
# send detail page update, just in case
if self._current_card.cardType in ["cardGrid", "cardEntities"]:
@@ -124,7 +134,7 @@ class LuiController(object):
self._pages_gen.generate_light_detail_page(entity_id)
def button_press(self, entity_id, button_type, value):
LOGGER.info(f"Button Press Event; entity_id: {entity_id}; button_type: {button_type}; value: {value} ")
self._ha_api.log(f"Button Press Event; entity_id: {entity_id}; button_type: {button_type}; value: {value} ")
# internal buttons
if entity_id == "screensaver" and button_type == "bExit":
# get default card if there is one

View File

@@ -55,11 +55,3 @@ def get_attr_safe(entity, attr, default):
if res is None:
res = default
return res
def dict_recursive_update(source: dict, target: dict) -> dict:
for sk, sv in source.items():
if sk in target and isinstance(target[sk], dict):
target[sk] = dict_recursive_update(sv, target[sk])
else:
target[sk] = sv
return target

View File

@@ -1,21 +1,18 @@
import json
import logging
LOGGER = logging.getLogger(__name__)
class LuiMqttListener(object):
def __init__(self, mqtt_api, 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')
def mqtt_event_callback(self, event_name, data, kwargs):
LOGGER.debug(f'MQTT callback for: {data}')
self._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):
@@ -25,7 +22,7 @@ class LuiMqttListener(object):
if("CustomRecv" not in data):
return
msg = data["CustomRecv"]
LOGGER.info(f"Received Message from Screen: {msg}")
self._mqtt_api.log(f"Received Message from Screen: {msg}")
# Split message into parts seperated by ","
msg = msg.split(",")
# run action based on received command

View File

@@ -1,4 +1,3 @@
import logging
import datetime
import dateutil.parser as dp
@@ -13,8 +12,6 @@ babel_spec = importlib.util.find_spec("babel")
if babel_spec is not None:
import babel.dates
LOGGER = logging.getLogger(__name__)
class LuiPagesGen(object):
def __init__(self, ha_api, config, send_mqtt_msg):
@@ -64,7 +61,7 @@ class LuiPagesGen(object):
if self._ha_api.entity_exists(we_name):
we = self._ha_api.get_entity(we_name)
else:
LOGGER.error(f"Skipping Weather Update, entity {we_name} not found")
self._ha_api.error(f"Skipping Weather Update, entity {we_name} not found")
return
icon_cur = get_icon_id_ha("weather", state=we.state)
@@ -84,7 +81,7 @@ class LuiPagesGen(object):
icon = get_icon_id_ha("weather", state=we.attributes.forecast[i-1]['condition'])
down = convert_temperature(we.attributes.forecast[i-1]['temperature'], unit)
else:
LOGGER.info(f"Forecast {i} is overriden with {wOF}")
self._ha_api.log(f"Forecast {i} is overriden with {wOF}")
icon = wOF.get("icon")
name = wOF.get("name")
entity = self._ha_api.get_entity(wOF.get("entity"))
@@ -107,7 +104,7 @@ class LuiPagesGen(object):
# type of the item is the string before the "." in the entityId
entityType = entityId.split(".")[0]
LOGGER.debug(f"Generating item for {entityId} with type {entityType}",)
self._ha_api.log(f"Generating item for {entityId} with type {entityType}", level="DEBUG")
# Internal types
if entityType == "delete":
return f"~{entityType}~~~~~"
@@ -326,7 +323,7 @@ class LuiPagesGen(object):
self._send_mqtt_msg(command)
def render_card(self, card, send_page_type=True):
LOGGER.info(f"Started rendering of page {card.pos} with type {card.cardType}")
self._ha_api.log(f"Started rendering of page {card.pos} with type {card.cardType}")
if len(self._config._config_cards) == 1:
navigation = "0|0"
else:

View File

@@ -1,9 +1,8 @@
import logging
LOGGER = logging.getLogger(__name__)
class Updater:
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):
def __init__(self, log, 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._log = log
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
@@ -43,10 +42,10 @@ class Updater:
# return's true if a notification was send to the panel
# run pre req check
if self.check_pre_req():
LOGGER.info("Update Pre-Check sucessful Tasmota Driver Version: %s Panel Version: %s", self.current_tasmota_driver_version, self.current_display_firmware_version)
self._log("Update Pre-Check sucessful Tasmota Driver Version: %s Panel Version: %s", self.current_tasmota_driver_version, self.current_display_firmware_version)
# check if tasmota driver needs update
if self.current_tasmota_driver_version < self.desired_tasmota_driver_version:
LOGGER.info("Update of Tasmota Driver needed")
self._log("Update of Tasmota Driver needed")
# in auto mode just do the update
if self.mode == "auto":
self.update_berry_driver()
@@ -59,14 +58,14 @@ class Updater:
return False
# check if model has changed
if self.current_display_model is not None and self.current_display_model != self.desired_display_firmware_model:
LOGGER.info(f"Mismatch between Display Firmware ({self.current_display_model}) and configured model ({self.desired_display_firmware_model})")
self._log(f"Mismatch between Display Firmware ({self.current_display_model}) and configured model ({self.desired_display_firmware_model})")
update_msg = f"The configured display firmware model has changed, do you want to start the update now? Current Model: {self.current_display_model} Configured Model: {self.desired_display_firmware_model} 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")
self._log("Update of Display Firmware needed")
# in auto mode just do the update
if self.mode == "auto":
self.update_panel_driver()
@@ -78,7 +77,7 @@ class Updater:
return True
return False
else:
LOGGER.info("Update Pre-Check failed Tasmota Driver Version: %s Panel Version: %s", self.current_tasmota_driver_version, self.current_display_firmware_version)
self._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 request_berry_driver_version(self):

View File

@@ -8,46 +8,10 @@ from luibackend.controller import LuiController
from luibackend.mqttListener import LuiMqttListener
from luibackend.updater import Updater
LOGGER = logging.getLogger(__name__)
class AppDaemonLoggingHandler(logging.Handler):
def __init__(self, app):
super().__init__()
self._app = app
def emit(self, record):
message = record.getMessage()
if record.exc_info:
message += '\nTraceback (most recent call last):\n'
message += '\n'.join(traceback.format_tb(record.exc_info[2]))
message += f'{record.exc_info[0].__name__}: {record.exc_info[1]}'
self._app.log(message, level=record.levelname)
class NsPanelLovelaceUIManager(hass.Hass):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._redirect_logging()
def _redirect_logging(self):
# Add a handler for the logging module that will convert the
# calls to AppDaemon's logger with the self instance, so that
# we can simply use logging in the rest of the application
rlogger = logging.getLogger()
rlogger.handlers = [
h for h in rlogger.handlers
if type(h).__name__ != AppDaemonLoggingHandler.__name__
]
rlogger.addHandler(AppDaemonLoggingHandler(self))
# We want to grab all the logs, AppDaemon will
# then care about filtering those we asked for
rlogger.setLevel(logging.DEBUG)
def initialize(self):
LOGGER.info('Starting')
self.log('Starting')
mqtt_api = self._mqtt_api = self.get_plugin_api("MQTT")
cfg = self._cfg = LuiBackendConfig(self, self.args["config"])
@@ -55,7 +19,7 @@ class NsPanelLovelaceUIManager(hass.Hass):
def send_mqtt_msg(msg, topic=None):
if topic is None:
topic = topic_send
LOGGER.info(f"Sending MQTT Message: {msg}")
self.log(f"Sending MQTT Message: {msg}")
mqtt_api.mqtt_publish(topic, msg)
# Request Tasmota Driver Version
@@ -64,7 +28,7 @@ class NsPanelLovelaceUIManager(hass.Hass):
controller = LuiController(self, cfg, send_mqtt_msg)
desired_display_firmware_version = 32
version = "v2.7.2"
version = "v2.7.3"
model = cfg.get("model")
if model == "us-l":
@@ -82,9 +46,9 @@ 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, model, desired_display_firmware_url, desired_tasmota_driver_version, desired_tasmota_driver_url)
updater = Updater(self.log, 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')
self.log('Started')