mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-22 15:34:26 +01:00
fixes #72 at least for now
This commit is contained in:
@@ -112,7 +112,7 @@ class LuiBackendConfig(object):
|
||||
self._config[k] = v
|
||||
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)
|
||||
|
||||
LOGGER.info(f"Parsed Page config to the following Tree: \n {self._page_config.dump()}")
|
||||
|
||||
@@ -80,16 +80,16 @@ class LuiController(object):
|
||||
|
||||
def register_callbacks(self):
|
||||
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:
|
||||
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.info(f"Got callback for: {entity}")
|
||||
LOGGER.info(f"Current page has the following items: {self._current_page.get_items()}")
|
||||
LOGGER.debug(f"Got callback for: {entity}")
|
||||
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):
|
||||
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)
|
||||
# send detail page update, just in case
|
||||
if self._current_page.data.get("type", "unknown") in ["cardGrid", "cardEntities"]:
|
||||
|
||||
@@ -15,7 +15,7 @@ class LuiMqttListener(object):
|
||||
|
||||
|
||||
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
|
||||
data = json.loads(data["payload"])
|
||||
if("nlui_driver_version" in data):
|
||||
|
||||
@@ -98,7 +98,7 @@ class LuiPagesGen(object):
|
||||
item = next(iter(item.items()))[0]
|
||||
# type of the item is the string before the "." in the item name
|
||||
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
|
||||
if item_type == "delete":
|
||||
return f",{item_type},,,,,"
|
||||
@@ -225,10 +225,9 @@ class LuiPagesGen(object):
|
||||
self._send_mqtt_msg(command)
|
||||
|
||||
def render_page(self, page, send_page_type=True):
|
||||
LOGGER.info(page)
|
||||
config = page.data
|
||||
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
|
||||
if send_page_type:
|
||||
self.page_type(page_type)
|
||||
@@ -237,10 +236,8 @@ class LuiPagesGen(object):
|
||||
self.generate_entities_page(heading, page.get_items())
|
||||
return
|
||||
if page_type == "cardThermo":
|
||||
LOGGER.info(page.data)
|
||||
self.generate_thermo_page(page.data.get("item"))
|
||||
if page_type == "cardMedia":
|
||||
LOGGER.info(page.data)
|
||||
self.generate_media_page(page.data.get("item"))
|
||||
|
||||
def generate_light_detail_page(self, entity):
|
||||
|
||||
Reference in New Issue
Block a user