Respect global topic prefix when debug logging topic subscription
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import paho.mqtt.client as mqtt
|
||||
from logger import _LOGGER
|
||||
|
||||
|
||||
class MqttClient:
|
||||
@@ -54,6 +55,7 @@ class MqttClient:
|
||||
def callbacks_subscription(self, callbacks):
|
||||
for topic, callback in callbacks:
|
||||
topic = "{}/{}".format(self.topic_prefix, topic) if self.topic_prefix else topic
|
||||
_LOGGER.debug("Subscribing to: %s" % topic)
|
||||
self.mqttc.message_callback_add(topic, callback)
|
||||
self.mqttc.subscribe(topic)
|
||||
|
||||
|
||||
@@ -61,7 +61,6 @@ class WorkersManager:
|
||||
raise "%s cannot be initialized, it has to define run or status_update method" % worker_name
|
||||
|
||||
if 'topic_subscription' in worker_config:
|
||||
_LOGGER.debug("Subscribing to: %s" % worker_config['topic_subscription'])
|
||||
self._mqtt_callbacks.append((
|
||||
worker_config['topic_subscription'],
|
||||
partial(self._on_command_wrapper, worker_obj)
|
||||
@@ -69,7 +68,6 @@ class WorkersManager:
|
||||
|
||||
if 'topic_subscription' in config:
|
||||
for (callback_name, options) in config['topic_subscription'].items():
|
||||
_LOGGER.debug("Subscribing to: %s with command: %s" % (options['topic'], callback_name))
|
||||
self._mqtt_callbacks.append((
|
||||
options['topic'],
|
||||
lambda client, _ , c: self._queue_if_matching_payload(self.Command(getattr(self, callback_name)), c.payload, options['payload']))
|
||||
|
||||
Reference in New Issue
Block a user