Skip to main content

No project description provided

Project description

django-mqtt

MQTT tools for Django project

PyPI

Usage

  • Add "dmqtt" to your INSTALLED_APPS
  • Add MQTT_HOST, MQTT_USER, MQTT_PASS, MQTT_PORT
  • Run with python manage.py mqtt
from dmqtt.signals import connect, regex, topic
from django.dispatch import receiver

@receiver(connect)
def on_connect(sender, **kwargs):
    sender.subscribe("#")

@topic("some/mqtt/topic")
def simple_topic(sender, topic, data, **kwargs):
    print(topic)
    print(data)

@regex("^some/(?P<username>[^/]+)/(?P<device>[^/]+)$")
def regex_topic(match, data, **kwargs):
    device = match.groupdict()
    print(device['username'], device['device])
    print(data)

Authentication

mosquitto-go-auth

Used with https://github.com/iegomez/mosquitto-go-auth

# From example project urls
from django.contrib import admin
from django.urls import include, path

urlpatterns = [
    path("mosquitto/", include("dmqtt.mosquitto")),
    path("account/", include(("django.contrib.auth.urls", "auth"), namespace="auth")),
    path("admin/", admin.site.urls),
]
# mosquitto configuration
# https://github.com/iegomez/mosquitto-go-auth#http
auth_plugin /mosquitto/go-auth.so
auth_opt_backends http
auth_opt_check_prefix false

auth_opt_http_host example.com
auth_opt_http_getuser_uri /mosquitto/getuser
auth_opt_http_aclcheck_uri /mosquitto/aclcheck

# If using https
auth_opt_http_port 443
auth_opt_http_with_tls true

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

django_mqtt-0.5.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_mqtt-0.5.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file django_mqtt-0.5.0.tar.gz.

File metadata

  • Download URL: django_mqtt-0.5.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for django_mqtt-0.5.0.tar.gz
Algorithm Hash digest
SHA256 745aa9b0994f57a64df4f920e2681c854fcaa2c8f3e72442acbe2457f4300155
MD5 80aac904f803d8690492ccc53a7c47b6
BLAKE2b-256 fc6c53564bdb3e94e9830c7d8e8c739d929c52dc8af3e2df213d0ce0a804c49f

See more details on using hashes here.

File details

Details for the file django_mqtt-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: django_mqtt-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for django_mqtt-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 41d5a7bef1b69ed525e038ae51a292d44e74939b261f5a467bd9ca770696eeb5
MD5 b0deef05b292d8ee2805ccd407a7b827
BLAKE2b-256 07b7cf6238d40b28ea89e1fc63a3103e330d6354fdb720a1441f6586ce552de7

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