Need help with ATOM Lite as a simple switch

Hello all. I have a gate that I’m trying to control through home assistant. It seems simple as all I have to do is jump pin 4 to pin 5 on the board my Topens gate opener. I can confirm this by using a simple jumper wire and I can manually control the gate without using a remote.
I’m trying to use an ATOM Lite as a simple switch. I’m not sure if I need an Active Low Switch or a Momentary Switch or Binary Sensor. I’m no programmer. I’ve spent some time reading over the info on ESPHome website and the more I read the more confused I get. I’m hoping to get a little guidance in either reference material or if someone can help with my YAML file. I found a sample code that I have compiled and loaded. The problem is the GPIO I chose (tried a few) is ALWAYS grounded, not activated by command. Here is the current code I found on the ESPHome website that references a gate opener.

switch:
  - platform: gpio
    pin: GPIO23
    id: relay
    name: "Gate Remote"
    icon: "mdi:gate"
    on_turn_on:
    - delay: 500ms
    - switch.turn_off: relay

I’m sure it can be more simple but I’m not sure what to do. Any help would be great. Thanks!

This is what I use for my Atom Lite to get the button working:

esphome:
  # Workaround for Button (GPIO39) randomly triggering
  # Increases power usage slightly (~1mA)
  # https://docs.espressif.com/projects/esp-idf/en/v4.4/esp32/api-reference/peripherals/adc.html#_CPPv412adc1_get_raw14adc1_channel_t
  includes:
    - common/device/m5stack-atom-lite.h
  on_boot:
    then:
      - lambda: "adc_power_acquire();"

# https://community.home-assistant.io/t/atom-lite-rgb-led-turns-on-by-itself/452852/6
light:
  - platform: esp32_rmt_led_strip
    rgb_order: GRB
    pin: 27
    num_leds: 1
    rmt_channel: 0
    chipset: SK6812
    id: status_led
    name: Light
    default_transition_length: 0s
    effects:
      - random:
      - flicker:
      - addressable_rainbow:

binary_sensor:
  - platform: gpio
    pin:
      number: 39
      inverted: true
    name: Button

The contents of m5stack-atom-lite.h are:

#include <driver/adc.h>

You’ll need to put that in your ESPhome directory somewhere and update the path at the top to point to it.

Thank you for the response. Just so I’m on the same page I’m only trying to trigger the GPIO remotely. I’m not trying to use the dedicated button on the ATOM Lite. Do you think it’s a driver issue hence the recommendation to add the included adc driver to Home Assistant? I thought it was just an incorrect YAML for the switch. Thanks again.

Sorry, my bad. I didn’t read your OP carefully. Yes, my YAML is about making the button on the atom lite work, not about using it as a switch.

In English “switch” has more than one meaning. In esphome switch usually means a GPIO output that you can control from HA that would typically turn on/off something.

You have a gate opener. You did not state if it was the remote or the actual opener. You have verified that you can achieve what you want with a simple wire. To achieve exactly that with esphome you need a physical relay to go with the GPIO output you have setup. They make relay boards that make it easy, or you need more circuitry to drive the relay.

If you have measured the voltages on the gate opener (at the two points that you need to short) you might be able to eliminate the relay and drive the pin directly. An optoisolator is another (probably better) choice. It all depends on the circuit you are trying to control.