Install and configure ESPHome¶
If you want to add ESPHome in Home Assistant, then you need to go through this section to install and configure it.
If you don’t use it, you can skip this section and go directly to the next one: Log In.
ESPHome is the perfect solution for creating custom firmware for your ESP8266/ESP32 boards.
Here’s a very quick introduction to how ESPHome works: ESPHome is a tool which aims to make managing your ESP boards as simple as possible. It reads in a YAML configuration file (just like Home Assistant) and creates custom firmware which it installs on your ESP device. Devices or sensors added in ESPHome’s configuration will automatically show up in Home Assistant’s UI.
sudo pip3 install cryptography==2.8
Install ESPHome, you need to install Python and install the console script through pip3.
Python 3.7 or above is required to install ESPHome 1.18.0 or above.
sudo pip3 install esphome
Alternatively, there’s also a Docker image available for easy installation (the Docker hub image is available for AMD64, ARM and ARM64(AARCH64) right now; if you have another architecture, please install ESPHome through pip or use the Home Assistant add-on:
docker pull esphome/esphome
Open the ESPHome Dashboard.
You need to keep this command running while you are operating in the ESPHome dashboard.
esphome dashboard config/
Click on the “+” to start adding configurations.
Enter a name and the WiFi and password that you need to have your device connect to and then click NEXT.
Select the device type (ESP32 for example).
Once added, you will see them in the Dashboard of ESPHome.
When it is not the first time to add a device, click “+” on the main page, follow the prompts to enter the device name, WIFI and password, select the device type.
Click EDIT in the bottom right corner to go inside the
.yaml file, you will see the following default components.
esphome: Contains the name, platform, and board type that you set up.
logger: The logger component automatically logs all log messages through the serial port and through MQTT topics.
api: The ESPHome native API is used to communicate with clients directly, with a highly-optimized network protocol. Currently, only the ESPHome tool and Home Assistant use this native API.
ota: With the OTA (Over The Air) update component you can upload your firmware binaries to your node without having to use a USB cable for uploads.
wifi: This core ESPHome component sets up WiFi connections to access points for you. It needs to be in your configuration or otherwise ESPHome will fail in the config validation stage.
captive_portal: The captive portal component in ESPHome is a fallback mechanism for when connecting to the configured WiFi fails. After 1 minute of unsuccessful WiFi connection attempts, the ESP will start a WiFi hotspot (with the credentials from your configuration).
Now start to add other components. There are a lot of components in the ESPHome official website, including Sensor Components, Output Components, Light Components, etc., Here we take Binary Light in Light Components as an example.
Add the following code to the end of the
# Example configuration entry light: - platform: binary name: "Desk Lamp" output: light_output output: - id: light_output platform: gpio pin: GPIO16
.yamlfile to ESP32 board.
After editing, click INSTALL in the lower right corner to compile and install. There are 2 methods for you to choose: Wirelessly and USB Port. But for the first installation you need to connect the ESP32 board to the Raspberry Pi using USB and then choose the second installation method. At a later time you can install and compile via Wirelessly.
It takes about 10 minutes to download the dependencies during the first compilation, so please be patient.
After successful installation, if you connect an LED to GPIO16 in ESP32 board, you will see the LED is lit. Also please record this IP, you will need to fill in this IP when you add ESPHome to Home Assistant.
If there is no response when clicking INSTALL, please clear the browser cache and INSTALL again.
sudo rm -rf ~/.cache/chromium
ESPHome configuration is complete and you can now add it to Home Assistant.