HTTP API¶
This page documents the HTTP API exposed by the MAC server.
The OpenAPI spec is also available at /openapi.json on a running server,
with interactive documentation at /docs (Swagger UI) and /redocs (ReDoc).
- GET /api/¶
API index route.
Returns a placeholder message.
- Status Codes:
200 OK – Response body for GET /api/.
- DELETE /api/machine/locked_out/{machine_name}¶
Set or clear machine lockout state.
POST to lock out a machine (prevent all use). DELETE to unlock the machine.
- Parameters:
machine_name (string)
- Status Codes:
200 OK – Generic success response.
404 Not Found – Generic error response.
500 Internal Server Error – Generic error response.
- POST /api/machine/locked_out/{machine_name}¶
Set or clear machine lockout state.
POST to lock out a machine (prevent all use). DELETE to unlock the machine.
- Parameters:
machine_name (string)
- Status Codes:
200 OK – Generic success response.
404 Not Found – Generic error response.
500 Internal Server Error – Generic error response.
- DELETE /api/machine/oops/{machine_name}¶
Set or clear machine Oops state.
POST to set the machine into Oops (maintenance needed) state. DELETE to clear the Oops state.
- Parameters:
machine_name (string)
- Status Codes:
200 OK – Generic success response.
404 Not Found – Generic error response.
500 Internal Server Error – Generic error response.
- POST /api/machine/oops/{machine_name}¶
Set or clear machine Oops state.
POST to set the machine into Oops (maintenance needed) state. DELETE to clear the Oops state.
- Parameters:
machine_name (string)
- Status Codes:
200 OK – Generic success response.
404 Not Found – Generic error response.
500 Internal Server Error – Generic error response.
- POST /api/machine/update¶
API method to update machine state.
Accepts POSTed JSON containing the following key/value pairs:
machine_name(string) - name of the machine sending the updateoops(boolean) - whether the oops button is pressedrfid_value(string) - value of the RFID fob/card that is currentlypresent in the machine, or empty string if none present. Note that ESPHome strips leading zeroes from this, so inside this method it is left-padded with zeroes to a length of 10 characters.
uptime(float) - uptime of the ESP32 (MCU).wifi_signal_db(float) - WiFi signal strength in dBwifi_signal_percent(float) - WiFi signal strength in percentinternal_temperature_c(float) - internal temperature of the ESP32 in°C.
amps(float; optional) - amperage value from the current clampammeter, if present, or 0.0 otherwise.
- Status Codes:
200 OK – Response body for POST /api/machine/update (200).
404 Not Found – Generic error response.
500 Internal Server Error – Generic error response.
- POST /api/reload-users¶
Reload users configuration.
Hot-reloads users.json without requiring a server restart. Returns counts of removed, updated, and added users.
- Status Codes:
200 OK – Response body for POST /api/reload-users (200).
500 Internal Server Error – Generic error response.
- GET /metrics¶
API method to return Prometheus-compatible metrics.
Prometheus Metrics¶
GET /metrics
Returns Prometheus-compatible metrics in text/plain format. This endpoint
is not included in the OpenAPI spec as it does not return JSON.
See dm_mac.views.prometheus for details on the available metrics.