-- Leo's gemini proxy
-- Connecting to m0yng.uk:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini;lang=en
Created 2021-12-10
Modified 2022-04-18
Hacking
Home Automation
ESPHome
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.
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.
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
**WARNING** This is a mains powered device. DO NOT OPEN IT WHEN IT IS PLUGGED IN.
Pop off the ring around the plugs, and remove the three screws, the case should come off into two parts.
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.
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!)
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)
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.
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.
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:
Turn the relay on and off remotely
Turn the relay on and off by pressing the button
Have the state correctly relayed to Home Assistant
Have the LED turn on and off depending on the relay state
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
**TIP** you can add this to your configuration BEFORE initial flashing, to avoid doing everything twice.
Each switch should now offer you some "things"
The relay itself (switch)
The LED (light)
The Button (sensor)
The state (sensor)
The template we called "Penguin Relay" (switch)
If this is too much clutter for your dashboard (it is for me!) you can disable most without any issue (in my experience)
Go to "Configuration"
Go to "Devices"
Find your switch and click to open its configuration
Find the thing you want to disable, for example "binary_sensor.sonoff_s26_button"
Click to open the Settings modal dialogue
Toggle the "Enable entity" switch
Cick UPDATE
-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-
๐ค Black Lives Matter
๐๐ค๐ Trans Rights are Human Rights
โค๏ธ๐งก๐๐๐๐ Love is Love
Copyright ยฉ 2024 Christopher M0YNG - It is forbidden to use any part of this site for crypto/NFT/AI related projects.
Page generated 2024-03-24 by Complex 19
-- Response ended
-- Page fetched on Sat May 18 21:49:47 2024