esp32.diy

ESPHome Home Assistant: What It Is and How to Get Started

Nov 28, 2026 · 7 min read · Beginner

ESPHome Home Assistant: What It Is and How to Get Started
TL;DR ESPHome turns an ESP32 or ESP8266 into a Home Assistant device from a short YAML file: you declare the board, Wi-Fi, the Home Assistant API and your GPIO switches or sensors, and ESPHome generates and compiles the C++ firmware for you. You can run it from the Home Assistant web dashboard or from the command line with pip, then flash over USB or OTA.
What it isYAML-driven firmware generator that produces a main.cpp and compiles it for ESP boards
Home Assistant linkThe api: block in the YAML enables the native Home Assistant API
Boards seen in sourcesESP32 (esp32dev, ESP-IDF framework) and ESP8266 NodeMCU v3
CLI installpip3 install esphome inside a Python venv, then esphome run <file>.yaml
OTA updatesota: with platform: esphome in the config
Version in sourcesESPHome 2024.12.2 with min_version 2024.11.0 in the example config

What is ESPHome and how does it work with Home Assistant?

ESPHome is a tool that lets you describe an ESP32 or ESP8266 device in a YAML file instead of writing firmware by hand. From that file it generates a main.cpp, compiles it with the PlatformIO toolchain (the build logs in the sources show the xtensa-esp32-elf GCC 8.4.0 compiler being used) and flashes the result to the board. If you already have a working Arduino sketch, you can also port it into ESPHome as a custom component so that it appears in Home Assistant, which is exactly what one maker did with a Wi-Fi egg cooker.

The Home Assistant side is handled by a single api: line in the config. Once the board is on your Wi-Fi, Home Assistant discovers it and every switch, sensor or light you declared in YAML shows up as an entity. There is no separate MQTT broker or custom integration needed for the basic case.

Two workflows appear in the sources:

Workflow Where it runs When it suits you
Web dashboard Inside Home Assistant (e.g. on a Raspberry Pi) Simplest, but one user found compiling too slow on a Raspberry Pi 3B+
Command line Any PC with Python (Windows and Linux both shown) Faster builds, custom components, scripting

Both produce the same firmware, so you can start with the dashboard and move to the CLI later.

Wiring diagram of the IR-controlled TV lift control box that was retrofitted with an ESP8266 running ESPHome\2

Wiring diagram of the IR-controlled TV lift control box that was retrofitted with an ESP8266 running ESPHome

What does a basic ESP32 ESPHome config look like?

A real config from the sources controls a relay and an LED in a workshop. Trimmed to its core, it looks like this:

esphome:
  name: esphome-web-baa3a0
  friendly_name: Workshop
  area: workshop
  min_version: 2024.11.0

esp32:
  board: esp32dev
  framework:
    type: esp-idf

logger:
api:

ota:
- platform: esphome

wifi:
  ssid: <Hidden>
  password: <Hidden>
  manual_ip:
    static_ip: 192.168.1.102
    gateway: 192.168.1.1
    subnet: 255.255.255.0

switch:
  - platform: gpio
    name: "relay"
    pin: GPIO16
  - platform: gpio
    name: "led"
    pin: GPIO23

What each block does:

Block Purpose
esphome: Device name, friendly name shown in Home Assistant, area, and the minimum ESPHome version required
esp32: Target board (esp32dev here) and framework (esp-idf in this case)
logger: Serial/network logging so you can see what the board is doing
api: Enables the native Home Assistant API
ota: Allows over-the-air reflashing after the first USB flash
wifi: Credentials, optionally with a fixed IP, gateway and subnet
switch: Two GPIO outputs (GPIO16 and GPIO23) that become toggles in Home Assistant

The name_add_mac_suffix: false option in the original file stops ESPHome from appending the MAC address to the device name, which is handy when you want a predictable hostname. For an ESP8266 NodeMCU v3, the structure is the same; only the board section changes.

The TV lift control board with its two 20A relays and the DIP packages believed to be optocouplers\2

The TV lift control board with its two 20A relays and the DIP packages believed to be optocouplers

How do I install and flash ESPHome from the command line?

If the web compiler is sluggish on your Home Assistant host, install ESPHome on a desktop machine. The egg-cooker project shows the whole flow on Linux using a virtual environment:

python3 -m venv venv
source venv/bin/activate
pip3 install esphome
pip3 install tornado esptool
esphome run eggcooker.yaml

esphome run reads the YAML, generates the C++ source, pulls in any components it needs, compiles, and then uploads. On Windows the equivalent is the same command pointed at your file, for example esphome run .\workshop.yaml, which the Windows user ran with Python 3.11 and ESPHome 2024.12.2.

A few practical notes from the sources:

An ESP32 development board of the type targeted by the esp32dev ESPHome board setting\2

An ESP32 development board of the type targeted by the esp32dev ESPHome board setting Image: Edwiyanto, CC BY-SA 4.0, via Wikimedia Commons

What ESPHome projects can I build for Home Assistant?

The sources describe several real projects, from trivial to fairly involved:

Project Hardware ESPHome pieces used
Workshop relay and LED ESP32 (esp32dev) Two gpio switches, static IP, OTA
Wi-Fi egg cooker ESP32 Custom C++ component ported from an Arduino sketch, with a GUI library
TV lift retrofit ESP8266 NodeMCU v3 Two IO pins driving the existing control box
IR remote for climate, TV, fans, lights Any ESPHome board with an IR transmitter ESPHome user-defined service called by the SmartIR integration

The relay example is the classic first project: one YAML file, no code, and a toggle in Home Assistant within minutes. The egg cooker shows the other extreme, where ESPHome acts as the glue between your own C++ and Home Assistant.

