Skip to content

Commit

Permalink
no need for -t
Browse files Browse the repository at this point in the history
fixes #3
  • Loading branch information
vladak committed Feb 11, 2024
1 parent 1d98314 commit 4daf30f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Messages with missing `tags` or `annotation` will be ignored. The `annotation` k
- the `-H`, `-U` and MQTT broker hostname/port arguments are required
- the file can look like this (no double quotes):
```
ARGS=-U http://localhost:3000 -t "foo/bar" -c /srv/mq2anno/config.json -l debug localhost 1883
ARGS=-U http://localhost:3000 -c /srv/mq2anno/config.json -l debug localhost 1883
```
- setup the service (assumes the `pi` user)
```
Expand Down
16 changes: 1 addition & 15 deletions mq2anno.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,6 @@ def main():
topic_config = json.load(file_handle)
logger.debug(f"Got config: {topic_config}")

# Check that each specific topic has a payload template in the configuration.
# The contents of the template are not checked.
logger.debug(f"Checking configuration for topics {args.topic}")
for topic in args.topic:
if topic not in topic_config.keys():
raise FatalError(f"no configuration for topic '{topic}'")

client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2)
user_data = Userdata(topic_config, args.grafana_url, headers)
client.user_data_set(user_data)
Expand All @@ -172,7 +165,7 @@ def main():
except OSError as exc:
raise FatalError("MQTT connect error") from exc

for topic in args.topic:
for topic in topic_config.keys():
logger.info(f"Subscribing to topic {topic}")
client.subscribe(topic)

Expand Down Expand Up @@ -208,13 +201,6 @@ def handle_args():
required=True,
help="base URL for the Grafana server",
)
parser.add_argument(
"-t",
"--topic",
required=True,
action="append",
help="MQTT topic to subscribe to",
)
parser.add_argument(
"-c",
"--config",
Expand Down

0 comments on commit 4daf30f

Please sign in to comment.