Skip to main content

mqtt_decorator is a decorator module which converts mqtt subscriptions and messages to a [Flask](https://flask.palletsprojects.com/en/1.1.x/) like api.

Project description

mqtt_decorator

autopep8 pylint pytest

mqtt_decorator is a decorator module which converts mqtt subscriptions and messages to a Flask like api.

Installing

Demo

from mqtt_decorator import MqttDecorator
import paho.mqtt.client as mqtt

# you can specify all 
# paho mqtt client options
# such as websocket connections or
# tls connections
mqttc = mqtt.Client(clean_session=True)
app = MqttDecorator(mqttc)

@app.route("$SYS/<broker>/<type>")
def broker_url_params(msg, broker, type):
    print("---broker_url_params", msg.topic, msg.payload)
    print("--broker", broker)
    print("--type", type)

@app.route("$SYS/broker/version")
def version(msg):
    print("---version", msg.topic, msg.payload)

@app.route("$SYS/broker/uptime")
def uptime(msg):
    print("---uptime", msg.topic, msg.payload)


if __name__ == "__main__":
    app.run( "mqtt.eclipse.org", 1883 )

Development

In this repo issue based development is active. For any problems or new enhancements please open a issue.

Create virtual environment (It should be done only for first installation)

conda create -n py38 python=3.8

Activate virtual environment

conda activate py38

Install this package

pip install -e .

Autopep8 is used for formatting.

autopep8 -r -i mqtt_decorator test

Pylint is used for linting.

pylint mqtt_decorator

Docs

for the first time

sphinx-apidoc -F mqtt_decorator -o docs/source

just update the auto docs

sphinx-apidoc -f mqtt_decorator -o docs/source

Deployment

The following 2 commands are required to deploy over pypi.

python setup.py sdist bdist_wheel
twine upload --repository-url https://upload.pypi.org/legacy/ dist/*

Licence

GPL

Acknowledges

This package is developed using

  • Python <3
  • Paho-Mqtt Heavily inspired from
  • Flask

Contributors

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

mqtt_decorator-0.1.3.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

mqtt_decorator-0.1.3-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file mqtt_decorator-0.1.3.tar.gz.

File metadata

  • Download URL: mqtt_decorator-0.1.3.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for mqtt_decorator-0.1.3.tar.gz
Algorithm Hash digest
SHA256 1663bae0430af5903c52d8ad0cb1a156b0f3b672ca6fd3e4f6a13db617521d9f
MD5 09de8fdec53ee4852cfe2c0e65ffcd17
BLAKE2b-256 2b93867ab202bde8ec98d4d8f2d45e61346cf398848b492bf82ffa4ff306a022

See more details on using hashes here.

File details

Details for the file mqtt_decorator-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: mqtt_decorator-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for mqtt_decorator-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7a126325fdcbf5217db9d138aab9b30bc57c6f3a7b94248451bc3ca61ae2c9f4
MD5 5a1798c698196622c434d7f21601e7fa
BLAKE2b-256 81fbf427901331f4d92ae7e265fc79d244c85d0cfb7fc56f1a873a8f87f98bb7

See more details on using hashes here.

Supported by

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