From d5e3a39fb20e40e504309ff60e56dfecc70d8f3a Mon Sep 17 00:00:00 2001 From: Lyn Lee <15036012006@126.com> Date: Wed, 25 Jun 2025 10:09:37 +0800 Subject: [PATCH] =?UTF-8?q?mqtt=E9=80=9A=E9=85=8D=E7=AC=A6=E8=AE=A2?= =?UTF-8?q?=E9=98=85=E7=9A=84=E5=9B=9E=E8=B0=83=E5=87=BD=E6=95=B0=E5=BF=85?= =?UTF-8?q?=E9=A1=BB=E5=8F=91=E9=80=81=E4=B8=BB=E9=A2=98=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- moonraker/components/mqtt.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/moonraker/components/mqtt.py b/moonraker/components/mqtt.py index e8232b4..a6f35c7 100644 --- a/moonraker/components/mqtt.py +++ b/moonraker/components/mqtt.py @@ -473,15 +473,15 @@ class MQTTClient(APITransport): self.status_cache = {} self._publish_status_update(payload, self.last_status_time) - def _get_topic_handles(self, topic) -> Optional[list]: + def _get_topic_handles(self, topic) -> Optional[tuple[list, bool]]: if topic in self.subscribed_topics: - return self.subscribed_topics[topic][1] + return self.subscribed_topics[topic][1], False for wildcardTopic, pattern in self.regex_topics_map.items(): if pattern.match(topic): cb_hdls = self.subscribed_topics[wildcardTopic][1].copy() for cb in cb_hdls: cb.topic = topic - return cb_hdls + return cb_hdls, True else: return None @@ -493,9 +493,11 @@ class MQTTClient(APITransport): topic = message.topic cb_hdls = self._get_topic_handles(topic) if cb_hdls: + cb_hdls, wildcard = cb_hdls for hdl in cb_hdls: self.eventloop.register_callback( - hdl.callback, message.payload) + hdl.callback, message.payload, + *((hdl.topic,) if wildcard else ())) else: logging.debug( f"Unregistered MQTT Topic Received: {topic}, "