.
This commit is contained in:
+10
-6
@@ -83,10 +83,14 @@ class WorkersManager:
|
||||
raise "%s cannot be initialized, it has to define run or status_update method" % worker_name
|
||||
|
||||
if 'topic_subscription' in worker_config:
|
||||
self._mqtt_callbacks.append((
|
||||
worker_config['topic_subscription'],
|
||||
partial(self._on_command_wrapper, worker_obj)
|
||||
))
|
||||
topics = worker_config['topic_subscription']
|
||||
if isinstance(topics, str):
|
||||
topics = [topics]
|
||||
for topic in topics:
|
||||
self._mqtt_callbacks.append((
|
||||
topic,
|
||||
partial(self._on_command_wrapper, worker_obj)
|
||||
))
|
||||
|
||||
if 'topic_subscription' in self._config:
|
||||
for (callback_name, options) in self._config['topic_subscription'].items():
|
||||
@@ -148,6 +152,6 @@ class WorkersManager:
|
||||
for command in self._config_commands:
|
||||
messages = command.execute()
|
||||
for msg in messages:
|
||||
msg.topic = "{}/{}".format(self._config['sensor_config'].get('topic', 'homeassistant'), msg.topic)
|
||||
#msg.topic = "{}/{}".format(self._config['sensor_config'].get('topic', 'homeassistant'), msg.topic)
|
||||
msg.retain = self._config['sensor_config'].get('retain', True)
|
||||
mqtt.publish(messages)
|
||||
mqtt.publish(messages)
|
||||
|
||||
Reference in New Issue
Block a user