fix for exception, when sending mqtt messages without topic

This commit is contained in:
Dirk Alders 2025-07-22 20:23:20 +02:00
parent 12044492cd
commit 7008ec077b

View File

@ -130,7 +130,10 @@ class MqttSniffer(App):
"""Event handler called when a button is pressed."""
if event.button.id == "send_button":
if self.mqtt is not None:
self.mqtt.send(self.send_topic, self.send_payload)
if len(self.send_topic) > 0:
self.mqtt.send(self.send_topic, self.send_payload)
else:
logger.warning("Can't send mqtt message with empty topic. topic=%s; payload=%s", repr(self.send_topic), repr(self.send_payload))
if __name__ == "__main__":