From 07484787ae187b5dbea8b7a432b1c0d5d3efb945 Mon Sep 17 00:00:00 2001 From: Anna Bocharova Date: Sat, 26 Aug 2023 21:31:59 +0200 Subject: [PATCH] Single update for all relays placed tasks. (#200) --- octoprint_octorelay/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/octoprint_octorelay/__init__.py b/octoprint_octorelay/__init__.py index f68f559b..8317ae45 100755 --- a/octoprint_octorelay/__init__.py +++ b/octoprint_octorelay/__init__.py @@ -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"] @@ -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