Simple hardware on/off switch with ESP01

Hello everyone,

Some time ago I created an IFTTT hardware button following this tutorial:

Now that I am switching to HA, I am looking to recreate the very same.

Can I keep the same hardware? What firmware/code do I flash onto the ESP01?
I am quite the newbie but I can follow tutorials.
Is there any resource you can link me to?

I apologise if this has been already asked.

Many thanks,
T

Did looking at the esphome documentation cross your mind? https://esphome.io/

yes, I was hoping there was something easier to follow, more like the tutorial I followed the first time

Welcome.

Not sure about a full walk through, but basically first you need to figure out how to flash a minimal config to the esp so you can OTA.

Once you’ve figured out the workflow for that once it’s easy.

Then you can add a button as a binary sensor.

Hi, I have such an entry in the configuration:

binary_sensor:
  - platform: gpio
    id: button
    name: Szambo
    pin:
      number: GPIO2

If I connect VCC to GPIO2, the state changes to ON and remains ON even when I disconnect VCC. When I connect GND, it changes to OFF. What do I need to change so that it switches to OFF immediately when I disconnect VCC?

p.s. if I add the following, it works as I would like, but on GND, not VCC

      mode:
        input: true
        pullup: true
      inverted: true

Typically you have it connected to a gpio and to ground. Having pull-ups activated typically is a good idea. Inverting it depends on your use case.