From bdc4aef9aa4901456005da7a12b4e3133d50b68f Mon Sep 17 00:00:00 2001 From: Onkel Andy Date: Mon, 11 Sep 2023 20:53:54 +0200 Subject: [PATCH] stateengine plugin: (re)fix web interface for overview page --- stateengine/webif/__init__.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/stateengine/webif/__init__.py b/stateengine/webif/__init__.py index e5d6f224f..1c3021bc5 100755 --- a/stateengine/webif/__init__.py +++ b/stateengine/webif/__init__.py @@ -103,8 +103,18 @@ def get_data_html(self, dataSet=None): :param dataSet: Dataset for which the data should be returned (standard: None) :return: dict with the data needed to update the web page. """ - - if dataSet and isinstance(dataSet, str): + if dataSet is None: + # get the new data + data = {} + for item in self.plugin.get_items(): + conditionset = item.lastconditionset_name + conditionset = "-" if conditionset == "" else conditionset + data.update({item.id: {'laststate': item.laststate_name, 'lastconditionset': conditionset}}) + try: + return json.dumps(data) + except Exception as e: + self.logger.error(f"get_data_html exception: {e}") + elif dataSet and isinstance(dataSet, str): try: dataSet = self.plugin.abitems[dataSet] except Exception as e: @@ -114,4 +124,6 @@ def get_data_html(self, dataSet=None): if self.vis_enabled and dataSet.firstrun is None: self.plugin.get_graph(dataSet, 'graph') return json.dumps({"success": "true"}) - return json.dumps({"success": "false"}) + return json.dumps({"success": "false"}) + else: + return {}