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" } } }