ESPHome and Home Assistant are developed by the same foundation, and the connection between them is one of the main reasons people choose ESPHome. Devices appear automatically, their sensors and switches become entities without any manual mapping, and the link is encrypted by default. This guide explains how that connection works, how to set it up properly, and what to do when a device shows as unavailable.
The native API in brief
ESPHome devices talk to Home Assistant over the native API, a compact binary protocol carried over TCP on port 6053. It is enabled by a single api: block in the device configuration. Home Assistant acts as the client: it opens a connection to each device, asks for the list of entities, and then receives state updates the moment they change.
This design differs from MQTT, where every device publishes to a central broker. With the native API there is no broker to install or maintain, and each device knows exactly which client is connected. If Home Assistant restarts, it simply reconnects to each device. If a device reboots, Home Assistant notices the dropped connection and reconnects when the device returns.
The API carries more than sensor values. It also handles:
- Entity metadata: names, units, device classes and icons, so Home Assistant knows a value is a temperature in °C or a power reading in watts.
- Commands: turning switches on, setting light colours, moving covers, pressing buttons.
- Actions defined in the device's YAML that Home Assistant can call with parameters.
- Logs, which Home Assistant can subscribe to for debugging.
- Bluetooth proxy traffic, when the device is configured to relay BLE advertisements and connections.
- Voice assistant audio, for ESP32 devices used as satellites.
Discovery: how Home Assistant finds devices
Every ESPHome device announces itself on the local network using mDNS (zeroconf), under the service name _esphomelib._tcp. Home Assistant listens for these announcements. When it sees a device it does not yet know, it shows a notification and lists the device under Settings → Devices & services as discovered.
Click Configure or Add and Home Assistant connects to the device. If the device uses an encryption key, Home Assistant asks for it, unless the Device Builder app running in the same Home Assistant instance has already supplied it. Once confirmed, the device and all its entities are added.
Discovery depends on mDNS reaching Home Assistant. On most home networks this works without any effort. It can fail when:
- Home Assistant runs in Docker without host networking.
- The device and Home Assistant are on different VLANs or subnets with no mDNS reflector.
- A mesh Wi-Fi system or access point filters multicast traffic between wireless clients and the wired network.
In those cases, add the device manually: open Settings → Devices & services → Add integration, search for ESPHome, and enter the device's hostname (for example garage-door.local) or its IP address. A DHCP reservation in your router keeps the address stable.
Encryption keys and why they matter
The native API supports transport encryption using the Noise protocol framework. With it enabled, every message between Home Assistant and the device is encrypted and authenticated with a pre-shared 32-byte key. Without it, anyone on the same network could connect to the device, read its sensors and control its outputs.
The Device Builder generates a random key for every new device:
api:
encryption:
key: "pTZB9jcD3k1fVQr2mBqYQm4c+n0Jd9zL1vC6kH2oXsE="
The key is base64-encoded. Home Assistant stores its copy in the integration entry. If you ever change the key in the YAML and install the new firmware, Home Assistant will lose the connection and show a repair notice asking for the new key. Paste it in and the device reconnects.
Older configurations sometimes use api: password: instead. That method is deprecated and offers no encryption. Replace it with an encryption key on any device that still uses it.
You can keep keys out of the configuration file by moving them to secrets.yaml:
api:
encryption:
key: !secret garage_api_key
How entities are named
Since 2023, ESPHome follows Home Assistant's entity naming model. Each device has a friendly_name, and each entity has a short name that describes only what it measures or controls:
esphome:
name: garage-door
friendly_name: Garage Door
sensor:
- platform: dallas_temp
name: "Temperature"
Home Assistant combines them and displays "Garage Door Temperature", with an entity ID of sensor.garage_door_temperature. Avoid repeating the device name in each entity name, or you will end up with "Garage Door Garage Door Temperature".
Setting name: to an empty value or omitting it on a single primary entity gives that entity the device's name alone, which suits simple devices like a smart plug whose main switch should be called just "Kettle Plug".
Other useful entity options:
device_classtells Home Assistant what kind of value this is, which controls icons, units and how history graphs are drawn.state_class: measurementenables long-term statistics, needed for energy dashboards and averages.entity_category: diagnosticmoves technical values such as Wi-Fi signal or uptime to a separate section on the device page.disabled_by_default: truecreates the entity but leaves it disabled until you choose to enable it.internal: truekeeps the entity on the device only; it is used in automations but never sent to Home Assistant.
Adding diagnostic entities
A few standard sensors make every device easier to look after:
sensor:
- platform: wifi_signal
name: "Wi-Fi Signal"
update_interval: 60s
- platform: uptime
name: "Uptime"
text_sensor:
- platform: version
name: "ESPHome Version"
button:
- platform: restart
name: "Restart"
These appear under the device's diagnostic section. A falling Wi-Fi signal often explains intermittent unavailability, and the uptime sensor reveals unexpected reboots.
Calling actions defined on the device
ESPHome devices can expose their own actions to Home Assistant. These appear as callable actions in automations and scripts, with typed parameters. For example, a device driving a buzzer could expose a tone action:
api:
encryption:
key: !secret buzzer_api_key
actions:
- action: play_tone
variables:
frequency: int
duration_ms: int
then:
- output.ledc.set_frequency:
id: buzzer
frequency: !lambda "return frequency;"
- output.set_level:
id: buzzer
level: 50%
- delay: !lambda "return duration_ms;"
- output.turn_off: buzzer
In Home Assistant this shows up as esphome.buzzer_node_play_tone, callable from any automation with the two parameters. Older configurations use the key services: and service: instead of actions: and action:; both refer to the same feature, and current releases use the newer names.
Letting the device call Home Assistant
The relationship works in both directions. A device can trigger Home Assistant actions directly:
binary_sensor:
- platform: gpio
pin:
number: GPIO14
mode: INPUT_PULLUP
inverted: true
name: "Doorbell"
on_press:
- homeassistant.action:
action: notify.mobile_app_phone
data:
message: "Someone is at the front door"
For security, Home Assistant blocks device-initiated actions by default. Enable them per device in the ESPHome integration's options under Allow the device to perform Home Assistant actions.
Devices can also read Home Assistant states with the homeassistant sensor platforms. A display in the hallway, for instance, can show the outdoor temperature reported by a weather integration:
sensor:
- platform: homeassistant
id: outside_temp
entity_id: sensor.outdoor_temperature
Turning an ESP32 into a Bluetooth proxy
Home Assistant supports many Bluetooth Low Energy devices: thermometers, plant sensors, locks and presence trackers. Their range is limited, so a single Bluetooth adapter rarely covers a whole house. Any ESP32 running ESPHome can extend that range:
esp32_ble_tracker:
scan_parameters:
active: true
bluetooth_proxy:
active: true
The device listens for BLE advertisements and forwards them to Home Assistant over the native API. With active: true it can also make connections on behalf of Home Assistant, which some devices need. Place a few proxies around the house, ideally on Ethernet-connected ESP32 boards or ones with a strong Wi-Fi signal, and Home Assistant combines their reports automatically.
Bluetooth and Wi-Fi share the ESP32's single radio, so a proxy should not also be running heavy workloads. Use the ESP-IDF framework for proxies; it handles the shared radio more efficiently.
Updating firmware from Home Assistant
When the Device Builder app is installed in Home Assistant, each ESPHome device gains an update entity. When a new ESPHome release is installed, the update entity shows that a newer firmware is available. Installing the update from Home Assistant asks the Device Builder to compile the device's configuration and push it over the air, exactly as if you had clicked Install in the dashboard.
This makes it easy to update many devices from one place. Still, read the release notes first: a breaking change in a component you use will cause that device's build to fail until the YAML is adjusted.
Native API or MQTT: choosing deliberately
ESPHome supports both the native API and MQTT, and it is worth understanding when each fits.
The native API is the better default when Home Assistant is your controller. Setup is automatic, the connection is encrypted with a per-device key, entities carry full metadata, and features such as Bluetooth proxying, voice satellites and firmware update entities only work over it. Latency is low because there is no broker in the middle.
MQTT makes sense when several systems need the same data. If Node-RED, a logging database and Home Assistant all consume a sensor's readings, publishing once to a broker is cleaner than giving each system its own connection. MQTT is also the natural choice when the controller is not Home Assistant at all.
The two can run side by side on one device, but doing so doubles the network traffic and the amount of configuration to maintain. Choose one as the primary path and add the other only when a specific need appears.
Working with the device page in Home Assistant
Each ESPHome device gets its own page under Settings → Devices & services → ESPHome. It groups entities into Controls, Sensors, Configuration and Diagnostic sections according to their entity categories. From this page you can:
- Rename the device or individual entities without touching the YAML. Home Assistant stores those overrides locally.
- Assign the device to an area, which makes it appear in that room's dashboard and voice commands.
- Enable entities that were created with
disabled_by_default: true. - Open the integration's options to allow Home Assistant actions or adjust other per-device settings.
- See the firmware version, the hardware model and a link back to the Device Builder.
Renaming in Home Assistant is convenient, but renaming in the YAML is more durable, because the name then travels with the configuration if you ever rebuild Home Assistant from scratch.
When a device shows as unavailable
An unavailable device means Home Assistant cannot keep the API connection open. Work through the causes in order.
- Is the device powered and running? Check its LED or connect by USB and look at the logs.
- Is it on Wi-Fi? The Device Builder's log view, or the Wi-Fi signal sensor's last value, shows whether it connected. Weak signals below about −80 dBm cause frequent drops.
- Can Home Assistant reach it? Ping the device's IP address from the Home Assistant host. Different subnets or client isolation on the access point will block the connection.
- Has the IP address changed? If you added the device by IP, a new DHCP lease breaks the link. Use the hostname or a DHCP reservation.
- Does the encryption key still match? A repair notice in Home Assistant means it needs the new key.
- Is the device rebooting? Look at the uptime sensor. Regular reboots usually point to power problems, memory exhaustion or a watchdog reset caused by a blocking automation.
A device that reboots on its own can also be the result of reboot_timeout, an option on the api component. By default, a device reboots if no client has connected for 15 minutes, on the theory that something is wrong. If you deliberately run a device without Home Assistant, set reboot_timeout: 0s.
Running ESPHome without Home Assistant
The native API is optional. Devices can also expose a built-in web interface with web_server:, publish to an MQTT broker with mqtt:, or simply run their own automations with no connection at all. This is useful for standalone projects such as a greenhouse controller, or when integrating with other platforms like Node-RED through MQTT.
If you remove the api: block, remember to remove anything that depends on it, such as homeassistant sensors and Home Assistant actions.
Frequently asked questions
Do I need the Device Builder app to use ESPHome devices in Home Assistant?
No. The ESPHome integration in Home Assistant is separate from the Device Builder. You can compile firmware anywhere, on a desktop, in Docker or with pip, and Home Assistant will still discover and control the devices. The app simply adds convenience features such as update entities and automatic key sharing.
How many ESPHome devices can Home Assistant handle?
Many households run dozens, and larger installations run well over a hundred. Each device holds one lightweight TCP connection. The practical limit is usually Wi-Fi capacity on your access points rather than Home Assistant itself.
Key takeaways
- ESPHome devices connect to Home Assistant over the native API on port 6053, with no broker required.
- Discovery uses mDNS; when it is blocked, add devices manually by hostname or IP.
- Always use an API encryption key, and keep it in
secrets.yaml. - Name entities with short descriptions and let
friendly_namesupply the device name. - ESP32 devices can act as Bluetooth proxies to extend Home Assistant's BLE coverage.
- Unavailable devices are almost always a power, Wi-Fi, network or key mismatch problem.


