I needed a switch for the garage to turn on and off the dust extractor and disable a sensor while working in that space. I have been using one of the cheap Tuya Zigbee ones and while it works it was not quite what I wanted.
I found a few handheld cases left over from a projects from ages ago and decided to design a PCB to do what I wanted that would fit those cases. One case has 4 buttons, the other no buttons but space for 8. The main requirement other than separate on and off switches was some feedback from HA that something had happened.
I have used the ESP32-C3 based DT-ESP-C05 module as I had few that were not needed after LibreTiny was rolled out and the circuit is pretty simple, 8 switches and 4 LEDs and 3.3V regulator. The 4 button version works fine, the 8 button may have an issue as I put a pulled down LED on GPIO9 but I can work around that if needed. The switch is powered from a low voltage DC supply I have run to various places in the building.
#### - My 4/8 button switch with ESP-C3-C05
#V1a - default install
#V1b - pinouts - SW1-IO19, SW2-IO18, SW3-IO7, SW4-IO2, LED1-IO4, LED2-IO3
#V1b - test switches and LEDs
#V1c - add sw3 & sw4 and LED actions
#V1d - add HA sensor state input & wifi sensor
#V1e - add action to HA text sensor
#V2a - add correct HA sensors
#V2b - adjust LED timings, change LED to use output
#V2c - change HA sensor to use lambda
#V2d - flash both LEDs on button press
esphome:
name: 4button1
esp32:
board: esp32-c3-devkitm-1
framework:
type: arduino
logger:
api:
ota:
password: "********"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: "4Button1 Fallback Hotspot"
password: "********"
sensor:
- platform: wifi_signal
name: "4Button1 WiFi"
update_interval: 120s
binary_sensor:
- platform: gpio
pin:
number: GPIO19
mode: INPUT_PULLUP
inverted: true
id: sw1_4b1
name: "4Button1-1"
filters:
- delayed_on: 10ms
on_press:
then:
- output.turn_on: led1_4b1
- delay: 250ms
- output.turn_off: led1_4b1
- delay: 250ms
- output.turn_on: led2_4b1
- delay: 250ms
- output.turn_off: led2_4b1
- platform: gpio
pin:
number: GPIO18
mode: INPUT_PULLUP
inverted: true
id: sw2_4b1
name: "4Button1-2"
filters:
- delayed_on: 10ms
on_press:
then:
- output.turn_off: led1_4b1
- output.turn_on: led2_4b1
- delay: 250ms
- output.turn_off: led2_4b1
- delay: 250ms
- output.turn_on: led1_4b1
- delay: 250ms
- output.turn_off: led1_4b1
- platform: gpio
pin:
number: GPIO7
mode: INPUT_PULLUP
inverted: true
id: sw3_4b1
name: "4Button1-3"
filters:
- delayed_on: 10ms
on_press:
then:
- output.turn_on: led2_4b1
- delay: 250ms
- output.turn_off: led2_4b1
- delay: 250ms
- output.turn_on: led1_4b1
- delay: 250ms
- output.turn_off: led1_4b1
- platform: gpio
pin:
number: GPIO2
mode: INPUT_PULLUP
inverted: true
id: sw4_4b1
name: "4Button1-4"
filters:
- delayed_on: 10ms
on_press:
then:
- output.turn_off: led2_4b1
- output.turn_on: led1_4b1
- delay: 250ms
- output.turn_off: led1_4b1
- delay: 250ms
- output.turn_on: led2_4b1
- delay: 250ms
- output.turn_off: led2_4b1
output:
- platform: gpio
pin: GPIO4
id: led1_4b1
- platform: gpio
pin: GPIO3
id: led2_4b1
text_sensor:
- platform: homeassistant
name: "Text Sensor - Turn On/Off Dust Extractor"
#entity_id: switch.dust_extractor_dust_ext_relay
entity_id: switch.shelly1pm_plug_0768
id: dust_ext
on_value:
- if:
condition:
lambda: 'return x == "on";'
then:
- delay: 1000ms
- output.turn_on: led1_4b1
else:
- delay: 1000ms
- output.turn_off: led1_4b1
- platform: homeassistant
name: "Text Sensor - Disable Garage Front Person"
entity_id: automation.notification_garage_front
id: disable_gf
on_value:
- if:
condition:
lambda: 'return x == "off";'
then:
- delay: 1000ms
- output.turn_on: led2_4b1
else:
- delay: 1000ms
- output.turn_off: led2_4b1