Skip to Content

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)
  1. Compile your ESPHome YAML to produce a .bin file (use tasmota32 variant)
  2. In Tasmota, navigate to Firmware Upgrade
  3. Upload the esphome-astra.factory.bin file
  4. Wait for the device to reboot — it will now run ESPHome
Option B: Serial via UART
  1. Connect a USB-to-UART adapter (3.3V) to TX, RX, GND, and 3V3 on the controller
  2. Hold the BOOT button while powering on to enter download mode
  3. Flash using esptool.py or 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

FunctionGPIOESPHome Platform
Relay 1–42, 4, 5, 18switch.gpio
Input 1–436, 39, 34, 35binary_sensor.gpio
Input 5–8 (BR4G8)13, 14, 15, 16binary_sensor.gpio
I2C SDA / SCL21 / 22i2c
UART TX / RX1 / 3uart
Status LED12status_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.