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 supports live video feeds from machines using a Raspberry Pi camera and Cloudflare Tunnel. The Raspberry Pi streams video locally over HTTP, and a helper script publishes the public tunnel URL to ECE-BOT automatically at boot. Operators and admins can then view the live feed directly from the machine monitoring dashboard.

How it works

1

Raspberry Pi runs the camera stream

The Raspberry Pi runs a local camera stream server (for example, mjpg-streamer or picamera2) that exposes a video feed at http://localhost:8080/stream. This address is only accessible on the Raspberry Pi itself.
2

Cloudflare Tunnel creates a public URL

cloudflared runs on the Raspberry Pi and creates an outbound tunnel to Cloudflare’s edge network. This assigns a public trycloudflare.com URL to the local stream — no port forwarding or static IP required.The tunnel URL changes every time the Raspberry Pi reboots, which is why ECE-BOT stores it in the database rather than relying on a hard-coded value.
3

publish_cloudflare_live_url.py registers the URL

The publish_cloudflare_live_url.py script runs on the Raspberry Pi after the tunnel starts. It automatically detects the current trycloudflare.com URL and sends it to ECE-BOT:
POST /api/machine-live/<machine_id>/url
X-Live-Update-Token: <MACHINE_LIVE_UPDATE_TOKEN>
Content-Type: application/json

{
  "stream_url": "https://example.trycloudflare.com/stream",
  "source": "raspberry_pi"
}
The machine_id in the URL identifies which machine the stream belongs to (melfa, plc, or cnc).
The endpoint requires the X-Live-Update-Token header to match the MACHINE_LIVE_UPDATE_TOKEN environment variable configured in ECE-BOT. This prevents unauthorized URL updates.
4

Operators view the live feed

Once the URL is registered, operators and admins can open the live feed from the machine monitoring dashboard. ECE-BOT fetches the stream URL and displays it in the dashboard’s video panel.

URL storage and priority

The stream URL for each machine is stored in PostgreSQL. When ECE-BOT looks up the stream URL for a machine, it uses the following priority order:
  1. Database-stored URL — the most recently published URL from POST /api/machine-live/<machine_id>/url. This takes priority over all other sources.
  2. Static environment variable — a fallback URL set at deploy time.

Static environment variables

If you do not use the Raspberry Pi publishing script, you can configure static stream URLs using environment variables:
VariableMachine
MELFA_LIVE_STREAM_URLMELFA robot
PLC_LIVE_STREAM_URLPLC machine
CNC_LIVE_STREAM_URLCNC machine
Static environment variables are useful for testing with a fixed stream URL or for machines that use a stable, non-tunnelled endpoint. Once a URL is published to the database, it overrides the environment variable until the database entry is cleared.

Access control

Only users with the operator or admin role can view live video feeds. Requests from user-role accounts receive a 403 Forbidden response.

API reference

# Get the configured stream URL for a machine
GET /api/machine-live/<machine_id>
Authorization: Bearer <token>
# Publish a new stream URL (called by the Raspberry Pi script)
POST /api/machine-live/<machine_id>/url
X-Live-Update-Token: <MACHINE_LIVE_UPDATE_TOKEN>
Content-Type: application/json

{
  "stream_url": "https://example.trycloudflare.com/stream",
  "source": "raspberry_pi"
}
Valid machine_id values: melfa, plc, cnc.
The POST /api/machine-live/<machine_id>/url endpoint does not require a user JWT — it uses the X-Live-Update-Token header instead. Keep MACHINE_LIVE_UPDATE_TOKEN secret and rotate it if it is ever exposed.

Build docs developers (and LLMs) love