No project description provided
Project description
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
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.4.3.tar.gz
(9.1 kB
view details)
Built Distribution
File details
Details for the file django-mqtt-0.4.3.tar.gz
.
File metadata
- Download URL: django-mqtt-0.4.3.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78e6cdbb12a310aae090de352753a189b2ead6a3227ca1ae557b1deaf62846b9 |
|
MD5 | 86905686ef09b733af35adac1ec1c295 |
|
BLAKE2b-256 | 5f9b85eb1ad77776d315f44a554555ee1b582ceb2e0acbc368b65902ee737945 |
File details
Details for the file django_mqtt-0.4.3-py3-none-any.whl
.
File metadata
- Download URL: django_mqtt-0.4.3-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d6aa0f5c9b837d80eed7035c6f6d0258afd70560a847def0e822f51350eae4a |
|
MD5 | 3facb7aabbfafa0955082469b4960bcf |
|
BLAKE2b-256 | c7243253b8cb94c1582c29c3363216cea02ad6f9003d2a40377dcfe683dd2f93 |