Skip to content

Commit

Permalink
stateengine plugin: fix web interface visu with empty actions
Browse files Browse the repository at this point in the history
  • Loading branch information
onkelandy committed Aug 10, 2023
1 parent 73867af commit 1b60b07
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 21 deletions.
36 changes: 20 additions & 16 deletions stateengine/StateEngineAction.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,34 +109,38 @@ def get_order(self):

def update_webif_actionstatus(self, state, name, success, issue=None):
try:
_key = ['{}'.format(state.id), 'actions_stay', '{}'.format(name), 'actionstatus', 'success']
self._abitem.update_webif(_key, success)
_key = ['{}'.format(state.id), 'actions_stay', '{}'.format(name), 'actionstatus', 'issue']
self._abitem.update_webif(_key, issue)
if self._abitem.webif_infos[state.id].get('actions_stay'):
_key = ['{}'.format(state.id), 'actions_stay', '{}'.format(name), 'actionstatus', 'success']
self._abitem.update_webif(_key, success)
_key = ['{}'.format(state.id), 'actions_stay', '{}'.format(name), 'actionstatus', 'issue']
self._abitem.update_webif(_key, issue)
except Exception:
pass
try:
_key = ['{}'.format(state.id), 'actions_enter', '{}'.format(name), 'actionstatus', 'success']
self._abitem.update_webif(_key, success)
_key = ['{}'.format(state.id), 'actions_enter', '{}'.format(name), 'actionstatus', 'issue']
self._abitem.update_webif(_key, issue)
if self._abitem.webif_infos[state.id].get('actions_enter'):
_key = ['{}'.format(state.id), 'actions_enter', '{}'.format(name), 'actionstatus', 'success']
self._abitem.update_webif(_key, success)
_key = ['{}'.format(state.id), 'actions_enter', '{}'.format(name), 'actionstatus', 'issue']
self._abitem.update_webif(_key, issue)
except Exception:
pass
try:
_key = ['{}'.format(state.id), 'actions_enter_or_stay', '{}'.format(name), 'actionstatus', 'success']
self._abitem.update_webif(_key, success)
_key = ['{}'.format(state.id), 'actions_enter_or_stay', '{}'.format(name), 'actionstatus', 'issue']
self._abitem.update_webif(_key, issue)
if self._abitem.webif_infos[state.id].get('actions_enter_or_stay'):
_key = ['{}'.format(state.id), 'actions_enter_or_stay', '{}'.format(name), 'actionstatus', 'success']
self._abitem.update_webif(_key, success)
_key = ['{}'.format(state.id), 'actions_enter_or_stay', '{}'.format(name), 'actionstatus', 'issue']
self._abitem.update_webif(_key, issue)
except Exception:
pass
try:
state.update_name(state.state_item)
_key_name = ['{}'.format(state.id), 'name']
self._abitem.update_webif(_key_name, state.name)
_key = ['{}'.format(state.id), 'actions_leave', '{}'.format(name), 'actionstatus', 'success']
self._abitem.update_webif(_key, success)
_key = ['{}'.format(state.id), 'actions_leave', '{}'.format(name), 'actionstatus', 'issue']
self._abitem.update_webif(_key, issue)
if self._abitem.webif_infos[state.id].get('actions_leave'):
_key = ['{}'.format(state.id), 'actions_leave', '{}'.format(name), 'actionstatus', 'success']
self._abitem.update_webif(_key, success)
_key = ['{}'.format(state.id), 'actions_leave', '{}'.format(name), 'actionstatus', 'issue']
self._abitem.update_webif(_key, issue)
except Exception:
pass

Expand Down
15 changes: 10 additions & 5 deletions stateengine/StateEngineState.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,10 @@ def run_enter(self, allow_item_repeat: bool):
self._log_increase_indent()
self._log_debug("Update web interface enter {}", self.id)
self._log_increase_indent()
self._abitem.update_webif([self.id, 'actions_enter_or_stay'], self.__actions_enter_or_stay.dict_actions('actions_enter_or_stay', self.id))
self._abitem.update_webif([self.id, 'actions_enter'], self.__actions_enter.dict_actions('actions_enter', self.id))
if self.__actions_enter_or_stay.count() > 0:
self._abitem.update_webif([self.id, 'actions_enter_or_stay'], self.__actions_enter_or_stay.dict_actions('actions_enter_or_stay', self.id))
if self.__actions_enter.count() > 0:
self._abitem.update_webif([self.id, 'actions_enter'], self.__actions_enter.dict_actions('actions_enter', self.id))
self._log_decrease_indent()
self._log_decrease_indent()

Expand All @@ -209,8 +211,10 @@ def run_stay(self, allow_item_repeat: bool):
self._log_increase_indent()
self._log_debug("Update web interface stay {}", self.id)
self._log_increase_indent()
self._abitem.update_webif([self.id, 'actions_enter_or_stay'], self.__actions_enter_or_stay.dict_actions('actions_enter_or_stay', self.id))
self._abitem.update_webif([self.id, 'actions_stay'], self.__actions_stay.dict_actions('actions_stay', self.id))
if self.__actions_enter_or_stay.count() > 0:
self._abitem.update_webif([self.id, 'actions_enter_or_stay'], self.__actions_enter_or_stay.dict_actions('actions_enter_or_stay', self.id))
if self.__actions_stay.count() > 0:
self._abitem.update_webif([self.id, 'actions_stay'], self.__actions_stay.dict_actions('actions_stay', self.id))
self._log_decrease_indent()
self._log_decrease_indent()

Expand All @@ -227,7 +231,8 @@ def run_leave(self, allow_item_repeat: bool):
self._log_increase_indent()
self._log_debug("Update web interface leave {}", self.id)
self._log_increase_indent()
self._abitem.update_webif([self.id, 'actions_leave'], self.__actions_leave.dict_actions('actions_leave', self.id))
if self.__actions_leave.count() > 0:
self._abitem.update_webif([self.id, 'actions_leave'], self.__actions_leave.dict_actions('actions_leave', self.id))
self._log_decrease_indent()
self._log_decrease_indent()

Expand Down

0 comments on commit 1b60b07

Please sign in to comment.