From 2793457393d4327604d33e81587d13d7e0a6a55c Mon Sep 17 00:00:00 2001 From: David Zingg Date: Wed, 20 Nov 2019 21:41:44 +0100 Subject: [PATCH] #6 UI Updates senden und anzeigen --- octoprint_mystromswitch/__init__.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/octoprint_mystromswitch/__init__.py b/octoprint_mystromswitch/__init__.py index 8b10fa8..854655b 100644 --- a/octoprint_mystromswitch/__init__.py +++ b/octoprint_mystromswitch/__init__.py @@ -49,9 +49,10 @@ class MyStromSwitchPlugin(octoprint.plugin.SettingsPlugin, self._logger.info(self.ip) self._logger.info(self.intervall) - self._logger.info("Starting timer.") - self._timer = RepeatedTimer(self.intervall, self._timer_task) - self._timer.start() + if self.intervall >= 1 and self.ip is not None: + self._logger.info("Starting timer") + self._timer = RepeatedTimer(self.intervall, self._timer_task) + self._timer.start() def _timer_task(self): self._logger.debug("timer_task") @@ -75,6 +76,10 @@ 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_initialized(self): self._logger.info("on_settings_initialized") self.initialize()