I have a sit/stand conversion that sits on top of my desk. Controls are very simple: press and hold button - desk goes up. Press and hold other button - desk goes down.
I have duplicated same functionality with ESP32 and relay module. I can toggle relays on or off from HA.
I have added 2 physical buttons that duplicate same functionality as stock. Press button, LED lights up and relay is triggered on.
I want to add another two buttons that will function as follows: momentary press - LED is on, relay is on. This condition stays for 25 seconds and then LED goes off and relay is turned off.
Here is my code so far:
esphome:
name: "esp32-desk"
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
web_server:
port: 80
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esphome-Web-0046Cc"
password: "YvUhUSzJdfL7"
captive_portal:
switch:
- platform: gpio
pin: GPIO22
name: "Desk Up relay"
id: relay1
inverted: True
- platform: gpio
pin: GPIO23
name: "Desk Down relay"
id: relay2
inverted: True
- platform: gpio
pin: GPIO4
id: up_led
name: "Desk UP Led"
- platform: gpio
pin: GPIO18
id: down_led
name: "Desk Down Led"
#relay stays ON when button pressed and held down, led lights up
binary_sensor:
- platform: gpio
name: 'Switch UP'
pin:
number: GPIO2
mode:
input: True
pullup: True
inverted: true
on_press:
then:
- switch.turn_on: relay1
- switch.turn_on: up_led
on_release :
then:
- switch.turn_off: relay1
- switch.turn_off: up_led
- platform: gpio
name: 'Switch Down'
pin:
number: GPIO5
mode:
input: True
pullup: True
inverted: true
on_press:
then:
- switch.turn_on: relay2
- switch.turn_on: down_led
on_release :
then:
- switch.turn_off: relay2
- switch.turn_off: down_led
Appreciate any help I can get.