An ESPHome based smartswitch

In my garage I have a wiring center that has a number of outside lights cabled to it (via a Sonoff 4CH pro) , aswell as the garage main lights. I now also have couple of appliances that are also switched both by smart plugs (my garage air compressor) and a battery charging station (a extension lead with battery chargers cabled to the Sonoff 4CH.

Until now local control was limited - any switching was done either via automations or phone/web/google assistant etc. When i added the garage main lights to the setup though I decided I wanted local control of everything. Went for a grid switch (modular switch system) with an ESP32 as the brain, WS2812s for indicator leds, GPIO for switch inputs and a small relay board for the garage lights (as I’d run out of relays on the Sonoff 4CH pro).

The switches all trigger the relevant entity in HA directly from ESP home, with the exception of the 1 switch which triggers the local relay board. The indicator LEDs are each driven from an ESPHome binary sensor monitoring the HA entity that in turn controls an individual light element (partition in ESPHome) representing each LED within the strip. Added a DHT11 for temp/humidity - and a couple of GPIO for inputs that will take garage door sensors shortly.

It occurred to me that it pretty much encompasses the full range of the particular technologies I’ve got in the house - but presents them as a single integrated solution…

HA as the back end
ESPHome + ESP32 for local intelligence

  • Local GPIO for both input/output
  • 2812 Addressable LEDs
  • Additional Temp/Humidity sensors
    Control of serial flashed (ESPHome) Sonoff 4CH Pro
    Control of Tuya-converted smart plug (flashed to ESPHome)

Assembling the switch :-


Cabling begins :-

Lower 3 switches added :-

Assembled ( The leds are glued to the from plate behind some diffusing white acrylic pieces)

The wiring unit with Sonoff 4CH Pro :-

All installed. the FCU (fuse+switch) above the consumer unit is for the Wifi repeater above, 4CHpro, Battery charger extension lead and the ESP in the switch.Reel of white alarm cable for the not -yet installed door sensors.

7 Likes

Congrats, that is a job very well done !
How do you mount the perfboards in the housing ?

Mounting of perfboard (and relay PCB) was via universal combined insulator and fixative…or “Hot Glue” :smiley:

I didn’t have any little pcb stand offs to hand. I’m slightly paranoid about the mains on the the little hi-link transformer being accessible on the exposed tracks between screw terminals and the pins - so always cover that in hot glue front and back…(aswell as the relay pins) so just added a few layers and used the last layer to stick them in.

Hi,
Do you mind to share your code?