diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2023-06-06 17:00:13 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2023-06-06 17:00:13 +0300 |
commit | ea5cc50729acfd306a9b025fd7ca8e621facdfae (patch) | |
tree | 4288a3a13318e98966f54082f482ecbf8e0f6ea2 | |
parent | b56b2125bec334c12bb84342d5ada69e8cf4fc07 (diff) |
fix
-rw-r--r-- | src/home/mqtt/_module.py | 3 | ||||
-rw-r--r-- | src/home/mqtt/_node.py | 5 |
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: |