๐Ÿ’พ Archived View for m0yng.uk โ€บ 2021 โ€บ 12 โ€บ Sonoff-S26-R2-+-ESPHome captured on 2022-04-29 at 12:23:12. Gemini links have been rewritten to link to archived content

View Raw

More Information

โฌ…๏ธ Previous capture (2022-04-28)

โžก๏ธ Next capture (2022-06-03)

-=-=-=-=-=-=-

Sonoff S26 R2 + ESPHome - M0YNG.uk

Created 2021-12-10

Modified 2022-04-18

Tagged

Who wants a smart home that stops working if the internet is down, or the OEM goes bust, or wants to charge you extra, or ... Not me!

I have a couple of TP-Link Kasa "Smart Plugs" because they were fairly cheap and they can be controlled from the command line by using python-kasa[1] or Thomas Breydo's thing[2] however, they still (try to) talk to their OEM a lot and at the time I needed to use the app to do the initial configuration.

1: https://python-kasa.readthedocs.io/en/latest/

2: https://github.com/thomasbreydo/kasa

Then I discovered that ESPHome[3] supports pretty much every Sonoff product, and that they are fairly cheap - I paid ยฃ32.82 for four sockets (ยฃ8.205 each) delivered from the UK.

3: https://esphome.io/

But what I got was the S26 R2 - which I haven't seen documented elsewhere, and there are some slight differences compared with the older version.

The documentation for S20 is basically the same - so do check that too: Sonoff S20 ESP Documentation

Open it up

Pop off the ring around the plugs, and remove the three screws, the case should come off into two parts.

S26 R2 with cover removed [IMG]

If you look closely at the writing on the chip on the daughter board you may worry that it is not an ESP8266 - but don't panic, it still works.

Flashing

There are no handy holes for the UART connections, so you WILL need a soldering iron for this.

Pull out the circuit board and look on the bottom by the daughter board which is sticking up and you should see three pads marked "V", "TX", & "RX". "GND" is on the other side of the daughter board.

You will need to solder some suitable wires to these pads (or try holding four wires very still!)

S26 R2 with wires soldered to the UART pads [IMG]

On my devices TX needed to connect to RX on my serial interface, and vice versa. (yours might be different, but there it won't break anything if you get this wrong initially)

*Note:* don't be scared off by the term "UART", I was successful using a normal USB->Serial interface This USB to RS232 at ยฃ6 on ebay

To get the device into "flash mode" hold down the button when you connect it to the computer - no lights should come on, if they do it didn't work and you can just try again. But it is worth giving it power without flash mode to check if the device is dead on arrival!

I am using ESPHome with Home Assistant[4] and generated the firmware from there. I named each one "s26-last four characters of serial number" and used "Pick specific board" -> "Generic ESP8266 (for example Sonoff)" as the device type.

4: https://www.home-assistant.io/

If you are using a chromium based browser you can just flash straight from the browser! But I found it more reliable to download the firmware image and use "esphomeflasher" to shove it over to the device.

Once the flash is complete, unplug from your computer and plug it back in again. Hopefully it will boot up and connect to your network and appear in ESPHome and/or Home Assistant.

Configuration

In my experience, the generated configuration file lacked some basic functionality. Sure - you can see if the button is pressed, turn the relay on and off, and the LED on and off, but that isn't quite a complete switch!

I want to be able to:

My configuration files look like this:

###
# All your normal WiFi Stuff here
###

# The button
binary_sensor:
  - platform: gpio
    pin:
      number: GPIO0
      mode:
        input: true
        pullup: true
      inverted: true
    name: "Sonoff S26 Button"
    # what to do when it is pressed
    on_press:
      - switch.toggle: relayandled
    # tell Home Assistant what is going on
  - platform: status
    name: "Sonoff S26 Status"
  - platform: gpio
    pin: GPIO2
    name: "Sonoff S26 Sensor"

# This is the relay
switch:
  - platform: gpio
    name: "Sonoff S26 Relay"
    pin: GPIO12
    id: s20_relay
    # the thing we do when the button is pressed
  - platform: template
    name: "Penguin Relay"
    optimistic: true
    id: relayandled
    turn_on_action:
    - switch.turn_on: s26_relay
    - light.turn_on: s26_status_led
    turn_off_action:
    - switch.turn_off: s26_relay
    - light.turn_off: s26_status_led

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

light:
  # ... and then make a light out of it.
  - platform: monochromatic
    name: "Sonoff S26 LED"
    output: s26_led
    id: s26_status_led

Tidying up Home Assistant

Each switch should now offer you some "things"

If this is too much clutter for your dashboard (it is for me!) you can disable most without any issue (in my experience)

Enable entity is disabled [IMG]

-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-

๐Ÿ–ค Black Lives Matter

๐Ÿ’™๐Ÿค๐Ÿ’œ Trans Rights are Human Rights

โค๏ธ๐Ÿงก๐Ÿ’›๐Ÿ’š๐Ÿ’™๐Ÿ’œ Love is Love

Copyright ยฉ 2022 Christopher M0YNG

Code snippets are licenced under the Hippocratic License 3.0 (or later.)

Page generated 2022-04-27 by Complex 19