1.0.2 • Published 6 years ago

@autocodingsystems/mqtt-stdin-publish v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

Publish data from std in to an MQTT topic

Quickstart

cat to-publish.txt | npx @autocodingsystems/mqtt-stdin-publish -h <host> -t <topic>

Description

This is a tiny commandlet that reads in data from the std-in, one line at a time, and pushes that data to an MQTT topic. It's really meant for quick tests on windows as no authentication is supported on the MQTT broker (except what can be done through the url).

It is roughly equivalent to the following bash script:

cat to-publish.txt | xargs -d '\n' -i mosquitto_pub -h broker -t topic -m {}

It's a little more efficient as the connection is only opened once and kept open.

It doesn't support all the options of mosquitto_pub.

Commandline Options

    --url: The url of an MQTT broker to connect to
    --host, -h: The hostname of an MQTT broker to connect to (if not using url)
    --port, -p: The port of an MQTT broker to connect to )(if not using url)
    --topic, -t: The topic to publish messages to