Now that we have support for the new button entity in HA and ESPHome, I’m trying to convert one of my existing configs to change an existing momentary switch into a button (mainly for UI reasons):
The issue is making a button work with a GPIO output.
I am probably just dense, but I can’t figure out how to make the two work together. Looking at the button examples in HA, they seem more geared towards triggering general automations versus what I am trying to do.
To be clear, the button press would be initiated in my Lovelace UI, not from the device itself. Can anyone suggest a way to accomplish this in ESPHome?
switch:
- platform: gpio
pin: GPIO12
id: relay
- platform: template
icon: "mdi:arrow-up-down-bold-outline"
name: "Garage Door Opener"
id: gdopener #add your button id
turn_on_action:
- switch.turn_on: relay
- delay: 600ms
- switch.turn_off: relay
- switch.turn_off: gdopener # turn off your button after a given time