Skip to content

Commit

Permalink
Merge pull request #818 from onkelandy/stateengine
Browse files Browse the repository at this point in the history
Stateengine Plugin: important updates for webif and value evaluation
  • Loading branch information
onkelandy authored Sep 13, 2023
2 parents ac152e9 + c8e72d2 commit 5f5d24e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion stateengine/StateEngineValue.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def __resetvalue(self):
# value: string indicating value or source of value
# name: name of object ("time" is being handled differently)
def set(self, value, name="", reset=True, item=None):
#value = copy.deepcopy(value)
value = copy.deepcopy(value)
if reset:
self.__resetvalue()
if isinstance(value, list):
Expand Down
18 changes: 15 additions & 3 deletions stateengine/webif/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 {}

0 comments on commit 5f5d24e

Please sign in to comment.