Skip to content

A versatile little program for publishing and receiving images over MQTT.

License

Notifications You must be signed in to change notification settings

mqtt-tools/mqttshot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mqttshot

About

mqttshot is a versatile little program for publishing and receiving images over MQTT.

Features

  • Offer flexible image acquisition from different sources. You can currently choose from File, URL and STDIN.

  • Use base64 for encoding the image, it feels safer than "just binary" and can be used to encapsulate the image into a message container.

  • Use JSON as message container format, as you usually want to send more data along. In the current implementation, the message structure is very simple and not restricted by any schema:

    {
        "text": "The car is on fire!",
        "image": "/9j/4AAQSkZJRgAB ... JooA/9k=",
        "alert": true
    }
    

Background

Please consider this as a proposal about a simple convention of how to send basic messages containing images over MQTT. We will be happy if this of any interest for you and love to hear back from you.

This was built to support the creation of a new feature for mqttwarn, namely Add support for Pushover image attachments.

Synopsis

$ mqttshot --help

Usage:
    mqttshot --topic= --image= [--broker=] [--text=] [--alert]
    mqttshot --example [--broker= --topic= --text= --image= --alert]
    mqttshot --version
    mqttshot (-h | --help)

Examples:

  # Run example out of the box: Publish a message with an image
  # to a MQTT broker running on "localhost" to the topic "testdrive"
  mqttshot --example

  # Publish image acquired from filesystem with text from command line argument
  # to specified topic and also raise the "alert" flag
  mqttshot --topic='testdrive/home' --text='The house is on fire!' --image='/var/spool/house-on-fire.jpg' --alert

  # Publish image acquired from STDIN
  cat test.jpg | mqttshot --topic='testdrive/pipe' --image=-

  # Publish image acquired from HTTP URL
  mqttshot --topic='testdrive/url' --image='https://images.unsplash.com/photo-1503022932596-500eb8cca2d8?w=100&q=10'

Setup

Get source code:

git clone https://github.com/daq-tools/mqttshot
cd mqttshot

Create and activate a Python virtualenv:

virtualenv .venv27
source .venv27/bin/activate

Install mqttshot in development mode:

python setup.py develop

References

There are other discussions and projects about sending and receiving images over MQTT.

Projects

Tutorials

Discussions

About

A versatile little program for publishing and receiving images over MQTT.

Topics

Resources

License

Stars

Watchers

Forks

Languages