#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,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'

View File

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