#22 Button taucht nicht auf

Fehler anzeigen wenn Verbindung zu switch nicht klappt
This commit is contained in:
David Zingg 2020-02-29 16:28:30 +01:00
parent 3d7cb06446
commit cc106e258c
2 changed files with 11 additions and 1 deletions

View File

@ -107,13 +107,19 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin,
self.lastTimeStamp = timestamp self.lastTimeStamp = timestamp
data["energy"] = self.energy data["energy"] = self.energy
data["onOffButtonEnabled"] = self.onOffButtonEnabled data["onOffButtonEnabled"] = self.onOffButtonEnabled
data["showShutdownOctopiOption"] = self.showShutdownOctopiOption
data["showPowerOffPrintFinishOption"] = self.showPowerOffPrintFinishOption
self._plugin_manager.send_plugin_message(self._identifier, data) self._plugin_manager.send_plugin_message(self._identifier, data)
return
except (requests.exceptions.ConnectionError, ValueError) as e: except (requests.exceptions.ConnectionError, ValueError) as e:
self._logger.exception(e) self._logger.exception(e)
except Exception as exp: except Exception as exp:
self._logger.exception(exp) self._logger.exception(exp)
else: else:
self._logger.info("Ip is None") 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): def _setRelaisState(self, newState):
nbRetry = 0 nbRetry = 0

View File

@ -70,11 +70,15 @@ $(function() {
return; return;
} }
self.onOffButtonEnabled(data.onOffButtonEnabled); self.onOffButtonEnabled(data.onOffButtonEnabled);
self.showShutdownOctopiOption(data.showShutdownOctopiOption);
self.showPowerOffPrintFinishOption(data.showPowerOffPrintFinishOption);
self.mystromswitchEnergyValue.innerHTML = "Energy: "+data.energy.toFixed(1)+"Wh" self.mystromswitchEnergyValue.innerHTML = "Energy: "+data.energy.toFixed(1)+"Wh"
if(data.relay == false){ if(data.relay == false){
self.mystromswitchPowerValue.innerHTML = "Relay is off"; self.mystromswitchPowerValue.innerHTML = "Relay is off";
} else if (data.power != null) { } else if (data.power != null) {
self.mystromswitchPowerValue.innerHTML = "Power Consumption "+data.power.toFixed(1)+"W"; self.mystromswitchPowerValue.innerHTML = "Power Consumption "+data.power.toFixed(1)+"W";
}else{
self.mystromswitchPowerValue.innerHTML = "myStrom switch not reachable"
} }
} }
} }