Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stateengine Plugin 2.0.0 #790

Merged
merged 60 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
2052d55
stateengine plugin: introduce new status function (if e.g. lamella it…
onkelandy Aug 3, 2023
58dd8e8
stateengine plugin: add status log message
onkelandy Aug 3, 2023
f297c24
stateengine plugin: some bug fixes and minor adjustments
onkelandy Aug 3, 2023
3945a6b
stateengine plugin: improve handling of min_delta and it's integratio…
onkelandy Aug 3, 2023
b144009
stateengine plugin: remove unneccessary code in web interface index.html
onkelandy Aug 3, 2023
168ceed
stateengine plugin: improve casting of values (boolean, numbers, etc.)
onkelandy Aug 3, 2023
3271be9
stateengine plugin: make se_eval_.. work as a standalone eval declara…
onkelandy Aug 3, 2023
bce6b86
stateengine plugin: bump version 1.10.0
onkelandy Aug 3, 2023
cd23e34
stateengine plugin: improve logging on startup. Initial config is log…
onkelandy Aug 3, 2023
a258e65
stateengine plugin: improve value conversion on demand
onkelandy Aug 3, 2023
6f75461
stateengine plugin: fix previously introduced issue (internal)
onkelandy Aug 3, 2023
7adfbf2
stateeninge plugin: if item can not be evaluated (e.g. by wrong eval)…
onkelandy Aug 3, 2023
bed16a5
stateengine plugin: improve logging
onkelandy Aug 3, 2023
2d83a58
stateengine plugin: introduce triggeredby condition functionality (eq…
onkelandy Aug 4, 2023
874d008
stateengine plugin: general code improvements and optimizations
onkelandy Aug 10, 2023
5903554
stateengine plugin: big improvement on the web interface visualizatio…
onkelandy Aug 10, 2023
0feb57e
stateengine plugin: fix previously introduced issue with conditions_c…
onkelandy Aug 10, 2023
73867af
stateengine plugin: improve web interface tooltips for actions
onkelandy Aug 10, 2023
1b60b07
stateengine plugin: fix web interface visu with empty actions
onkelandy Aug 10, 2023
0d1b8f9
stateengine plugin: improve error messag in web interface
onkelandy Aug 16, 2023
a388b11
stateengine plugin: minor code and logging improvements, allow se_eva…
onkelandy Aug 16, 2023
8904332
stateengine plugin: catch some possible exceptions/issues in web inte…
onkelandy Aug 16, 2023
3e5fb92
stateengine plugin: improve error handling when laststate items, etc.…
onkelandy Aug 16, 2023
ff2b48a
stateengine plugin: fix recently introduces issues
onkelandy Aug 16, 2023
bce5bfc
stateengine plugin: improve graphviz issue handling and logging
onkelandy Aug 16, 2023
7de7aeb
stateengine plugin: Introduce option to define se_log_level via an it…
onkelandy Aug 19, 2023
ac1ecfb
stateengine plugin: update webif init.py to reflect the new feature c…
onkelandy Aug 19, 2023
0a0e142
stateengine plugin: fix issue with log_level. Update web interface to…
onkelandy Aug 19, 2023
21be073
stateengine plugin: minor tweaks, implement se_leaveaction in general…
onkelandy Aug 19, 2023
c009483
stateengine plugin: fix and improve code. Esp. fix action tooltip i w…
onkelandy Aug 19, 2023
367092a
stateengine plugin: introduce new feature on initialization: unsued s…
onkelandy Aug 19, 2023
75ee7eb
stateengine plugin: improve webif error handling regarding icons for …
onkelandy Aug 19, 2023
81e6433
stateengine plugin: fix previously introduced issue with action issue…
onkelandy Aug 20, 2023
0e661a1
stateengine plugin: fix previously introduced problem with suspend ac…
onkelandy Aug 21, 2023
d68ccf4
stateengine plugin: improve and fix initial logging of problems
onkelandy Aug 21, 2023
fe3ec18
stateengine plugin: improve warning at initialziation for issues with…
onkelandy Aug 21, 2023
adedf55
stateengine plugin: improve struct
onkelandy Aug 21, 2023
169edcf
stateengine plugin: improve logging
onkelandy Aug 21, 2023
416dc41
stateengine plugin: urgent fix of previously introduced issue when ch…
onkelandy Aug 21, 2023
ce67b30
stateengine plugin: fix web interface icons for actions. Now only bei…
onkelandy Aug 22, 2023
053201b
stateengine plugin: if attributes are not used log level is info inst…
onkelandy Aug 22, 2023
7633bcc
stateengine plugin: remove warning in web if (forgotten msg while deb…
onkelandy Aug 22, 2023
c8ab8f0
stateengine plugin: improve se_releasedby handling - removing states …
onkelandy Aug 22, 2023
04791d7
stateengine plugin: rename internal variable
onkelandy Aug 22, 2023
42581b1
stateengine plugin: refactor se_instant_leaveaction. Can now be overw…
onkelandy Aug 22, 2023
e303121
plugin stateengine: minor updates and documentation update for se_lea…
onkelandy Aug 23, 2023
cb38351
stateengine plugin: initialize suspendduration with negative value in…
onkelandy Aug 23, 2023
1cffcbf
stateengine plugin: improve logging for set_by_attr value handling
onkelandy Aug 23, 2023
35f3d25
stateengine plugin: minor logging improvements and fixes
onkelandy Aug 24, 2023
12f6329
stateengine plugin: improve retrigger and release structs, fix docume…
onkelandy Aug 24, 2023
9765ef9
stateengine plugin: improve logging, structs and minor internal things
onkelandy Aug 27, 2023
e4cc02f
stateengine: completely redone "se_released_by" handling and largely …
onkelandy Aug 27, 2023
e6ee559
stateengine: improve web interface: Icons on conditions are only show…
onkelandy Aug 31, 2023
04004e8
stateengine plugin: some code refactoring and internal issue fixing a…
onkelandy Aug 31, 2023
e9d847c
stateengine plugin: improve configuration issue handling and logging
onkelandy Aug 31, 2023
6a8fdb5
stateengine plugin: improve se_use attribute handling and error checking
onkelandy Aug 31, 2023
d031192
stateengine plugin: introduce possibility to delete a scheduler for d…
onkelandy Aug 31, 2023
6a4a91b
stateengine plugin: refactor, optimize and extend se_released_by func…
onkelandy Aug 31, 2023
bbc8496
stateengine plugin: update suspend structs to delete retrigger schedu…
onkelandy Aug 31, 2023
b5d55b3
stateengine plugin: update plugin.yaml and dump version to 2.0.0
onkelandy Aug 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
628 changes: 412 additions & 216 deletions stateengine/StateEngineAction.py

Large diffs are not rendered by default.

43 changes: 30 additions & 13 deletions stateengine/StateEngineActions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,14 @@
#########################################################################
from . import StateEngineAction
from . import StateEngineTools

import ast
import threading
import queue


# Class representing a list of actions
class SeActions(StateEngineTools.SeItemChild):
@property
def dict_actions(self):
result = {}
for name in self.__actions:
self._abitem._initactionname = name
result.update({name: self.__actions[name].get()})
self._abitem._initactionname = None
return result

# Initialize the set of actions
# abitem: parent SeItem instance
Expand All @@ -56,6 +49,21 @@ def __init__(self, abitem):
def __repr__(self):
return "SeActions, count {}".format(self.count())

def dict_actions(self, type, state):
result = {}
for name in self.__actions:
self._abitem._initactionname = name
result.update({name: self.__actions[name].get()})
try:
result[name].update({'actionstatus': self._abitem.webif_infos[state][type][name].get('actionstatus')})
except Exception:
pass
self._abitem._initactionname = None
return result

def reset(self):
self.__actions = {}

# Return number of actions in list
def count(self):
return len(self.__actions)
Expand All @@ -67,6 +75,7 @@ def update(self, attribute, value):
# Split attribute in function and action name
func, name = StateEngineTools.partition_strip(attribute, "_")
_count = 0
_issue = None
try:
if func == "se_delay":
# set delay
Expand Down Expand Up @@ -133,17 +142,18 @@ def update(self, attribute, value):
self.__actions[name].update_order(value)
return
elif func == "se_action": # and name not in self.__actions:
self.__handle_combined_action_attribute(name, value)
_issue = self.__handle_combined_action_attribute(name, value)
_count += 1
elif self.__ensure_action_exists(func, name):
# update action
self.__actions[name].update(value)
_issue = self.__actions[name].update(value)
_count += 1
except ValueError as ex:
if name in self.__actions:
del self.__actions[name]
_issue = {name: {'issue': ex, 'issueorigin': [{'state': 'unknown', 'action': 'unknown'}]}}
self._log_warning("Ignoring action {0} because: {1}", attribute, ex)
return _count
return _count, _issue

# ensure that action exists and create if missing
# func: action function
Expand Down Expand Up @@ -279,6 +289,7 @@ def __handle_combined_action_attribute(self, name, value_list):

# create action based on function
exists = False
_issue = None
try:
if parameter['function'] == "set":
if self.__ensure_action_exists("se_set", name):
Expand Down Expand Up @@ -342,6 +353,7 @@ def __handle_combined_action_attribute(self, name, value_list):
exists = False
if name in self.__actions:
del self.__actions[name]
_issue = {name: {'issue': ex, 'issueorigin': [{'state': 'unknown', 'action': 'unknown'}]}}
self._log_warning("Ignoring action {0} because: {1}", name, ex)

# add additional parameters
Expand All @@ -363,6 +375,8 @@ def __handle_combined_action_attribute(self, name, value_list):
if parameter['mode'] is not None:
self.__actions[name].update_modes(parameter['mode'])

return _issue

# noinspection PyMethodMayBeStatic
def __raise_missing_parameter_error(self, parameter, param_name):
if param_name not in parameter or parameter[param_name] is None:
Expand All @@ -372,11 +386,14 @@ def __raise_missing_parameter_error(self, parameter, param_name):
# Check the actions optimize and complete them
# item_state: item to read from
def complete(self, item_state, evals_items=None):
_status = {}
for name in self.__actions:
try:
self.__actions[name].complete(item_state, evals_items)
_status.update(self.__actions[name].complete(item_state, evals_items))
except ValueError as ex:
_status.update({name: {'issue': ex, 'issueorigin': {'state': item_state.property.path, 'action': 'unknown'}}})
raise ValueError("State '{0}', Action '{1}': {2}".format(item_state.property.path, name, ex))
return _status

def set(self, value):
for name in self.__actions:
Expand All @@ -390,7 +407,7 @@ def set(self, value):
# item_allow_repeat: Is repeating actions generally allowed for the item?
# state: state item triggering the action
# additional_actions: SeActions-Instance containing actions which should be executed, too
def execute(self, is_repeat: bool, allow_item_repeat: bool, state: str, additional_actions=None):
def execute(self, is_repeat: bool, allow_item_repeat: bool, state, additional_actions=None):
actions = []
for name in self.__actions:
actions.append((self.__actions[name].get_order(), self.__actions[name]))
Expand Down
Loading