#21 Only check shutdown command defined if Raspberry Pi needs to shutdown

This commit is contained in:
David Zingg 2020-08-29 16:44:46 +02:00
parent 96fdafb2dc
commit 9afe94169d
2 changed files with 20 additions and 19 deletions

View File

@ -3,6 +3,7 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="7e2e0eec-b22e-4d48-8f24-196d1ed9b51a" name="Default Changelist" comment=""> <list default="true" id="7e2e0eec-b22e-4d48-8f24-196d1ed9b51a" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/octoprint_mystromswitch/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/octoprint_mystromswitch/__init__.py" afterDir="false" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
@ -47,20 +48,6 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1574193087583</updated> <updated>1574193087583</updated>
</task> </task>
<task id="LOCAL-00056" summary="#17 Logging zur Fehleranalyse eingebaut">
<created>1578941071143</created>
<option name="number" value="00056" />
<option name="presentableId" value="LOCAL-00056" />
<option name="project" value="LOCAL" />
<updated>1578941071143</updated>
</task>
<task id="LOCAL-00057" summary="#17 Logging zur Fehleranalyse eingebaut">
<created>1579188503178</created>
<option name="number" value="00057" />
<option name="presentableId" value="LOCAL-00057" />
<option name="project" value="LOCAL" />
<updated>1579188503178</updated>
</task>
<task id="LOCAL-00058" summary="#17 Logging zur Fehleranalyse eingebaut"> <task id="LOCAL-00058" summary="#17 Logging zur Fehleranalyse eingebaut">
<created>1579190155814</created> <created>1579190155814</created>
<option name="number" value="00058" /> <option name="number" value="00058" />
@ -390,7 +377,21 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1593633696895</updated> <updated>1593633696895</updated>
</task> </task>
<option name="localTasksCounter" value="105" /> <task id="LOCAL-00105" summary="#25 Python 3 Compatibility">
<created>1595688504296</created>
<option name="number" value="00105" />
<option name="presentableId" value="LOCAL-00105" />
<option name="project" value="LOCAL" />
<updated>1595688504296</updated>
</task>
<task id="LOCAL-00106" summary="#25 Python 3 Compatibility">
<created>1595688536404</created>
<option name="number" value="00106" />
<option name="presentableId" value="LOCAL-00106" />
<option name="project" value="LOCAL" />
<updated>1595688536404</updated>
</task>
<option name="localTasksCounter" value="107" />
<servers /> <servers />
</component> </component>
<component name="UnknownFeatures"> <component name="UnknownFeatures">

View File

@ -162,6 +162,10 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
self._status_timer.start() self._status_timer.start()
def _shutdown_system(self): 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._logger.info("Shutdown Relais and System")
self._powerCycleRelais(False, self.powerOffDelay) self._powerCycleRelais(False, self.powerOffDelay)
shutdown_command = self._settings.global_get(["server", "commands", "systemShutdownCommand"]) 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: if not self.shutdownAfterPrintFinished and not self.powerOffAfterPrintFinished:
return 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]: if event not in [Events.PRINT_DONE, Events.PRINT_FAILED]:
return return