From b8ba6c0d2ba4f686c9dbf1e7469fd2988e248123 Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Mon, 22 Jul 2024 13:55:33 -0400 Subject: [PATCH] mqtt: add support for a user configured client id Signed-off-by: Eric Callahan --- moonraker/components/mqtt.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/moonraker/components/mqtt.py b/moonraker/components/mqtt.py index 07aa79e..48f8854 100644 --- a/moonraker/components/mqtt.py +++ b/moonraker/components/mqtt.py @@ -352,11 +352,13 @@ class MQTTClient(APITransport): "between 0 and 2") self.publish_split_status = \ config.getboolean("publish_split_status", False) + client_id: Optional[str] = config.get("client_id", None) if PAHO_MQTT_VERSION < (2, 0): - self.client = ExtPahoClient(protocol=self.protocol) + self.client = ExtPahoClient(client_id, protocol=self.protocol) else: self.client = ExtPahoClient( - paho_mqtt.CallbackAPIVersion.VERSION1, protocol=self.protocol + paho_mqtt.CallbackAPIVersion.VERSION1, client_id, + protocol=self.protocol ) self.client.on_connect = self._on_connect self.client.on_message = self._on_message