Migrating some old Sonoff S20 smart plugs

Last Updated or created 2022-12-28

(From ESPEASY to ESPHOME without soldering)

I previously had these smartplugs flashed with EspEasy (I hate cloud enabled devices)
I will post something about flashing these and others.
Maybe … because you can find a lot of information on the internet.
But i’ve used several tools, and made tools for this process.
( Raspberry Zero mobile tool and 3D printed PCB holder for example)

Well ..

I was using these devices in our previous home using curl commands and on a main wifi network.
So i have to change the SSID and migrate from Espeasy to ESPhome so i can use these devices with Home Assistant.

Step 1 : Start in Access Point mode and migrate to my current Wifi Iot network.

Using my phone i made the necessary changes.

Goto HomeAssistant and ESPhome (you need to install this first via HACS)
Press the green + Add device and give it a name

Next select the device type (Sonoff S20 in this case)

Press install and select manual download

Above will compile a binary for the Sonoff device.

Go back to your Sonoff interface and go to the tools tab.
We can reflash the device without connecting this with wires to our computer.

Press Firmware load and select your downloaded binary

Back in HA it should say “online”

Pressing edit gives us a config page. Nothing works .. yet
We need to add some yaml entries.
( use https://esphome.io/devices/sonoff_s20.html )

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO0
      mode:
        input: true
        pullup: true
      inverted: true
    name: "Sonoff S20 Button"
  - platform: status
    name: "Sonoff S20 Status"
  - platform: gpio
    pin: GPIO2
    name: "Sonoff S20 Sensor"


switch:
  - platform: gpio
    name: "Sonoff S20 Relay"
    pin: GPIO12

output:
  # Register the green LED as a dimmable output ....
  - platform: esp8266_pwm
    id: s20_green_led
    pin:
      number: GPIO13
      inverted: true

light:
  # ... and then make a light out of it.
  - platform: monochromatic
    name: "Sonoff S20 Green LED"
    output: s20_green_led

Now press install

Now we can use wirelessly to upload the config

After this the device can be discovered by HA

Click add, and use the encryption key found in the yaml config to add

Success!

Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *