summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/home/mqtt/_module.py3
-rw-r--r--src/home/mqtt/_node.py5
2 files changed, 8 insertions, 0 deletions
diff --git a/src/home/mqtt/_module.py b/src/home/mqtt/_module.py
index ef50e70..840534e 100644
--- a/src/home/mqtt/_module.py
+++ b/src/home/mqtt/_module.py
@@ -27,6 +27,9 @@ class MqttModule(abc.ABC):
def set_initialized(self):
self._initialized = True
+ def unset_initialized(self):
+ self._initialized = False
+
def tick(self, mqtt: MqttNode):
pass
diff --git a/src/home/mqtt/_node.py b/src/home/mqtt/_node.py
index 688b30b..9e39911 100644
--- a/src/home/mqtt/_node.py
+++ b/src/home/mqtt/_node.py
@@ -38,6 +38,11 @@ class MqttNode(MqttBase):
module.init(self)
module.set_initialized()
+ def on_disconnect(self, client: mqtt.Client, userdata, rc):
+ super().on_disconnect(client, userdata, rc)
+ for module in self._modules:
+ module.unset_initialized()
+
def on_publish(self, client: mqtt.Client, userdata, mid):
pass # FIXME
# if self._ota_mid is not None and mid == self._ota_mid and self._ota_publish_callback: