summaryrefslogtreecommitdiff
path: root/src/home/mqtt/module/diagnostics.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/home/mqtt/module/diagnostics.py')
-rw-r--r--src/home/mqtt/module/diagnostics.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/home/mqtt/module/diagnostics.py b/src/home/mqtt/module/diagnostics.py
index c31cce2..fa6cc8e 100644
--- a/src/home/mqtt/module/diagnostics.py
+++ b/src/home/mqtt/module/diagnostics.py
@@ -48,14 +48,17 @@ class DiagnosticsPayload(MqttPayload):
class MqttDiagnosticsModule(MqttModule):
- def init(self, mqtt: MqttNode):
+ def on_connect(self, mqtt: MqttNode):
+ super().on_connect(mqtt)
for topic in ('diag', 'd1ag', 'stat', 'stat1'):
mqtt.subscribe_module(topic, self)
def handle_payload(self, mqtt: MqttNode, topic: str, payload: bytes) -> Optional[MqttPayload]:
+ message = None
if topic in ('stat', 'diag'):
message = DiagnosticsPayload.unpack(payload)
elif topic in ('stat1', 'd1ag'):
message = InitialDiagnosticsPayload.unpack(payload)
- self._logger.debug(message)
+ if message:
+ self._logger.debug(message)
return message