This directory contains practical examples of MQTT payloads for the Unified Namespace (UNS) architecture.
The pump_mqtt_publisher.py script demonstrates how to publish realistic MQTT payloads for an industrial pump using all schema types.
- Complete Schema Coverage: Demonstrates all 10 payload types
- Realistic Data: Generates realistic pump data with configurable variations
- Environment Configuration: Uses
.envfiles for secure configuration - Comprehensive Logging: Detailed console output for monitoring
-
Install Dependencies:
pip install -r requirements.txt
-
Configure Environment:
cp ../example.env .env # Edit .env with your MQTT broker settings -
Run the Example:
python pump_mqtt_publisher.py
All environment variables used by the script are defined in the ../example.env file. To configure your environment:
- Duplicate the example file:
cp ../example.env .env
- Edit
.envwith your MQTT broker settings, credentials, and any other options you wish to change.
Environment variables include:
MQTT_BROKER_HOST: MQTT broker addressMQTT_BROKER_PORT: MQTT broker portMQTT_USE_TLS: Enable TLS/SSL (true/false)MQTT_USE_AUTH: Enable authentication (true/false)MQTT_BROKER_USERNAME: Authentication usernameMQTT_BROKER_PASSWORD: Authentication passwordMQTT_CLIENT_ID: MQTT client IDMQTT_KEEPALIVE: Keepalive intervalMQTT_QOS: Quality of Service levelASSET_ID,ASSET_NAME,ASSET_DESCRIPTION: Pump asset configurationPUBLISH_INTERVAL: Seconds between publish cyclesSIMULATION_MODE: Enable random data variation (true/false)LOG_LEVEL: Logging level (e.g., INFO, DEBUG)
For a full list and descriptions, see the comments in ../example.env.
The script publishes to topics following the UNS structure:
abelara/plant1/utilities/water-system/pump-station/pump-101/{schemaType}
Example topics:
.../definition- Asset configuration.../state- Pump operational state.../edge/temperature- Real-time temperature readings.../measurement/bearing-temperature- Precision maintenance data.../count/runtime-hours- Accumulated runtime.../kpi/oee- Performance metrics.../alert- System alerts.../production- Production tracking
- Asset Definition - Pump configuration and metadata
- State - Operational states (Running, Stopped, Fault, etc.)
- Edge - Real-time sensor data (temperature, pressure, flow)
- Measurement - Precision maintenance measurements
- Count - Accumulated values (runtime, production, energy)
- KPI - Performance indicators (OEE, efficiency)
- Alert - System notifications and alarms
- Product - Product specifications
- Production - Production run tracking
To adapt this example for your own equipment:
- Modify the asset configuration variables
- Adjust the data generation functions for your specific sensors
- Update the topic structure to match your UNS hierarchy
- Customize the payload content for your use case
- Connection Issues: Check your MQTT broker settings in
.env - Authentication Errors: Verify username/password in
.env - TLS Issues: Set
MQTT_USE_TLS=truefor secure connections - Topic Errors: Ensure your broker supports the topic structure
For more information, see the main README.