MQTT integration plugin for NEMO tool usage events
Project description
NEMO_mqtt_bridge
Knowing a tool's status (interlock enabled or disabled) is critical in most labs using NEMO, but many setups only indicate this via NEMO itself or a simple LED. This project enables NEMO to send MQTT messages to displays on each tool, providing detailed, real-time status information such as current user, start time, and previous user.
The hardware, firmware, and broker code associated with this project can be found at: https://github.com/alexanderenrique/NEMO-Tool-Display
This is a Django plugin that publishes NEMO tool usage events to MQTT (tool enable/disable, tool saves). Uses PostgreSQL LISTEN/NOTIFY and a separate bridge process to keep broker connections out of Django.
Architecture
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────────┐ ┌─────────────┐
│ Django NEMO │───▶│ PostgreSQL │───▶│ PostgreSQL–MQTT │───▶│ MQTT Broker │
│ (signals) │ │ (event queue) │ │ Bridge (standalone) │ │ │
└─────────────────┘ └──────────────────┘ └─────────────────────┘ └─────────────┘
- Django: Signal handlers (Tool save, UsageEvent) insert into
MQTTEventQueueand usepg_notifyto wake the bridge. - Bridge: Separate process runs
python -m NEMO_mqtt_bridge.postgres_mqtt_bridge; it LISTENs for notifications, fetches events, and publishes to the MQTT broker with QoS 1. - Topics:
nemo/tools/{id}/enabled,nemo/tools/{id}/disabled
Configuration is stored in Django (e.g. /customization/mqtt/) and loaded by the bridge on each connection.
Installation
Prerequisites: Python 3.8+, Django 3.2+, NEMO-CE 4.0+, MQTT broker (e.g. Mosquitto), PostgreSQL (NEMO's database). The plugin uses the same PostgreSQL database as NEMO; no Redis required.
Simplified deployment: The plugin package is NEMO_mqtt_bridge. Add 'NEMO_mqtt_bridge' to INSTALLED_APPS, then run python manage.py setup_nemo_integration (use --write-urls to add the URL include to NEMO/urls.py) and python manage.py migrate NEMO_mqtt_bridge.
From PyPI (recommended)
pip install nemo-mqtt-bridge
cd /path/to/your/nemo-ce
# Add 'NEMO_mqtt_bridge' to INSTALLED_APPS in your settings (see Manual below).
python manage.py setup_nemo_integration
python manage.py migrate NEMO_mqtt_bridge
Local / testing: The command above only prints integration steps (no file changes). Add NEMO_mqtt_bridge to INSTALLED_APPS and any logging config yourself. Use --write-urls to add the MQTT URL include to NEMO/urls.py.
Production with GitLab/Ansible: If your config is in version control and deployed by GitLab or Ansible, run with --gitlab so no files are changed on the server; the command will print the snippets to add to your repo:
python manage.py setup_nemo_integration --gitlab
# Add the printed snippets to your repo (INSTALLED_APPS and URLs; configure logging as needed for your environment), commit, and deploy. Then on the server:
python manage.py migrate NEMO_mqtt_bridge
Manual
pip install nemo-mqtt-bridge- Add
'NEMO_mqtt_bridge'toINSTALLED_APPSin your settings. - (Optional) If you use Django's
LOGGINGsetting, add aNEMO_mqtt_bridgelogger with your preferred level and handlers (e.g. DEBUG in dev/test, INFO or WARNING in production). What and how you log is installation-dependent. - run
python manage.py setup_nemo_integrationto print integration steps, or addpath("mqtt/", include("NEMO_mqtt_bridge.urls"))toNEMO/urls.pyyourself. Use--write-urlsto have the command add the URL include. - Run
python manage.py migrate NEMO_mqtt_bridge.
After install
- Configure: Open
/customization/mqtt/in NEMO, set broker host/port (and auth if needed), enable the config. - Start NEMO (e.g.
python manage.py runserver). With the default AUTO mode, the plugin uses the PostgreSQL–MQTT bridge and a local Mosquitto broker for development.
Production: Use EXTERNAL mode so the plugin does not start or kill brokers: set PostgresMQTTBridge(auto_start=False) in NEMO_mqtt_bridge/apps.py (or configure the bridge to not auto-start Mosquitto). Then start the MQTT broker yourself, and run the bridge separately (e.g. python -m NEMO_mqtt_bridge.postgres_mqtt_bridge or as a systemd service).
- Monitoring: Event stream at
/mqtt/monitor/; CLI tools inNEMO_mqtt_bridge.monitoring(seesrc/NEMO_mqtt_bridge/monitoring/README.md). - HMAC: Optional payload signing
- License: MIT. Issues · Discussions
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 nemo_mqtt_bridge-2.0.0.tar.gz.
File metadata
- Download URL: nemo_mqtt_bridge-2.0.0.tar.gz
- Upload date:
- Size: 52.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a084653088048e853f0c3eb3f2147dfffc09c7b39b20a068846fe7ba7f43bda
|
|
| MD5 |
0bbd76006402a856768995a7785b91f3
|
|
| BLAKE2b-256 |
4e9af0f2d35de8bee30762a46562a002e3800aea87bd1dd912781e57bec409ff
|
File details
Details for the file nemo_mqtt_bridge-2.0.0-py3-none-any.whl.
File metadata
- Download URL: nemo_mqtt_bridge-2.0.0-py3-none-any.whl
- Upload date:
- Size: 49.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cacd13064706394be26fd4d41448458c97704fae90557c1b6ce6cdcd107e6f2a
|
|
| MD5 |
0d446a83ca94dcc64afaea2b6d66167c
|
|
| BLAKE2b-256 |
4a55512ae1b6011446869d842451d043be29a0f7d03dc68f32bea348d7510bb4
|