From ea5cc50729acfd306a9b025fd7ca8e621facdfae Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Tue, 6 Jun 2023 17:00:13 +0300 Subject: fix --- src/home/mqtt/_module.py | 3 +++ src/home/mqtt/_node.py | 5 +++++ 2 files changed, 8 insertions(+) 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: -- cgit v1.2.3