The TV lift is an instructive middle ground. The lift lives in a bed footboard and is normally driven by an IR remote through a soundbar, which has to be powered on for roughly 12 seconds before the lift will move. The control box contains two 20A relays, one presumed for up and one for down, and is fed by a 29V adaptor rated between 2A and 4A. The owner, who already had Home Assistant scenes and automations running, had two options: replicate the three control wires coming from the soundbar, or add his own relays to switch power to the motor. The accepted advice was to go with the first option and reuse the board that was already designed for the job. The two 4-pin DIP packages on it were judged to be optocouplers, so the ESP likely needs nothing more than two IO pins wired to the control inputs. The suggested method was to probe the white and black wires (green being ground) with a multimeter while the lift moves; if the signals are simple on/off levels, that is enough, otherwise a logic analyser would be needed.

If you want more ideas, our esp32-home-assistant-projects guide and the esphome-devices collection list ready-made configs.

Espressif ESP-WROOM-32 Wi-Fi and Bluetooth module used on common ESP32 dev boards\2

Espressif ESP-WROOM-32 Wi-Fi and Bluetooth module used on common ESP32 dev boards Image: Brian Krent, CC BY-SA 4.0, via Wikimedia Commons

Can ESPHome send infrared commands from Home Assistant?

Yes. SmartIR is a custom Home Assistant integration that controls climate units, media players, fans and lights through infrared controllers, and ESPHome is one of its supported back ends via a user-defined service for the remote transmitter. The other supported controllers are Broadlink, the Xiaomi IR remote, LOOK.in Remote and plain MQTT publish, and the project ships with more than 120 climate device profiles, mostly contributed for Broadlink.

Installation is either manual or through HACS:

SmartIR checks for updates on each Home Assistant start and will refuse an update that is incompatible with your HA version. You can turn that off with:

smartir:
  check_updates: false

or track release candidates with update_branch: rc. The project README also asks that forks do not reuse the SmartIR name. For an ESPHome user this means an ESP32 with an IR LED can become the transmitter behind a proper Home Assistant climate or media-player entity rather than a bare "send code" button.

What are the common pitfalls with ESPHome and Home Assistant?

Compile suddenly fails while cloning a component. A Windows CLI user on ESPHome 2024.12.2 had a working ESP-IDF build for weeks, then every run died with voluptuous.error.Invalid: Cloning into '.esphome\idf_components\...' right after Cloning https://github.com/espressif/[email protected]. The traceback runs through git.clone_or_update in esphome/git.py. The resolution was unglamorous: reverting to the previous version of the config file made it build again, and the user never pinned down the offending line. Takeaway: keep your YAML in version control so you can diff and roll back, and suspect recent config edits before suspecting git itself.

Multiple definition errors in custom components. When porting the egg cooker, the linker complained about multiple definition of 'm_asFont', 'm_asPage', 'm_gui' and similar symbols, each reported as defined in both main.cpp.o and the custom eggslice.cpp.o, with the definitions located in a shared header (eggslice_GSLC.h). Because ESPHome generates main.cpp and includes your custom files, any variables defined in a header that both files include end up defined twice. Expect this when a GUI-builder header carries real definitions rather than declarations.

Slow web compiler on small hosts. The Raspberry Pi 3B+ struggled with in-browser builds, which is why the user moved to the CLI on a PC. Moving the build elsewhere does not change the firmware.

Retrofit wiring without measuring first. The TV lift thread shows the right order: identify ground and the control lines, measure them with a multimeter under real operation, and only then connect ESP pins. Also plan how the existing control box stays powered when the original controller (the soundbar) is off, a question the owner raised and that depends on the specific board.

Version drift. The example config sets min_version: 2024.11.0; if your installed ESPHome is older, the build will refuse to start. Keep the CLI and the dashboard on matching versions if you use both.

Frequently asked questions

Do I need to write code to use ESPHome with Home Assistant?

Not for basic devices. The workshop example drives a relay and an LED purely from YAML with gpio switches, an api block and ota. Custom C++ is only needed for things like the egg cooker, where an existing Arduino sketch was ported into a custom component.

Does ESPHome work with ESP8266 as well as ESP32?

Yes. The TV lift project used an ESP8266 NodeMCU v3 that was already programmed and connected to Home Assistant through ESPHome, while the workshop and egg cooker builds used ESP32 boards.

Can I give an ESPHome device a fixed IP address?

Yes. The wifi block accepts a manual_ip section with static_ip, gateway and subnet, as in the workshop config that pinned the ESP32 to 192.168.1.102.

How do I update an ESPHome device after the first flash?

Add an ota block with platform: esphome to the config. After the initial USB flash, esphome run can upload new firmware over Wi-Fi.

Why does my ESPHome build fail with a git cloning error?

In the documented case on ESPHome 2024.12.2, the clone of the esp-protocols mdns component failed and the fix was to restore an earlier version of the YAML config; the exact trigger was not identified.

Bottom line

ESPHome is the lowest-friction way to get an ESP32 or ESP8266 into Home Assistant: a short YAML file, one api: line, and your GPIO devices become entities. Start with a simple switch config, move to the command line if your Home Assistant host is slow at compiling, and keep your YAML under version control so a broken build can be rolled back quickly.

Sources

stackoverflow.comUnable to compile esphome using CLI. voluptuous.error.Invalid: Cloning into '.esphome\idf_components\7cd5e7e1'stackoverflow.comMultiple definitions error in custom ESPHome componentelectronics.stackexchange.comHow can I make this TV lift control box smart?github.comsmartHomeHub/SmartIR (GitHub README)

This guide summarises the public sources listed above in our own words. Check the original documentation before relying on exact figures.