Skip to the content.

Configuration Reference

ESPHome Swift uses YAML files to define device configuration. This reference covers all available configuration options.

Core Configuration

esphome_swift

The core configuration section defines basic device information.

esphome_swift:
  name: device_name           # Required: Unique device identifier
  friendly_name: "My Device"  # Optional: Human-readable name
  comment: "Living room"      # Optional: Device description
  area_id: "living_room"      # Optional: Home Assistant area

Requirements:

esp32

Platform-specific configuration for ESP32 boards.

esp32:
  board: esp32-c6-devkitc-1  # Required: Board identifier
  framework:
    type: esp-idf            # Required: Framework type
    version: "5.3"           # Optional: Framework version
  flash_size: "4MB"          # Optional: Flash memory size

Supported Boards:

Framework Types:

Network Configuration

wifi

Configure WiFi connectivity.

wifi:
  ssid: "MyNetwork"          # Required: Network name
  password: "MyPassword"     # Required: Network password
  
  # Optional: Manual IP configuration
  manual_ip:
    static_ip: 192.168.1.100
    gateway: 192.168.1.1
    subnet: 255.255.255.0
    dns1: 8.8.8.8
    dns2: 8.8.4.4
  
  # Optional: Fallback access point
  ap:
    ssid: "Device Fallback"
    password: "12345678"     # Min 8 characters
  
  use_address: 192.168.1.100 # Optional: Override mDNS

Services

logger

Configure logging output.

logger:
  level: INFO                # Log level
  baud_rate: 115200         # Serial baud rate
  tx_buffer: 512            # TX buffer size

Log Levels:

api

Enable Home Assistant API.

api:
  encryption:
    key: "32-character-base64-key"  # Required for encryption
  port: 6053                        # Optional: API port
  password: "deprecated"            # Deprecated: Use encryption
  reboot_timeout: 15min            # Optional: Reboot if no client

ota

Over-the-air update configuration.

ota:
  - platform: esphome_swift
    password: "ota_password"  # Optional: OTA password
    id: my_ota               # Optional: OTA ID

Components

Sensors

DHT Temperature/Humidity

sensor:
  - platform: dht
    pin:
      number: GPIO4          # Required: Data pin
      mode: INPUT            # Optional: Pin mode
    model: DHT22            # Required: DHT11/DHT22/AM2302
    temperature:
      name: "Temperature"
    humidity:
      name: "Humidity"
    update_interval: 60s    # Optional: Read interval

ADC (Analog Input)

sensor:
  - platform: adc
    pin:
      number: GPIO1         # Required: ADC pin (0-7)
    name: "Battery Level"
    update_interval: 30s
    # Note: Advanced filtering is planned for future releases

Switches

GPIO Switch

switch:
  - platform: gpio
    pin:
      number: GPIO5        # Required: Output pin
      inverted: false      # Optional: Invert logic
      mode: OUTPUT         # Optional: Pin mode
    name: "Relay"
    id: relay_switch      # Optional: Internal ID
    restore_mode: RESTORE_DEFAULT_OFF

Restore Modes:

Lights

Binary Light

light:
  - platform: binary
    pin:
      number: GPIO2       # Required: Output pin
    name: "Status LED"
    id: status_light

RGB Light

light:
  - platform: rgb
    red_pin:
      number: GPIO6       # Required: Red channel
    green_pin:
      number: GPIO7       # Required: Green channel
    blue_pin:
      number: GPIO8       # Required: Blue channel
    white_pin:            # Optional: White channel
      number: GPIO9
    name: "RGB Light"
    # Note: Light effects are planned for future releases

Binary Sensors

GPIO Binary Sensor

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO3
      mode: INPUT_PULLUP  # Recommended for buttons
      inverted: true      # Optional: Invert logic
    name: "Button"
    device_class: button  # Optional: HA device class
    # Note: Advanced filtering is planned for future releases

Device Classes:

Pin Configuration

Simple Format

pin: GPIO4               # Simple pin number
pin: 4                   # Integer format

Advanced Format

pin:
  number: GPIO4          # Pin number
  mode: INPUT_PULLUP     # Pin mode
  inverted: true         # Invert logic

Pin Modes:

Filters

Note: Advanced filtering capabilities are planned for future releases. Basic sensor reading and binary sensor input are currently supported.

Secrets Management

Use !secret to reference values from secrets.yaml:

# configuration.yaml
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

# secrets.yaml
wifi_ssid: "MyNetwork"
wifi_password: "MyPassword"

Best Practices

  1. Use Secrets - Never commit passwords or keys
  2. Unique Names - Each device needs a unique name
  3. Pin Documentation - Comment pin connections
  4. Update Intervals - Balance accuracy vs. power
  5. Restore Modes - Consider power loss behavior
  6. Filters - Smooth noisy sensor readings
  7. Device Classes - Use appropriate HA classes

Example Configurations

Basic Sensor Node

esphome_swift:
  name: bedroom_sensor
  friendly_name: "Bedroom Sensor"

esp32:
  board: esp32-c6-devkitc-1
  framework:
    type: esp-idf

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

api:
  encryption:
    key: !secret api_key

sensor:
  - platform: dht
    pin: GPIO4
    model: DHT22
    temperature:
      name: "Bedroom Temperature"
    humidity:
      name: "Bedroom Humidity"

Smart Switch

esphome_swift:
  name: smart_switch
  friendly_name: "Smart Switch"

esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: esp-idf

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

api:
  encryption:
    key: !secret api_key

switch:
  - platform: gpio
    pin: GPIO5
    name: "Light Switch"
    restore_mode: RESTORE_DEFAULT_OFF

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO9
      mode: INPUT_PULLUP
      inverted: true
    name: "Light Button"
    # Note: Automation actions like on_press are planned for future releases