Skip to content

Commit d3a92d1

Browse files
authored
Merge pull request #93 from kiemlicz/master
MQTT_TOPIC comma separated
2 parents 967b412 + 4360715 commit d3a92d1

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ The list of parameters are:
114114
* `MQTT_IGNORED_TOPICS`: Comma-separated lists of topics to ignore. Accepts wildcards. (default: None)
115115
* `MQTT_ADDRESS`: IP or hostname of MQTT broker (default: 127.0.0.1)
116116
* `MQTT_PORT`: TCP port of MQTT broker (default: 1883)
117-
* `MQTT_TOPIC`: Topic path to subscribe to (default: #)
117+
* `MQTT_TOPIC`: Comma-separated lists of topics to subscribe to (default: #)
118118
* `MQTT_KEEPALIVE`: Keep alive interval to maintain connection with MQTT broker (default: 60)
119119
* `MQTT_USERNAME`: Username which should be used to authenticate against the MQTT broker (default: None)
120120
* `MQTT_PASSWORD`: Password which should be used to authenticate against the MQTT broker (default: None)

mqtt_exporter/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ def subscribe(client, _, __, reason_code, properties):
7575

7676
client.user_data_set(user_data)
7777

78-
LOG.info('subscribing to "%s"', settings.TOPIC)
79-
client.subscribe(settings.TOPIC)
78+
for s in settings.TOPIC.split(","):
79+
LOG.info('subscribing to "%s"', s)
80+
client.subscribe(s)
8081
if reason_code != mqtt.CONNACK_ACCEPTED:
8182
LOG.error("MQTT %s", mqtt.connack_string(reason_code))
8283

0 commit comments

Comments
 (0)