Skip to content

MQTT_TOPIC comma separated #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ The list of parameters are:
* `MQTT_IGNORED_TOPICS`: Comma-separated lists of topics to ignore. Accepts wildcards. (default: None)
* `MQTT_ADDRESS`: IP or hostname of MQTT broker (default: 127.0.0.1)
* `MQTT_PORT`: TCP port of MQTT broker (default: 1883)
* `MQTT_TOPIC`: Topic path to subscribe to (default: #)
* `MQTT_TOPIC`: Comma-separated lists of topics to subscribe to (default: #)
* `MQTT_KEEPALIVE`: Keep alive interval to maintain connection with MQTT broker (default: 60)
* `MQTT_USERNAME`: Username which should be used to authenticate against the MQTT broker (default: None)
* `MQTT_PASSWORD`: Password which should be used to authenticate against the MQTT broker (default: None)
Expand Down
5 changes: 3 additions & 2 deletions mqtt_exporter/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ def subscribe(client, _, __, reason_code, properties):

client.user_data_set(user_data)

LOG.info('subscribing to "%s"', settings.TOPIC)
client.subscribe(settings.TOPIC)
for s in settings.TOPIC.split(","):
LOG.info('subscribing to "%s"', s)
client.subscribe(s)
if reason_code != mqtt.CONNACK_ACCEPTED:
LOG.error("MQTT %s", mqtt.connack_string(reason_code))

Expand Down