fixes #72 at least for now

This commit is contained in:
joBr99
2022-03-25 22:58:34 +01:00
parent a80c61f8a0
commit 00adcebcf2
4 changed files with 8 additions and 11 deletions

View File

@@ -112,7 +112,7 @@ class LuiBackendConfig(object):
self._config[k] = v self._config[k] = v
LOGGER.info(f"Loaded config: {self._config}") LOGGER.info(f"Loaded config: {self._config}")
root_page = {"items": self.get("pages"), "name": "root"} root_page = {"items": self.get("pages"), "type": "internal", "heading": "root"}
self._page_config = PageNode(root_page) self._page_config = PageNode(root_page)
LOGGER.info(f"Parsed Page config to the following Tree: \n {self._page_config.dump()}") LOGGER.info(f"Parsed Page config to the following Tree: \n {self._page_config.dump()}")

View File

@@ -80,16 +80,16 @@ class LuiController(object):
def register_callbacks(self): def register_callbacks(self):
items = self._config.get_root_page().get_all_item_names() items = self._config.get_root_page().get_all_item_names()
LOGGER.info(f"Registering callbacks for the following items: {items}") LOGGER.debug(f"Registering callbacks for the following items: {items}")
for item in items: for item in items:
if self._ha_api.entity_exists(item): if self._ha_api.entity_exists(item):
self._ha_api.listen_state(self.state_change_callback, entity_id=item, attribute="all") self._ha_api.listen_state(self.state_change_callback, entity_id=item, attribute="all")
def state_change_callback(self, entity, attribute, old, new, kwargs): def state_change_callback(self, entity, attribute, old, new, kwargs):
LOGGER.info(f"Got callback for: {entity}") LOGGER.debug(f"Got callback for: {entity}")
LOGGER.info(f"Current page has the following items: {self._current_page.get_items()}") LOGGER.debug(f"Current page has the following items: {self._current_page.get_items()}")
if entity in self._current_page.get_all_item_names(recursive=False): if entity in self._current_page.get_all_item_names(recursive=False):
LOGGER.info(f"Callback Entity is on current page: {entity}") LOGGER.debug(f"Callback Entity is on current page: {entity}")
self._pages_gen.render_page(self._current_page, send_page_type=False) self._pages_gen.render_page(self._current_page, send_page_type=False)
# send detail page update, just in case # send detail page update, just in case
if self._current_page.data.get("type", "unknown") in ["cardGrid", "cardEntities"]: if self._current_page.data.get("type", "unknown") in ["cardGrid", "cardEntities"]:

View File

@@ -15,7 +15,7 @@ class LuiMqttListener(object):
def mqtt_event_callback(self, event_name, data, kwargs): def mqtt_event_callback(self, event_name, data, kwargs):
LOGGER.info(f'MQTT callback for: {data}') LOGGER.debug(f'MQTT callback for: {data}')
# Parse Json Message from Tasmota and strip out message from nextion display # Parse Json Message from Tasmota and strip out message from nextion display
data = json.loads(data["payload"]) data = json.loads(data["payload"])
if("nlui_driver_version" in data): if("nlui_driver_version" in data):

View File

@@ -98,7 +98,7 @@ class LuiPagesGen(object):
item = next(iter(item.items()))[0] item = next(iter(item.items()))[0]
# type of the item is the string before the "." in the item name # type of the item is the string before the "." in the item name
item_type = item.split(".")[0] item_type = item.split(".")[0]
LOGGER.info(f"Generating item command for {item} with type {item_type}",) LOGGER.debug(f"Generating item command for {item} with type {item_type}",)
# Internal Entities # Internal Entities
if item_type == "delete": if item_type == "delete":
return f",{item_type},,,,," return f",{item_type},,,,,"
@@ -225,10 +225,9 @@ class LuiPagesGen(object):
self._send_mqtt_msg(command) self._send_mqtt_msg(command)
def render_page(self, page, send_page_type=True): def render_page(self, page, send_page_type=True):
LOGGER.info(page)
config = page.data config = page.data
page_type = config["type"] page_type = config["type"]
LOGGER.info(f"Started rendering of page x with type {page_type}") LOGGER.info(f"Started rendering of page {page.pos} with type {page_type}")
# Switch to page # Switch to page
if send_page_type: if send_page_type:
self.page_type(page_type) self.page_type(page_type)
@@ -237,10 +236,8 @@ class LuiPagesGen(object):
self.generate_entities_page(heading, page.get_items()) self.generate_entities_page(heading, page.get_items())
return return
if page_type == "cardThermo": if page_type == "cardThermo":
LOGGER.info(page.data)
self.generate_thermo_page(page.data.get("item")) self.generate_thermo_page(page.data.get("item"))
if page_type == "cardMedia": if page_type == "cardMedia":
LOGGER.info(page.data)
self.generate_media_page(page.data.get("item")) self.generate_media_page(page.data.get("item"))
def generate_light_detail_page(self, entity): def generate_light_detail_page(self, entity):