TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/esphome/esphome.io/llms.txt
Use this file to discover all available pages before exploring further.
esphome: block is the mandatory top-level section of every ESPHome YAML configuration. It tells ESPHome the identity of your device — its network name, human-readable label, and area in Home Assistant — as well as advanced build-time settings such as custom C++ includes, extra libraries, PlatformIO overrides, and project metadata for creator workflows. Every other component in your config depends on this block being present and correctly filled out.
Minimal Example
Configuration Variables
The unique network hostname of the device. May only contain lowercase letters, digits, and hyphens. Maximum 24 characters when
name_add_mac_suffix is true, or 31 characters when it is false. This name is used for mDNS, OTA uploads, and the ESPHome dashboard.A human-readable display name sent to Home Assistant. Used as the integration and device name, and prefixed to entity names where needed. Strongly recommended for a polished Home Assistant experience.
Assigns the device to a Home Assistant area/zone. Accepts either a simple string (
"Living Room") or a structured mapping with id and name keys for use with sub-devices.Freeform text displayed in the ESPHome dashboard UI. Has no effect on the compiled firmware.
When
true, appends the last 3 bytes of the device MAC address to the name as -aabbcc. Useful for flashing multiple identical devices from a single firmware binary. Defaults to false.The minimum ESPHome version required to compile this configuration. Produces a friendly error message if an older version is used. Example:
2025.11.0.Embeds creator project metadata into the firmware (exposed via logger, mDNS, and native API device info). The name must use the format
author_name.project_name.- name (Required, string): Project name in
author.projectformat. - version (Required, string): Semantic version string.
- on_update (Optional, Automation): Triggered when firmware version changes between boots.
Override the directory where ESPHome stores the PlatformIO build files. Defaults to
.esphome/build/<NODE>. The official Docker image uses /build when that volume is mounted.Additional key-value pairs injected into the
[env] section of the generated platformio.ini. See the PlatformIO documentation for available options.Environment variables available during the build process. Useful for passing configuration to build scripts or PlatformIO environments. Not available at device runtime.
C/C++ files or directories to copy into the generated PlatformIO
src/ folder. Header files (.h, .hpp) are also #included in main.cpp. Paths are relative to the YAML file location.Same as
includes but wraps all files in extern "C" {} for C linkage compatibility.PlatformIO library dependencies to add to the project. Accepts the same syntax as PlatformIO’s
lib_deps. Use <name>=<source> to override a library version pulled in by an ESPHome component.Maximum number of simultaneous compile processes. Defaults to the number of CPU cores available (also the maximum).
Additional named areas for use by sub-devices. Each entry requires
id (string) and name (string).Sub-devices that group entities into separate logical devices in Home Assistant. Each entry requires
id (string) and name (string), with an optional area_id referencing an entry in areas.Automation Triggers
Triggered when the device starts. Use the
priority sub-key (float) to control execution order. Higher priority = earlier execution. Key priorities: 800 hardware init, 600 sensors, 250 WiFi, 200 network connections, -100 everything ready.Triggered just before the device shuts down (caused by WiFi/MQTT failures, OTA updates, or deep sleep). Shutdown order is the reverse of boot priority. Not all components are guaranteed to be connected.
Triggered on every main loop iteration (approximately every 16 ms).
Advanced Example
Preferences Component
Thepreferences: top-level key controls how frequently persistent state (light states, globals, etc.) is written to flash memory.
How often buffered state changes are flushed to flash. Defaults to
1min. Set to never to disable, or 0s to write immediately (increases flash wear). For ESP8266, restore_from_flash: true must also be set on the esp8266: component.Sub-Devices and Areas Example
When renaming a device, set
wifi.use_address to the old hostname during the transition, then remove it after a successful OTA upload. This prevents losing network access mid-rename.