I have recently been using these, very inexpensive, go,comma WiFi switches. I get them from GearBest https://www.gearbest.com/smart-home-controls/pp_009841506979.html?wid=1433363
They are particularly friendly to re-flashing. The plastic top is just a snap fit. No heating and un-gluing is involved!
The board uses the ubiquitous ESP8266. As you see from the photo, they have even labelled all the five points you need to solder on to for re-flashing.
I use the marvelous ESPHome ( https://esphome.io/ ) for all of my devices now. So the steps are:
- Hook up your USB to Serial converter to VDD (3v), GND, TXD and RXD.
- Connect GPIO0 to ground
- Create a new ESPHome device
- Select the compile option and download the binary
- I connect the USB to Serial to my laptop, rather than the Home Assistant, so I use ESPHomeflasher to flash the binary to the device
- Disconnect GPIO0 from ground and unplug and re-plug the USB to Serial converter and watch the logs.
That’s it done.
Here is my YAML for these devices:
binary_sensor:
- platform: gpio
pin:
number: GPIO12
mode: INPUT_PULLUP
inverted: True
name: "ESP Switch 1 Button"
on_press:
- switch.toggle: eswitch_1
output:
- platform: gpio
pin: 4
id: 'relay'
- platform: gpio
pin:
number: 13
inverted: yes
id: red_led
- platform: gpio
pin:
number: 15
inverted: yes
id: blue_led
switch:
- platform: output
name: "ESwitch 1"
id: eswitch_1
output: 'relay'
on_turn_on:
- output.turn_on: blue_led
- output.turn_off: red_led
on_turn_off:
- output.turn_off: blue_led
- output.turn_on: red_led
The led toggles between Blue and Red as the switch is turned ON and OFF.
A press of the Button will toggle the switch.
I find these are particularly effective in the lead of a table lamp. As ever, when dealing with Mains Electricity, if you are inexperienced then get a professional to do the wiring!
If anyone want more details on this process then please drop me a comment and I’ll try to answer any questions.