#21 Add PowerOFF when print is finished

This commit is contained in:
David Zingg
2020-06-28 14:20:30 +02:00
parent 2148d75b29
commit 78df6af17c
3 changed files with 19 additions and 228 deletions

View File

@ -202,6 +202,12 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
elif command == "disablePowerOffAfterFinish":
self._logger.info("disablePowerOffAfterFinish")
self.powerOffAfterPrintFinished = False
self._plugin_manager.send_plugin_message(self._identifier,
dict(showShutdownOctopiOption=self.shutdownAfterPrintFinished,
type="timeout", timeout_value=self._timeout_value))
self._plugin_manager.send_plugin_message(self._identifier,
dict(showPowerOffPrintFinishOption=self.powerOffAfterPrintFinished,
type="timeout", timeout_value=self._timeout_value))
def get_api_commands(self):
return dict(
@ -270,6 +276,15 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
def on_event(self, event, payload):
if event == Events.CLIENT_OPENED:
self._plugin_manager.send_plugin_message(self._identifier,
dict(showShutdownOctopiOption=self.shutdownAfterPrintFinished,
type="timeout", timeout_value=self._timeout_value))
self._plugin_manager.send_plugin_message(self._identifier,
dict(showPowerOffPrintFinishOption=self.powerOffAfterPrintFinished,
type="timeout", timeout_value=self._timeout_value))
return
if not self.shutdownAfterPrintFinished and not self.powerOffAfterPrintFinished:
return

View File

@ -62,8 +62,8 @@ $(function() {
})
}
//self.automaticShutdownEnabled.subscribe(self.onAutomaticShutdownEnabledChanged,self);
//self.automaticPowerOffEnabled.subscribe(self.onAutomaticPowerOffEnabledChanged,self);
self.automaticShutdownEnabled.subscribe(self.onAutomaticShutdownEnabledChanged,self);
self.automaticPowerOffEnabled.subscribe(self.onAutomaticPowerOffEnabledChanged,self);
self.onDataUpdaterPluginMessage = function(plugin, data) {
if (plugin != "mystromswitch" && plugin != "octoprint_mystromswitch") {