From 9afe94169db204045ab43b138e7cce89c54b2f6c Mon Sep 17 00:00:00 2001 From: David Zingg Date: Sat, 29 Aug 2020 16:44:46 +0200 Subject: [PATCH] #21 Only check shutdown command defined if Raspberry Pi needs to shutdown --- .idea/workspace.xml | 31 +++++++++++++++-------------- octoprint_mystromswitch/__init__.py | 8 ++++---- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 183db3a..ee7e3e4 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,6 +3,7 @@ + diff --git a/octoprint_mystromswitch/__init__.py b/octoprint_mystromswitch/__init__.py index 52564d3..d7f7db5 100644 --- a/octoprint_mystromswitch/__init__.py +++ b/octoprint_mystromswitch/__init__.py @@ -162,6 +162,10 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin, self._status_timer.start() def _shutdown_system(self): + if not self._settings.global_get(["server", "commands", "systemShutdownCommand"]): + self._logger.warning("systemShutdownCommand is not defined. Aborting shutdown...") + return + self._logger.info("Shutdown Relais and System") self._powerCycleRelais(False, self.powerOffDelay) shutdown_command = self._settings.global_get(["server", "commands", "systemShutdownCommand"]) @@ -390,10 +394,6 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin, if not self.shutdownAfterPrintFinished and not self.powerOffAfterPrintFinished: return - if not self._settings.global_get(["server", "commands", "systemShutdownCommand"]): - self._logger.warning("systemShutdownCommand is not defined. Aborting shutdown...") - return - if event not in [Events.PRINT_DONE, Events.PRINT_FAILED]: return