Sonoff devices are affordable Wi-Fi smart switches and plugs. This guide shows three reliable ways to control them from Home Assistant (HA):
- Method A — eWeLink Cloud: quickest to try; needs internet for control.
- Method B — Local LAN: control over your home network; no cloud latency.
- Method C — ESPHome: flash custom firmware for the most control and telemetry.
What you’ll need
- Home Assistant (any install) on the same network as your Sonoff devices.
- A working 2.4 GHz Wi-Fi network (most Sonoff products don’t support 5 GHz).
- One or more Sonoff devices (Basic, Mini, POW, S26, etc.).
- For Method C: a computer to flash firmware, and a USB-to-TTL adapter (for some models).
Method A — eWeLink Cloud (fastest)
Great for a quick demo or if you don’t want to modify anything. Requires internet.
- Pair Sonoff with eWeLink (the official app) and ensure you can toggle the device in the app.
- In Home Assistant, go to Settings → Devices & Services and click Add Integration. Search for eWeLink Smart Home (by CoolKit).
- Log in with the same eWeLink account. Your devices should appear in HA.
Method B — Local control via Sonoff LAN
This method keeps your automations local (no cloud). We’ll use the community Sonoff LAN custom integration.
Step 1 — Install HACS (if you don’t already use it)
- In HA, go to Settings → Add-ons → Add-on Store and install the Terminal & SSH add-on (optional but handy).
- Follow the official HACS install at
hacs.xyz/docs/setup/download. After a restart you’ll see HACS in the sidebar.
Step 2 — Add Sonoff LAN
- Open HACS → Integrations, click Explore & Download and search for Sonoff LAN (by AlexxIT). Install and restart Home Assistant.
- Go to Settings → Devices & Services → Add Integration, search for Sonoff LAN, and enter your eWeLink credentials. The integration uses local protocol where possible.
Example: use a Sonoff switch in an automation
alias: Turn on geyser at 5am (weekdays)
trigger:
- platform: time
at: "05:00:00"
condition:
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
action:
- service: switch.turn_on
target:
entity_id: switch.sonoff_geyser
mode: single
Method C — Flash ESPHome (power users)
ESPHome replaces the stock firmware. You gain rock-solid local control, telemetry, and full customization. On many models you can flash OTA (web-installer); others need a USB-to-TTL serial flash.
Step 1 — Create a new ESPHome device
- In HA, go to ESPHome and click New Device.
- Name it (e.g. sonoff_geyser) and select a supported board (often ESP8266 for older Sonoff or ESP32 for newer).
- Configure Wi-Fi credentials when prompted.
Step 2 — Use a minimal config (example for a relay + status LED)
esphome:
name: sonoff_geyser
esp8266:
board: esp01_1m
# Your Wi-Fi (2.4GHz)
wifi:
ssid: "YOUR_WIFI"
password: "YOUR_PASSWORD"
ap:
ssid: "sonoff-fallback"
password: "fallback123"
logger:
api:
ota:
# GPIOs vary by model — check ESPHome device pages for your exact Sonoff model
switch:
- platform: gpio
name: "Geyser Relay"
pin: GPIO12
id: relay_1
status_led:
pin:
number: GPIO13
inverted: true
After compiling and flashing, ESPHome will auto-discover in HA. Add it from Settings → Devices & Services.
Troubleshooting & FAQs
Device not discovered in HA
- Confirm 2.4 GHz Wi-Fi is enabled; some APs have band-steering issues.
- Power-cycle the device and your router.
- For LAN/ESPHome, ensure HA and device are on the same subnet/VLAN.
Slow control or delayed automations
- Cloud method adds latency; prefer LAN or ESPHome for instant response.
- Use a static DHCP lease so HA always finds the device quickly.
Which method should I choose?
- Just starting: Method A (cloud) to test.
- Daily driver: Method B (Sonoff LAN) for local, fast control.
- Advanced: Method C (ESPHome) for maximum features & reliability.
Next steps
- Create energy-saving schedules (e.g., pool pump or geyser) based on time-of-use tariffs.
- Combine with presence or solar production sensors to automate intelligently.
- Add a manual override button in your dashboard for quick control.