Home / Documentation / ESPHome Setup
ESPHome Setup
Replace Tasmota with ESPHome for native Home Assistant integration and YAML-based configuration
Why ESPHome?
ESPHome is an alternative firmware that uses simple YAML configuration files instead of a web UI. It offers several advantages for Home Assistant users:
- Native API — direct communication with Home Assistant, no MQTT broker needed
- YAML-as-code — version control your configuration, reproduce setups instantly
- OTA updates — compile and flash wirelessly from the ESPHome dashboard
- Auto-discovery — devices appear in Home Assistant automatically
- Extensive sensor library — 800+ components supported out of the box
Flashing ESPHome
You can replace Tasmota with ESPHome via OTA (wireless) or serial (UART). OTA is recommended for convenience.
Option A: OTA via Tasmota (recommended)
- Compile your ESPHome YAML to produce a
.binfile (usetasmota32variant) - In Tasmota, navigate to Firmware Upgrade
- Upload the
esphome-astra.factory.binfile - Wait for the device to reboot — it will now run ESPHome
Option B: Serial via UART
- Connect a USB-to-UART adapter (3.3V) to TX, RX, GND, and 3V3 on the controller
- Hold the BOOT button while powering on to enter download mode
- Flash using
esptool.pyor the ESPHome dashboard
YAML Configuration — BR4A4AL
esphome:
name: astra-br4a4al
friendly_name: "ASTRA Controller"
esp32:
board: esp32-s3-devkitc-1
framework:
type: arduino
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: "ASTRA-Fallback"
password: "astra1234"
captive_portal:
logger:
api:
encryption:
key: !secret api_key
ota:
platform: esphome
password: !secret ota_password
i2c:
sda: GPIO21
scl: GPIO22
scan: true
switch:
- platform: gpio
name: "Relay 1"
pin: GPIO2
id: relay_1
- platform: gpio
name: "Relay 2"
pin: GPIO4
id: relay_2
- platform: gpio
name: "Relay 3"
pin: GPIO5
id: relay_3
- platform: gpio
name: "Relay 4"
pin: GPIO18
id: relay_4
binary_sensor:
- platform: gpio
name: "Input 1"
pin:
number: GPIO36
mode: INPUT
- platform: gpio
name: "Input 2"
pin:
number: GPIO39
mode: INPUT
- platform: gpio
name: "Input 3"
pin:
number: GPIO34
mode: INPUT
- platform: gpio
name: "Input 4"
pin:
number: GPIO35
mode: INPUT
status_led:
pin: GPIO12
GPIO Pin Mapping for ESPHome
| Function | GPIO | ESPHome Platform |
|---|---|---|
| Relay 1–4 | 2, 4, 5, 18 | switch.gpio |
| Input 1–4 | 36, 39, 34, 35 | binary_sensor.gpio |
| Input 5–8 (BR4G8) | 13, 14, 15, 16 | binary_sensor.gpio |
| I2C SDA / SCL | 21 / 22 | i2c |
| UART TX / RX | 1 / 3 | uart |
| Status LED | 12 | status_led |
Adding I2C Sensors (BME280 Example)
Connect a BME280 temperature/humidity/pressure sensor to the I2C header and add to your YAML:
sensor:
- platform: bme280_i2c
temperature:
name: "Panel Temperature"
humidity:
name: "Panel Humidity"
pressure:
name: "Barometric Pressure"
address: 0x76
update_interval: 30s
ESP-NOW Configuration
ESP-NOW enables direct device-to-device communication without a WiFi router, ideal for remote buildings or areas with poor coverage. In ESPHome, use the esp_now component:
esp_now:
peers:
- mac_address: "AA:BB:CC:DD:EE:FF"
# Send relay state to peer when input changes
automation:
- trigger:
platform: state
entity_id: binary_sensor.input_1
action:
- esp_now.send:
mac_address: "AA:BB:CC:DD:EE:FF"
data: [0x01]
Complete Example: 4 Relays + 4 Inputs + MQTT + HA
This configuration exposes all relays and inputs to Home Assistant via the native API, while also publishing state to an MQTT broker for third-party integrations:
mqtt:
broker: 192.168.1.100
port: 1883
username: !secret mqtt_user
password: !secret mqtt_password
discovery: true
topic_prefix: astra/br4a4al
# Link inputs to relays (local toggle)
binary_sensor:
- platform: gpio
name: "Input 1"
pin:
number: GPIO36
mode: INPUT
on_press:
then:
- switch.toggle: relay_1
- platform: gpio
name: "Input 2"
pin:
number: GPIO39
mode: INPUT
on_press:
then:
- switch.toggle: relay_2
Tip: When using both the native API and MQTT simultaneously, Home Assistant will prefer the native API connection. MQTT serves as a fallback or for third-party consumers.