May 19, 2026
Description
All smart home enthusiasts will know the issue - you have visitors and they are helplessly looking for a light switch, instead of admiring the level of automation that you have acomplished!
Nevermind, here is my solution.
I am running Home Assistant and the easiest way to set up a custom smart device is using ESPHome.
Add the provided code below to the bare configuration code of your connected ESP32 D1-Mini and upload it.
Solder the push button between GND pin, the resistor and pin IO27 or whichever pin you decided on using. Just remember to update your code accordingly.
What I used:
For the look I have spray-painted the parts. Then, insert the pre-soldered ESP32, the switch and glue the two halves of the case together.
This switch ads a little fun to switching!
Here the code, just copy/paste:
switch:
- platform: template
name: "Toggle State"
id: toggle_state
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
binary_sensor:
- platform: gpio
pin:
number: GPIO27
mode:
input: true
pullup: true
inverted: true # gedrückt = ON
name: "Taster"
id: taster
filters:
- delayed_on: 20ms # Entprellung
on_press:
then:
- switch.toggle: toggle_state
# Optional: langer Druck als separate Aktion
on_click:
- min_length: 1000ms
max_length: 3000ms
then:
- logger.log: "Langer Druck erkannt"
MembershipConsider supporting me with a membership - this will give me the boost and motivation to upload even more designs! Every single supporter matters to me - and makes me invest even more time, sweat and filament, to bring you the designs you are waiting for. Also, as a member you are able to request changes to my models for your very own purpose and needs!
License:
MakerWorld Exclusive License
2,683