Skip to main content

Netcat for MQTT

Project description

Overview

Netcat for MQTT

  • Free software: BSD 2-Clause License

Installation

This needs Python 3.6. At the command line:

pip3 install mqttcat

If your system does not provide python 3.6, a more comfortable way is to use the mqtttool Docker container. Please see the Github repo.

Documentation

Usage: mqttcat [OPTIONS] URL

  A MQTT Message filter inspired by netcat and other Unix tools.

  Publishes Messages from STDIN to a MQTT Topic

    -or-

  Subscribes to MQTT Topic and writes messages to STDOUT

  URL - Examples:

      mqtt://hostname/topic     tcp://hostname:1883/topic
      ws://hostname/topic

  Usage Examples:

      mqttcat --echo mqtt://localhost/%23 >/dev/null

      ... will subscribe to all topics ("%23" is urlencoded #), and echo
      them to STDERR for control

      echo "Heart ... beat" | mqttcat --echo --loop --wait=3.3
      mqtt://localhost/heartbeat-topic

      ... will publish "Heart ... beat" every 3.3 seconds to the topic
      "heartbeat-topic"

      mqttcat mqtt://source/ticktock | rq 'filter (a) => { a.payload="tock"
      }' | mqttcat mqtt://destination/tock

      ... subscribe to ticktock topic on host source, filter out the
      messages whose payload is tock,     and forward those to the tock
      topic (using the rq tool https://github.com/dflemstr/rq)

Options:
  --loglevel TEXT             Python loglevel, one of
                              DEBUG,INFO,WARNING,ERROR,CRITICAL
  --echo / --no-echo          Echo MQTT Messages to STDERR
  --source TEXT               File to read MQTT messages to be published (use
                              '-' for STDIN)
  --wait FLOAT                Wait time between publishing messages read from
                              --source in seconds (can be float)
  --loop / --no-loop          Loop message publishing (starting at beginning
                              of file after the end is reached
  --follow / --no-follow      Wait for additional in file after reaching the
                              end (like Unix 'tail -f')
  --destination TEXT          Append JSON-encoded MQTT messages to this file
                              (use '-' for STDOUT)
  --snapshot / --no-snapshot  Keep only the last JSON-encoded message in the
                              file specified with --destination
  --help                      Show this message and exit.

Authors

This module is part of the Smart Orchestra Project, co-financed by the Federal Ministery of Economics and Technology.

Changelog

0.1.0 (2018-03-20)

  • First release on PyPI.

0.1.1 (2018-04-13)

  • Flak8-compliant

0.1.2 (2018-04-14)

  • added –source and –destination options to the command line

  • source file can be followed (like ‘tail -f ‘) with –follow

  • destination file can contain only the last messaget (with –snapshot)

  • destinations abstracted in emittargets.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mqttcat-0.1.2.tar.gz (12.8 kB view details)

Uploaded Source

File details

Details for the file mqttcat-0.1.2.tar.gz.

File metadata

  • Download URL: mqttcat-0.1.2.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for mqttcat-0.1.2.tar.gz
Algorithm Hash digest
SHA256 17a63089c8c4c35db84f64d03995dbe3dd8625adfd357f231cecb4764c4b7b3c
MD5 19aa9f83c2f335a5b2b787d2f0fe48ce
BLAKE2b-256 b3d45002e326458ba930168337086a9fe665d8eca400e2ba82c00182abdb0f19

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page