Skip to main content

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.

PyPI version Python versions Django versions Tests License

Documentation | PyPI | Source

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 with makemigrations
  • 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.js frontend 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.

Release files for django-devicehub 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-devicehub 0.2.1
File Size Uploaded
django_devicehub-0.2.1.tar.gz 52.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-devicehub 0.2.1
File Interpreter ABI Platform
django_devicehub-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 104.7 kB

Release files / django_devicehub-0.2.1.tar.gz

Download URL django_devicehub-0.2.1.tar.gz
Size 52.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c78b3b924993f292551721f363c15a120f81e44273602f0eb170672664cc146a
BLAKE2b-256 checksum
How to use checksums
aa6d799b26654e946ef9afe428a351382183029b69114d891eb7cd31eac6e6db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 18, 2026.

Transparency log

Release files / django_devicehub-0.2.1-py3-none-any.whl

Download URL django_devicehub-0.2.1-py3-none-any.whl
Size 51.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a8b8a6ce11cbe4fcceed7eb0719169b51d762f855499215885b2888c420e9de3
BLAKE2b-256 checksum
How to use checksums
fd99955e6f2215646a815b20b3e1137f7bf0ba45af6a3d9e562b4191b443217c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 18, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.1.2

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page