About |
|||||
This device allows you to operate a mains appliance via Alexa or Google Assistant. However, its firmware can be reflashed with ESPHome allowing Home Assistant to take full control of it on your local network, without need for the internet. |
|||||
|
|||||
|
|||||
Parts needed |
|||||
Sonoff S20 Wi-Fi smart switch (as above) Home assistant - with ESPHome installed A USB to TTL module (with 3V option selected) to flash the new firmware. |
|||||
![]() |
|||||
This is the inside of the module. The unit does not come with the 4 way connector. I have soldered this in. If you prefer, you could solder wires just for programming. The connections marked up are what should be connected to the TTL port. Swap RX and TX at the USB device. |
|||||
ESPHome device setup |
|||||
Before you can flash the firmware, you need to setup a new device in ESPHome. These instructions were wrote in May 2025. Home Assistant and ESPHome may have change since this. Navigate to ESPHome Builder in Home Assistant. Press + NEW DEVICE at the bottom right. Click Continue. Enter a name for the new device (this can be changed in the code later if needed) Choose ESP8266. Its not this, but this is the nearest match. We will change it in the code later. Click INSTALL How do you want to install? We will be plugging into the computer running ESPHome Device Builder. You can cancel now. We can't go any further yet.
In ESPHome Builder, find your new device, click edit.
|
|||||
ESPHome code
|
|||||
Take a look at the Sonoff WiFi smart switch under home assistant which shows connecting up to the USB TTL device. | |||||
Hold down the sonoff button whilst connecting the USB TTL to a USB port on the Home Assistant PC. In Home Assistant - whist viewing the yaml code, press INSTALL at the top right.
|
|||||
Choose the one highlighted. Choose your USB device. After some waiting, you should eventually end up with sometihng like this:
|
|||||
|
|||||
At this point, as a quick test, unplug from the USB port, and plug it back in. The LED on the Sonoff should start to flash. Go back to the ESPHome Builder page, locate your device and click LOGS: Choose "Plug into computer running ESPHome Dashboard" Choose the USB device again. You might see various information about the status of the device. You can press the button on the unit, this should show in the log.
|
|||||
![]() |
|||||
By now, you should have an item waiting in Notifications. Click this, New devices discovered > Check it out Find the new item, click ADD Thats it. The Sonoff device is now a tighly integrated part of Home Assistant. It does not use the internet to connect, just your own WiFi directly to Home Assistant. |
|||||