django-mqtt
MQTT tools for Django project
Usage
- Add
"dmqtt"to yourINSTALLED_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
Release files for django-mqtt 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_mqtt-0.7.0.tar.gz | 5.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_mqtt-0.7.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.5 kB
Release files / django_mqtt-0.7.0.tar.gz
| Download URL | django_mqtt-0.7.0.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e7d70ebd284f09d4a4dbf6666fcb664c36bff2f523c96c9888ee7bd41c5b341a
|
|
BLAKE2b-256 checksum How to use checksums |
49c6041246e42da6300302e5a75ce7e0823150ea1e1ae52fee1bfe641eeb4c55
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"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}
|
Release files / django_mqtt-0.7.0-py3-none-any.whl
| Download URL | django_mqtt-0.7.0-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ead914b33872190a460fa42efe28020c15e13ee3fab3d3aea83e67713abf8568
|
|
BLAKE2b-256 checksum How to use checksums |
bc4b0bf69b0629f4727e02ddda5ac30fb9337d6ffdaac4f58be2fc0b1d25426a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"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}
|