ESPHome Swift
A Swift-based replacement for ESPHome that generates Embedded Swift firmware for ESP32 microcontrollers from declarative YAML configuration files.
Features
- 🚀 Native Swift Implementation - Type-safe configuration and code generation
- 📱 ESP32 RISC-V Support - Targets ESP32-C3, C6, H2, and P4 boards
- đź”§ Extensible Component System - Easy to add new sensors and actuators
- 🏠Home Assistant Compatible - Native API integration
- 📦 Simple YAML Configuration - Familiar ESPHome-style syntax
- 🔄 OTA Updates - Update firmware over-the-air
Quick Start
Installation
From Source
git clone https://github.com/ryan-graves/esphome-swift.git
cd esphome-swift
swift build -c release
sudo cp .build/release/esphome-swift /usr/local/bin/
Create Your First Project
- Create a new project:
esphome-swift new my-sensor
- Edit the configuration file: ```yaml esphome_swift: name: my-sensor friendly_name: “My Sensor”
esp32: board: esp32-c6-devkitc-1 framework: type: esp-idf
wifi: ssid: “MyWiFi” password: “MyPassword”
sensor:
- platform: dht pin: GPIO4 model: DHT22 temperature: name: “Temperature” humidity: name: “Humidity” ```
- Build and flash:
cd my-sensor esphome-swift build my-sensor.yaml esphome-swift flash build/my-sensor
Documentation
Supported Components
Sensors
- DHT - Temperature and humidity (DHT11, DHT22, AM2302)
- ADC - Analog input readings
Binary Sensors
- GPIO Binary Sensor - Digital input with debouncing
Switches
- GPIO Switch - Digital output control
Lights
- Binary Light - Simple on/off lighting
- RGB Light - Full color LED control
Coming Soon
- I2C sensors (BME280, BMP280, etc.)
- SPI devices
- Climate control
- Covers and fans
- Display support
Example Projects
Temperature Monitor
sensor:
- platform: dht
pin:
number: GPIO4
model: DHT22
temperature:
name: "Room Temperature"
humidity:
name: "Room Humidity"
update_interval: 60s
Smart Switch
switch:
- platform: gpio
pin:
number: GPIO5
name: "Living Room Light"
restore_mode: ALWAYS_OFF
RGB Mood Light
light:
- platform: rgb
red_pin:
number: GPIO6
green_pin:
number: GPIO7
blue_pin:
number: GPIO8
name: "Mood Light"
License
ESPHome Swift is released under the MIT License. See LICENSE for details.