From 2ce950e2da52b9fdb6b7778254fa680468b578aa Mon Sep 17 00:00:00 2001 From: David Zingg Date: Wed, 20 Nov 2019 20:18:16 +0100 Subject: [PATCH] #5 Rest Api integration - Nullpointer fix --- octoprint_mystromswitch/__init__.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/octoprint_mystromswitch/__init__.py b/octoprint_mystromswitch/__init__.py index 32b87d6..7421e0a 100644 --- a/octoprint_mystromswitch/__init__.py +++ b/octoprint_mystromswitch/__init__.py @@ -24,8 +24,6 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin, self.ctx.check_hostname = False self.ctx.verify_mode = ssl.CERT_NONE - self.initialize() - def initialize(self): self.ip = self._settings.get(["ip"]) self._logger.debug("ip: %s" % self.ip) @@ -71,6 +69,16 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin, def on_shutdown(self): self._logger.info("Hello World!") + def on_settings_load(self): + self._logger.info("on_settings_load") + self.initialize() + + def on_settings_migrate(self, target, current): + pass + + def get_settings_version(self): + return 1 + def get_settings_defaults(self): return dict( ip=None,