Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Kr-Yogsa/ECE-BOT/llms.txt

Use this file to discover all available pages before exploring further.

ECE-BOT includes a machine monitoring system that continuously ingests sensor telemetry from connected hardware over MQTT and stores every reading in PostgreSQL. Operators and admins can view the latest readings, aggregated summaries, and trend charts for each machine from the dashboard. Access is restricted to users with the operator or admin role.

MQTT ingestion

A standalone MQTT worker subscribes to sensor topics and persists each message to the database as it arrives. The worker runs separately from the Flask app and is configured entirely through environment variables. Default topic: factory/machine/+/telemetry The + wildcard matches any machine ID (for example, factory/machine/cnc/telemetry). You can override this with the MQTT_TOPIC environment variable.

Expected payload

The MQTT worker accepts JSON payloads with the following structure:
{
  "machine_id": "cnc",
  "temperature": 29.4,
  "humidity": 61.0,
  "vibration": 0.0314,
  "timestamp": "2026-05-05T10:30:00Z"
}
FieldTypeRequiredDescription
machine_idstringRecommendedMachine identifier (melfa, plc, or cnc). If omitted, ECE-BOT falls back to the second-to-last segment of the MQTT topic.
temperaturenumberNoTemperature in degrees Celsius.
humiditynumberNoRelative humidity as a percentage.
vibrationnumberNoVibration magnitude.
timestampstringNoISO 8601 timestamp. Defaults to server time if omitted or invalid.
Timestamps before 2025 (for example, ESP8266 uptime-based 1970-01-01 placeholders) are discarded and replaced with the server’s current UTC time.

Machine IDs

Machine IDs in telemetry payloads correspond directly to the hardware assistant IDs used throughout ECE-BOT:
Machine IDHardware
melfaMitsubishi MELFA robot
plcProgrammable logic controller
cncCNC machine

Machine online and offline status

A machine is considered online if its most recent telemetry reading arrived within the last MACHINE_OFFLINE_AFTER_SECONDS seconds. The default is 15 seconds. If no reading arrives within that window, the machine status switches to offline. You can tune this threshold by setting MACHINE_OFFLINE_AFTER_SECONDS in your environment:
MACHINE_OFFLINE_AFTER_SECONDS=30
Setting this value too high will make machines appear online long after they stop sending data. Keep the value close to your sensor’s expected publish interval.

Dashboard

The dashboard endpoint returns everything the frontend needs in a single request: the latest reading, per-window summaries, and a short trend series for charts.

Latest reading

The most recent row stored for the machine, including temperature, humidity, vibration, and the recorded_at timestamp.

Summaries

Average temperature, humidity, and vibration computed over multiple time windows (for example, last 5 minutes, last hour). This lets operators spot gradual drift without scrolling through raw history.

Trend chart

A short series of recent readings suitable for rendering a sparkline or line chart. The series is ordered chronologically and sized to fit the dashboard layout without overloading the browser.
# Fetch the full dashboard payload
GET /api/machine-stats/<machine_id>/dashboard
Authorization: Bearer <token>
Valid machine_id values: melfa, plc, cnc.

Reading history

The history endpoint returns a paginated list of raw telemetry readings for export, analysis, or custom charts.
GET /api/machine-stats/<machine_id>/history?limit=100
Authorization: Bearer <token>
ParameterDefaultMaximumDescription
limit1001000Number of readings to return, newest first.

API endpoints

# Latest reading and online status
GET /api/machine-stats/<machine_id>
Authorization: Bearer <token>
# Dashboard: latest + summaries + trend
GET /api/machine-stats/<machine_id>/dashboard
Authorization: Bearer <token>
# Raw reading history
GET /api/machine-stats/<machine_id>/history?limit=100
Authorization: Bearer <token>
All machine monitoring endpoints require an operator or admin role. Requests from accounts with the user role receive a 403 Forbidden response.

Build docs developers (and LLMs) love