Compile ESPHome firmware
esphome_compile_deviceBuild ESPHome firmware for a device to prepare it for upload. Runs a full compile and returns exit code plus build log.
Instructions
Compile ESPHome firmware for a device via the dashboard's /compile WebSocket route.
Blocks until the compile process exits (~60-180s). Compatible with the
"ESPHome Device Builder" add-on (esphome/device-builder): /compile
keeps the same spawn wire protocol as the old dashboard, now backed by
its firmware job queue. A first build for a platform fetches PlatformIO
packages from the internet before compiling. only_generate=True is
rejected outright (see Errors) — Device Builder ignores that field and
always runs a full build (ADR-0004 D4); it stays in the signature only
for input-shape compatibility.
Use when: building firmware before esphome_upload_device.
Not for: checking config validity only — use esphome_validate_config,
which is faster and skips package downloads.
Returns: {"device", "action": "compile", "exit_code", "success", "log_tail", "log_lines"}.
Errors: {"error": "esphome_unsupported_option", ...} for
only_generate=True (no I/O); {"error": "Invalid device name: ..."}
for a path-escaping or blocked (e.g. 'secrets') name; otherwise one of
esphome_dashboard.DashboardError's stable codes —
esphome_unreachable/esphome_auth_required add diagnosis (see
esphome_ping_dashboard); timeout adds log_tail/log_lines/
job_may_still_be_running (always True — do not retry, check
esphome_get_addon_logs); esphome_command_failed adds
dashboard_error_code/details.
Limits: blocks up to timeout seconds; log_lines truncates the log.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Device name, with or without the '.yaml' suffix, e.g. 'kitchen_sensor'. | |
| timeout | No | Maximum seconds to wait for the compile process to finish, e.g. 180. | |
| log_lines | No | Number of trailing build-log lines to return, e.g. 200. | |
| only_generate | No | If true, only generate the C++ source and skip the platform build. Set false for a full firmware build. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||