From 3d7cb06446691d08aa6ca48b1b870a0bd369f02c Mon Sep 17 00:00:00 2001 From: David Zingg Date: Sat, 29 Feb 2020 16:08:03 +0100 Subject: [PATCH 01/26] #21 Add PowerOFF when print is finished MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit neue Einstellmöglichkeiten anzeigen --- .idea/misc.xml | 2 +- .idea/workspace.xml | 228 +++++++++++++++++- octoprint_mystromswitch/__init__.py | 77 +++++- .../static/js/mystromswitch.js | 41 +++- .../templates/mystromswitch_settings.jinja2 | 31 +++ .../templates/mystromswitch_sidebar.jinja2 | 9 + 6 files changed, 373 insertions(+), 15 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index d3b7f65..cf3bce4 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 3a46de4..7b41104 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,8 +2,12 @@ + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + onOffBu + onOffButtonEnabled + onmystromswitchEvent + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Show option to automatic shutdown Octoprint after Print is finished + + {{ _('This setting shows the option to shut Octoprint down and switch your mySwitch off after your Print is finished.') }} + + + +
+
+ + {{ _('This setting shows the option to switch your mySwitch off after your Print is finished') }} +
+
+ +
+ +
+
+ + seconds +
+ {{ _('Delay in seconds after after print is finished') }} +
+
+ diff --git a/octoprint_mystromswitch/templates/mystromswitch_sidebar.jinja2 b/octoprint_mystromswitch/templates/mystromswitch_sidebar.jinja2 index 8fa3af7..13d22f9 100644 --- a/octoprint_mystromswitch/templates/mystromswitch_sidebar.jinja2 +++ b/octoprint_mystromswitch/templates/mystromswitch_sidebar.jinja2 @@ -2,4 +2,13 @@ + + + From cc106e258ce4240fb9f28c4e9507825dda2a8fbc Mon Sep 17 00:00:00 2001 From: David Zingg Date: Sat, 29 Feb 2020 16:28:30 +0100 Subject: [PATCH 02/26] #22 Button taucht nicht auf Fehler anzeigen wenn Verbindung zu switch nicht klappt --- octoprint_mystromswitch/__init__.py | 8 +++++++- octoprint_mystromswitch/static/js/mystromswitch.js | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/octoprint_mystromswitch/__init__.py b/octoprint_mystromswitch/__init__.py index ff11b48..abbd4d7 100644 --- a/octoprint_mystromswitch/__init__.py +++ b/octoprint_mystromswitch/__init__.py @@ -107,14 +107,20 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin, self.lastTimeStamp = timestamp data["energy"] = self.energy data["onOffButtonEnabled"] = self.onOffButtonEnabled + data["showShutdownOctopiOption"] = self.showShutdownOctopiOption + data["showPowerOffPrintFinishOption"] = self.showPowerOffPrintFinishOption self._plugin_manager.send_plugin_message(self._identifier, data) + return except (requests.exceptions.ConnectionError, ValueError) as e: self._logger.exception(e) except Exception as exp: self._logger.exception(exp) else: self._logger.info("Ip is None") - + data = {"relay": True, "energy": 0, "onOffButtonEnabled": False, "showShutdownOctopiOption": False, + "showPowerOffPrintFinishOption": False} + self._plugin_manager.send_plugin_message(self._identifier, data) + def _setRelaisState(self, newState): nbRetry = 0 value = '0' diff --git a/octoprint_mystromswitch/static/js/mystromswitch.js b/octoprint_mystromswitch/static/js/mystromswitch.js index 81310e4..186f7a3 100644 --- a/octoprint_mystromswitch/static/js/mystromswitch.js +++ b/octoprint_mystromswitch/static/js/mystromswitch.js @@ -70,11 +70,15 @@ $(function() { return; } self.onOffButtonEnabled(data.onOffButtonEnabled); + self.showShutdownOctopiOption(data.showShutdownOctopiOption); + self.showPowerOffPrintFinishOption(data.showPowerOffPrintFinishOption); self.mystromswitchEnergyValue.innerHTML = "Energy: "+data.energy.toFixed(1)+"Wh" if(data.relay == false){ self.mystromswitchPowerValue.innerHTML = "Relay is off"; } else if (data.power != null) { self.mystromswitchPowerValue.innerHTML = "Power Consumption "+data.power.toFixed(1)+"W"; + }else{ + self.mystromswitchPowerValue.innerHTML = "myStrom switch not reachable" } } } From 83608fa80710bd22d075b0e376be650e610a78f0 Mon Sep 17 00:00:00 2001 From: David Zingg Date: Sat, 29 Feb 2020 16:39:59 +0100 Subject: [PATCH 03/26] #21 Add PowerOFF when print is finished --- .idea/workspace.xml | 113 +++++++++--------- .../static/js/mystromswitch.js | 4 +- .../templates/mystromswitch_sidebar.jinja2 | 4 +- 3 files changed, 60 insertions(+), 61 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 7b41104..0f429ab 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,11 +2,8 @@ - - - - + @@ -564,7 +562,7 @@ - + @@ -609,7 +607,6 @@ - @@ -633,42 +630,44 @@ - - - - - + - - - - - - - - - - - - - + + - - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/octoprint_mystromswitch/static/js/mystromswitch.js b/octoprint_mystromswitch/static/js/mystromswitch.js index 186f7a3..3f98a87 100644 --- a/octoprint_mystromswitch/static/js/mystromswitch.js +++ b/octoprint_mystromswitch/static/js/mystromswitch.js @@ -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") { diff --git a/octoprint_mystromswitch/templates/mystromswitch_sidebar.jinja2 b/octoprint_mystromswitch/templates/mystromswitch_sidebar.jinja2 index 13d22f9..dd68376 100644 --- a/octoprint_mystromswitch/templates/mystromswitch_sidebar.jinja2 +++ b/octoprint_mystromswitch/templates/mystromswitch_sidebar.jinja2 @@ -3,12 +3,12 @@ From 419bac31370db537a968bb2dfc252c6bf437dc0c Mon Sep 17 00:00:00 2001 From: David Zingg Date: Sat, 29 Feb 2020 16:43:53 +0100 Subject: [PATCH 04/26] #21 Add PowerOFF when print is finished --- octoprint_mystromswitch/__init__.py | 8 ++++++-- octoprint_mystromswitch/static/js/mystromswitch.js | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/octoprint_mystromswitch/__init__.py b/octoprint_mystromswitch/__init__.py index abbd4d7..7afb0e8 100644 --- a/octoprint_mystromswitch/__init__.py +++ b/octoprint_mystromswitch/__init__.py @@ -120,7 +120,7 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin, data = {"relay": True, "energy": 0, "onOffButtonEnabled": False, "showShutdownOctopiOption": False, "showPowerOffPrintFinishOption": False} self._plugin_manager.send_plugin_message(self._identifier, data) - + def _setRelaisState(self, newState): nbRetry = 0 value = '0' @@ -207,7 +207,11 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin, return dict( enableRelais=[], disableRelais=[], - toggleRelais=[] + toggleRelais=[], + disableShutdownAfterFinish=[], + enableShutdownAfterFinish=[], + disablePowerOffAfterFinish=[], + enablePowerOffAfterFinish=[] ) def on_after_startup(self): diff --git a/octoprint_mystromswitch/static/js/mystromswitch.js b/octoprint_mystromswitch/static/js/mystromswitch.js index 3f98a87..8d0c978 100644 --- a/octoprint_mystromswitch/static/js/mystromswitch.js +++ b/octoprint_mystromswitch/static/js/mystromswitch.js @@ -30,7 +30,7 @@ $(function() { //self.onOffButtonEnabled.subscribe(self.onmystromswitchEvent, self); - self.onAutomaticShutdownEnabledChanged = function(){ + /*self.onAutomaticShutdownEnabledChanged = function(){ var cmd = "disableShutdownAfterFinish"; if (self.automaticShutdownEnabled()) { var cmd = "enableShutdownAfterFinish"; @@ -60,7 +60,7 @@ $(function() { }), contentType: "application/json; charset=UTF-8" }) - } + }*/ //self.automaticShutdownEnabled.subscribe(self.onAutomaticShutdownEnabledChanged,self); //self.automaticPowerOffEnabled.subscribe(self.onAutomaticPowerOffEnabledChanged,self); From 1c3c49bab918295c9588db25ba2be84197fb49f3 Mon Sep 17 00:00:00 2001 From: David Zingg Date: Sat, 29 Feb 2020 16:49:12 +0100 Subject: [PATCH 05/26] #21 Add PowerOFF when print is finished --- .idea/workspace.xml | 106 ++++++++---------- .../static/js/mystromswitch.js | 12 +- .../templates/mystromswitch_settings.jinja2 | 2 +- .../templates/mystromswitch_sidebar.jinja2 | 4 +- 4 files changed, 58 insertions(+), 66 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 0f429ab..4862f78 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,6 +4,7 @@ +
@@ -607,7 +599,6 @@ - @@ -632,40 +623,41 @@ - - - - - - - - + + + + + + + - - + + - + - - + + - + - - + + diff --git a/octoprint_mystromswitch/static/js/mystromswitch.js b/octoprint_mystromswitch/static/js/mystromswitch.js index 8d0c978..599d6e3 100644 --- a/octoprint_mystromswitch/static/js/mystromswitch.js +++ b/octoprint_mystromswitch/static/js/mystromswitch.js @@ -7,8 +7,8 @@ $(function() { self.printer = parameters[2]; self.onOffButtonEnabled = ko.observable(); - self.showShutdownOctopiOption = ko.observable(); - self.showPowerOffPrintFinishOption = ko.observable(); + //self.showShutdownOctopiOption = ko.observable(); + //self.showPowerOffPrintFinishOption = ko.observable(); self.mystromswitchPowerValue = document.getElementById("mystromswitchPowerValue") self.mystromswitchEnergyValue = document.getElementById("mystromswitchEnergyValue") @@ -30,7 +30,7 @@ $(function() { //self.onOffButtonEnabled.subscribe(self.onmystromswitchEvent, self); - /*self.onAutomaticShutdownEnabledChanged = function(){ + self.onAutomaticShutdownEnabledChanged = function(){ var cmd = "disableShutdownAfterFinish"; if (self.automaticShutdownEnabled()) { var cmd = "enableShutdownAfterFinish"; @@ -60,7 +60,7 @@ $(function() { }), contentType: "application/json; charset=UTF-8" }) - }*/ + } //self.automaticShutdownEnabled.subscribe(self.onAutomaticShutdownEnabledChanged,self); //self.automaticPowerOffEnabled.subscribe(self.onAutomaticPowerOffEnabledChanged,self); @@ -70,8 +70,8 @@ $(function() { return; } self.onOffButtonEnabled(data.onOffButtonEnabled); - self.showShutdownOctopiOption(data.showShutdownOctopiOption); - self.showPowerOffPrintFinishOption(data.showPowerOffPrintFinishOption); + //self.showShutdownOctopiOption(data.showShutdownOctopiOption); + //self.showPowerOffPrintFinishOption(data.showPowerOffPrintFinishOption); self.mystromswitchEnergyValue.innerHTML = "Energy: "+data.energy.toFixed(1)+"Wh" if(data.relay == false){ self.mystromswitchPowerValue.innerHTML = "Relay is off"; diff --git a/octoprint_mystromswitch/templates/mystromswitch_settings.jinja2 b/octoprint_mystromswitch/templates/mystromswitch_settings.jinja2 index 7942819..933b399 100644 --- a/octoprint_mystromswitch/templates/mystromswitch_settings.jinja2 +++ b/octoprint_mystromswitch/templates/mystromswitch_settings.jinja2 @@ -1,7 +1,7 @@

General

- +
diff --git a/octoprint_mystromswitch/templates/mystromswitch_sidebar.jinja2 b/octoprint_mystromswitch/templates/mystromswitch_sidebar.jinja2 index dd68376..da5a304 100644 --- a/octoprint_mystromswitch/templates/mystromswitch_sidebar.jinja2 +++ b/octoprint_mystromswitch/templates/mystromswitch_sidebar.jinja2 @@ -3,12 +3,12 @@
From 531d7956158538c399ce85d3cbd3f12d895d5950 Mon Sep 17 00:00:00 2001 From: David Zingg Date: Sat, 29 Feb 2020 16:55:20 +0100 Subject: [PATCH 06/26] #21 Add PowerOFF when print is finished --- octoprint_mystromswitch/static/js/mystromswitch.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/octoprint_mystromswitch/static/js/mystromswitch.js b/octoprint_mystromswitch/static/js/mystromswitch.js index 599d6e3..87c6fb3 100644 --- a/octoprint_mystromswitch/static/js/mystromswitch.js +++ b/octoprint_mystromswitch/static/js/mystromswitch.js @@ -7,8 +7,8 @@ $(function() { self.printer = parameters[2]; self.onOffButtonEnabled = ko.observable(); - //self.showShutdownOctopiOption = ko.observable(); - //self.showPowerOffPrintFinishOption = ko.observable(); + self.showShutdownOctopiOption = ko.observable(); + self.showPowerOffPrintFinishOption = ko.observable(); self.mystromswitchPowerValue = document.getElementById("mystromswitchPowerValue") self.mystromswitchEnergyValue = document.getElementById("mystromswitchEnergyValue") @@ -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") { @@ -79,6 +79,7 @@ $(function() { self.mystromswitchPowerValue.innerHTML = "Power Consumption "+data.power.toFixed(1)+"W"; }else{ self.mystromswitchPowerValue.innerHTML = "myStrom switch not reachable" + self.mystromswitchEnergyValue.innerHTML = "Check url in Plugin Settings" } } } From b5d23ef46f48f8a0f81dc5ad8eeaecfbc5549f43 Mon Sep 17 00:00:00 2001 From: David Zingg Date: Sat, 29 Feb 2020 17:04:39 +0100 Subject: [PATCH 07/26] #21 Add PowerOFF when print is finished --- .idea/workspace.xml | 87 +++++++++++-------- .../static/js/mystromswitch.js | 4 +- .../templates/mystromswitch_sidebar.jinja2 | 4 +- 3 files changed, 53 insertions(+), 42 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 4862f78..201ac4c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,7 +4,6 @@ - @@ -198,20 +198,6 @@ @@ -198,13 +198,6 @@