Declarative IoT device management for Django
Project description
Django DeviceHub
Declarative IoT device management for Django. Define device types with Python classes, get auto-generated models, REST API, admin, MQTT integration, and realtime updates.
Quick Example
# devices.py - declare your device types
from django_devicehub import DeviceType, Reading, Command, reading_types
class WeatherStation(DeviceType):
class Meta:
protocol = "mqtt"
heartbeat_interval = 300
temperature = Reading(type=reading_types.FLOAT, unit="C", range=(-40, 80))
humidity = Reading(type=reading_types.FLOAT, unit="%", range=(0, 100))
rainfall = Reading(type=reading_types.FLOAT, unit="mm")
reboot = Command()
set_interval = Command(payload={"interval": int})
# models.py - one line generates 3 concrete Django models
from .devices import WeatherStation
WeatherStationDevice, WeatherStationReading, WeatherStationMessage = (
WeatherStation.create_models()
)
python manage.py makemigrations # generates migrations
python manage.py migrate # creates tables
python manage.py iot_listen # starts MQTT listener
python manage.py iot_simulate weatherstation --realistic # simulate devices
Features
- Declarative device types -- define readings, commands, and state fields as Python classes
- Concrete model generation --
create_models()produces real Django models withmakemigrations - MQTT 5.0 broker -- paho-mqtt with shared subscriptions, TLS, EMQX/Mosquitto compatible
- Auto-generated REST API -- DRF viewsets with device CRUD, readings, and provisioning
- Auto-generated admin -- Django admin registered automatically
- Broker authentication -- HTTP auth/ACL endpoints for EMQX and Mosquitto
- Device provisioning -- credential generation, bulk provisioning, API key management
- Realtime updates -- Django Channels WebSocket + SSE fallback +
iot.jsfrontend library - Pluggable storage -- Django ORM (default), TimescaleDB, InfluxDB 2.x
- Django signals --
device_data_received,device_status_changed,device_provisioned, etc. - Management commands --
iot_listen,iot_simulate,iot_provision
Installation
pip install django-devicehub # core
pip install django-devicehub[mqtt] # + MQTT support
pip install django-devicehub[drf] # + REST API
pip install django-devicehub[channels] # + WebSocket realtime
pip install django-devicehub[all] # everything
Add to INSTALLED_APPS:
INSTALLED_APPS = [
...
"django_devicehub",
"myapp",
]
Configure the broker:
DJANGO_DEVICEHUB = {
"BROKERS": {
"default": {
"ENGINE": "django_devicehub.brokers.mqtt.MQTTBroker",
"HOST": "localhost",
"PORT": 1883,
}
},
"TOPIC_PREFIX": "myproject",
}
Documentation
Full documentation at altius-academy-snc.github.io/django-devicehub.
License
MIT -- see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_devicehub-0.1.2.tar.gz.
File metadata
- Download URL: django_devicehub-0.1.2.tar.gz
- Upload date:
- Size: 52.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf359d9fc0aeef188e7cb0bd2f4c5eda49a8f8540036228416c9133c18a8449e
|
|
| MD5 |
64b9fb2ba7199633c3fe7f629b398509
|
|
| BLAKE2b-256 |
932e5440dea765b3b404f65bba17905a3da2bf3a0dbd0e8af49b713d7f51d98c
|
Provenance
The following attestation bundles were made for django_devicehub-0.1.2.tar.gz:
Publisher:
publish.yml on Altius-Academy-SNC/django-devicehub
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_devicehub-0.1.2.tar.gz -
Subject digest:
bf359d9fc0aeef188e7cb0bd2f4c5eda49a8f8540036228416c9133c18a8449e - Sigstore transparency entry: 1118873597
- Sigstore integration time:
-
Permalink:
Altius-Academy-SNC/django-devicehub@f09780f648d3803576950523f93d9fff033e436f -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/Altius-Academy-SNC
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f09780f648d3803576950523f93d9fff033e436f -
Trigger Event:
release
-
Statement type:
File details
Details for the file django_devicehub-0.1.2-py3-none-any.whl.
File metadata
- Download URL: django_devicehub-0.1.2-py3-none-any.whl
- Upload date:
- Size: 51.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ad2bf3a98469981961be860991fbc2c3052562e55937cd4888023676da406a0
|
|
| MD5 |
e6db376a59a0b684f50a31e70bd64608
|
|
| BLAKE2b-256 |
26115615110faf8e775ff8152623e76af8ceacb5c651ba3f6323f79ca6dd772a
|
Provenance
The following attestation bundles were made for django_devicehub-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on Altius-Academy-SNC/django-devicehub
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_devicehub-0.1.2-py3-none-any.whl -
Subject digest:
5ad2bf3a98469981961be860991fbc2c3052562e55937cd4888023676da406a0 - Sigstore transparency entry: 1118873599
- Sigstore integration time:
-
Permalink:
Altius-Academy-SNC/django-devicehub@f09780f648d3803576950523f93d9fff033e436f -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/Altius-Academy-SNC
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f09780f648d3803576950523f93d9fff033e436f -
Trigger Event:
release
-
Statement type: