ESPHome is designed for deployment on trusted home or business networks — not hardened for hostile environments or direct internet exposure. Even within a trusted network, following the practices in this guide significantly reduces the risk of unauthorized access to your devices and the data they collect.Documentation 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.
Secrets Management
The single most impactful habit you can build is keeping all sensitive values — passwords, API keys, Wi-Fi credentials — out of your device configuration files and in a dedicatedsecrets.yaml file instead. This lets you share or publish your configuration YAML safely.
The secrets.yaml File
Create a secrets.yaml file in the same directory as your device configurations. It must be a flat key-to-scalar mapping:
!secret tag in any device file:
Per-Device Unique Credentials
Wi-Fi credentials are the only values that should be shared across devices. Every other secret must be unique per device so that a compromise of one device does not expose all others.| Credential | Shared across devices? |
|---|---|
wifi_ssid / wifi_password | ✅ Yes |
| API encryption key | ❌ No — unique per device |
| OTA password | ❌ No — unique per device |
| Web server credentials | ❌ No — unique per device |
| Fallback AP password | ❌ No — unique per device |
API Encryption
The native API is the primary channel between ESPHome devices and Home Assistant. Without encryption, anyone on your local network can read sensor data, control switches and lights, and execute services on your devices. Always enable API encryption:secrets.yaml under a unique name.
OTA Password Protection
Over-the-Air updates allow you to push firmware wirelessly without a physical USB connection. Without a password, anyone on your local network can replace your firmware with anything they choose.- Use a strong, randomly generated password (20+ characters).
- Store the password in
secrets.yaml. - Never reuse OTA passwords across devices.
- Rotate passwords periodically or immediately after a suspected compromise.
Wi-Fi Security
Minimum Authentication Mode
ESPHome allows you to enforce a minimum Wi-Fi security protocol. This prevents devices from accidentally associating with a rogue access point that advertises a weaker encryption mode.ESP32 Devices
The default
min_auth_mode is WPA2, allowing both WPA2 and WPA3 networks. Set min_auth_mode: WPA3 only if all your access points support WPA3.ESP8266 Devices
The default is
WPA, which permits insecure TKIP connections. Explicitly set min_auth_mode: WPA2 on all ESP8266 devices.Fallback AP Password
The Wi-Fi component creates a fallback access point if the device cannot connect to your network. This AP must always have a password:ap: block entirely to disable the fallback AP.
Prefer Ethernet Where Possible
For devices that support it, wired Ethernet eliminates Wi-Fi attack surfaces entirely (deauthentication attacks, jamming, rogue AP association). See the Ethernet component for supported hardware.Web Server
The optional web server component provides a browser-accessible dashboard and API for your device. If you enable it, always require authentication:Logger Security
AtDEBUG or VERBOSE log levels, ESPHome may log Wi-Fi passwords and other sensitive values. Keep your production devices at INFO or higher:
Network Segmentation
For most home users, keeping ESPHome devices and Home Assistant on the same network is the simplest and most reliable setup. ESPHome uses mDNS for device discovery, which does not cross VLAN boundaries by default. If you require VLAN isolation, the recommended approach is to give Home Assistant two network interfaces — one on the management VLAN and one on the IoT VLAN — so it can discover devices via mDNS without an unreliable mDNS reflector.Minimal Secure Configuration
The following template applies all of the above recommendations to a single device. Copy it, fill in the secrets, and adapt the board and components to your hardware.secrets.yaml entries:
Incident Response
If you suspect a device has been compromised:Isolate the device
Disconnect it from the network (pull the power or block it at the router/firewall) to prevent further communication.
Document what you observed
Note timestamps, unusual log entries, unexpected API connections, or sensor behavior that triggered the suspicion.
Rotate all credentials for that device
Generate new API encryption key, OTA password, web server credentials, and fallback AP password. Update
secrets.yaml.Re-flash via USB
Flash fresh firmware via a physical USB/serial connection — do not trust OTA if the device may be compromised.
Audit neighboring devices
Check logs on other devices on the same network for signs of lateral movement.