Skip to content

Commit

Permalink
Merge pull request #870 from onkelandy/stateengine
Browse files Browse the repository at this point in the history
stateengine plugin: change force action
  • Loading branch information
onkelandy authored Dec 28, 2023
2 parents bced298 + a8d69c6 commit 34cc9ba
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions stateengine/StateEngineAction.py
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,8 @@ def real_execute(self, state, actionname: str, namevar: str = "", repeat_text: s
return
source = self.set_source(current_condition, previous_condition, previousstate_condition)
# Set to different value first ("force")
if self.__item() == value:
current_value = self.__item()
if current_value == value:
if self.__item._type == 'bool':
self._log_debug("{0}: Set '{1}' to '{2}' (Force)", actionname, self.__item.property.path, not value)
self.__item(not value, caller=self._caller, source=source)
Expand All @@ -1091,12 +1092,8 @@ def real_execute(self, state, actionname: str, namevar: str = "", repeat_text: s
self._log_debug("{0}: Set '{1}' to '{2}' (Force)", actionname, self.__item.property.path, '-')
self.__item('-', caller=self._caller, source=source)
elif self.__item._type == 'num':
if value != 0:
self._log_debug("{0}: Set '{1}' to '{2}' (Force)", actionname, self.__item.property.path, 0)
self.__item(0, caller=self._caller, source=source)
else:
self._log_debug("{0}: Set '{1}' to '{2}' (Force)", actionname, self.__item.property.path, 1)
self.__item(1, caller=self._caller, source=source)
self._log_debug("{0}: Set '{1}' to '{2}' (Force)", actionname, self.__item.property.path, current_value+0.1)
self.__item(current_value+0.1, caller=self._caller, source=source)
else:
self._log_warning("{0}: Force not implemented for item type '{1}'", actionname, self.__item._type)
else:
Expand Down

0 comments on commit 34cc9ba

Please sign in to comment.