Skip to content

Commit 0ed1946

Browse files
Teddy-1000fjugipe
andauthored
Fix settings of MQTT topic prepend (#274)
* Fix settings of MQTT topic prepend * Update ingest/api/send_mqtt.py Co-authored-by: Jukka Pelli <132542798+fjugipe@users.noreply.github.com> * Update ingest/api/send_mqtt.py Co-authored-by: Jukka Pelli <132542798+fjugipe@users.noreply.github.com> * FIx missing bracket --------- Co-authored-by: Jukka Pelli <132542798+fjugipe@users.noreply.github.com>
1 parent 8552b92 commit 0ed1946

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ingest/api/send_mqtt.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66

77
logger = logging.getLogger(__name__)
88

9-
if "MQTT_TOPIC_PREPEND" in os.environ:
10-
mqtt_topic_prepend = os.getenv("MQTT_TOPIC_PREPEND", "")
9+
mqtt_topic_prepend = os.getenv("MQTT_TOPIC_PREPEND", "")
10+
if not mqtt_topic_prepend or mqtt_topic_prepend == "/":
11+
mqtt_topic_prepend = ""
12+
logger.error("MQTT_TOPIC_PREPEND cannot be just a '/'. Setting topic prepend to empty string.")
13+
else:
1114
mqtt_topic_prepend = mqtt_topic_prepend if mqtt_topic_prepend.endswith("/") else mqtt_topic_prepend + "/"
1215

1316

0 commit comments

Comments
 (0)