Skip to content

Commit

Permalink
Single update for all relays placed tasks. (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTail authored Aug 26, 2023
1 parent ec59a51 commit 0748478
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion octoprint_octorelay/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def on_event(self, event, payload):
def handle_plugin_event(self, event, scope = RELAY_INDEXES):
self._logger.debug(f"Handling the plugin event {event} having scope: {scope}")
settings = self._settings.get([], merged=True) # expensive
needs_ui_update = False
for index in scope:
if bool(settings[index]["active"]):
target = settings[index]["rules"][event]["state"]
Expand All @@ -202,7 +203,9 @@ def handle_plugin_event(self, event, scope = RELAY_INDEXES):
self.tasks.append(task)
task.timer.start()
self._logger.debug(f"The task registered: {task}")
self.update_ui() # issue 190
needs_ui_update = True
if needs_ui_update:
self.update_ui() # issue 190

def toggle_relay(self, index, target: Optional[bool] = None):
settings = self._settings.get([index], merged=True) # expensive
Expand Down

0 comments on commit 0748478

Please sign in to comment.