Need Help with Well Tank Alarm

Hi all, years ago I created an alarm for the amount of air space in my water well pressure tanks, this was by using IFTTT, recently I was informed it was turned off unless I pay, OK it’s time to do it locally.
What I have is a current switch on the pump on GPIO0, and a LED on GPI02, when the pump shuts off, a timer starts, if the pump starts again before 30 seconds has passed the LED comes on and WIFI sends the alarm.
Any help would be greatly appreciated, thanks, Rick

Are you running ESPHome? What hardware (ESP)?
What is your current config?

Yes ESPHome, ESP-01 module.
I’ve only got the module connected so far, totally confused on how to use a timer or counter
esphome:
name: well-pump
friendly_name: well-pump

esp8266:
board: esp01_1m

Enable logging

logger:

Enable Home Assistant API

api:
encryption:
key: “”

ota:
password: “”

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password

Enable fallback hotspot (captive portal) in case wifi connection fails

ap:
ssid: “Well-Pump Fallback Hotspot”
password: “”

captive_portal:

OK, I asked at chatGPT, I think I got a pretty good start, but I get a “Component not found: automation”, when I try to install

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
      inverted: true
    id: pump_on
    name: "Pump On"
    device_class: door

sensor:
  - platform: template
    name: "Pump On Time"
    unit_of_measurement: "s"
    update_interval: 1s
    accuracy_decimals: 0
    lambda: |-
      if (id(pump_on).state) {
        // Pump is on, start counting time
        static unsigned long start_time = 0;
        if (start_time == 0) {
          start_time = millis();
        }
        return (millis() - start_time) / 1000;
      } else {
        // Door is closed, reset timer
        start_time = 0;
        return 0;
      }

output:
  - platform: gpio
    pin: GPIO2
    id: led_output

automation:
  - alias: "Turn on LED if pump stays off less than 30 seconds"
    trigger:
      platform: numeric_state
      entity_id: sensor.pump_on_time
      above: 30
    action:
      - output.turn_on: led_output

    

Chatgpt is great if you never want to learn or understand what you’re doing and enjoy being clueless. There is a wealth of documentation on https://esphome.io/ that explains automations and gives you lots of examples. The automation you need is a very basic one and there are pretty much examples alone that would meet your needs. You just gotta try, that’s it. Show that you are trying to learn it and make an effort and people are more inclined to help that person over chatgpt person.

Well now you’ve really gotten to me, first a little about me, I’m a licensed electrician have wired and programed commercial PLC’s for over 30 years, these devices are all pretty much the same, they have inputs, analog or digital and outputs, analog or digital, timers, counters, and a host of special features, they function purely with logic period… Saying that, you might start to understand my confusion of using typically non logically named items. I had already spent many hours trying to find information, had read the documents you are showing me… I just don’t get it, that’s why I asked for help, I gave up and am trying other paths, if you can actually point me to the answer that would help.
Thanks, Rick

An esp board is very similar but in this case or at least from what i’m told my my brothers who are all journeyman electricians. They(you) do the wiring of the PLC but someone else comes in and programs the logic/automations which is what you now have to do. I’m not really sure what you mean by “non logically named items”. Can you expand on that?

I forget sometimes how confused I was when I first started diving into those documents so I apologize. I will say though, once you kind of get the hang of it, it will all start making a lot of sense and you’ll be zipping over there to look at the Docs for a reference or reminder and it will only take 60-90 seconds to get what you need and you’re done.

If you want, I’ll help you out and walk through this one with if you.

Thank you Justin for the response.
Where I reside the electricians have always been allowed to program and make changes to programs even though engineers have fought it. By “non logically named” I mean things like “sensor”, in my world this refers to an external analog device that would be connected to the controller, a “switch” is also an external digital device, neither one of these terms would ever be used inside a program, it’s just very confusing. I’m very familiar with ESP boards and have used them for many years, I used Arduino to program this very setup years ago.
I have been using Homeassistant for years as well, I have tried to learn yaml but I just can’t quite figure it out, that and it’s always 6 months between projects so I forget what I thought I knew.
If you know how to do this help would be greatly appreciated.
Thanks, Rick

Oh thats cool. I always give my brothers a hard time and call them glorified wire pullers. The joke is actually on me though… they got it pretty cushy and im the one in a trench box 20’ deep slogging in the mud…

So those terms are just for telling esphome what it is you are commecting to it. So a “sensor” can be a lot of things but overall its an input for a gpio pin. Whichever platform you use will determine what kind of functions are available to use. So, a binary sensor for example is the same, its a gpio input(the esp is expecting to receive a logic High or Low) its binary sp thats one or the other, On or Off, High or Low.

A “sensor” alone is more of a generic term unlike binary sensor where it only accepts High/Low. A generic sensor can be used to program a gpio input for all kinds of physical sensors that send analog signals, digital, they csn be used for a sensor like a temp sensor that will give you numbers (72.0 deg.). Its more or less a “catch all”

OK, I got this to work with node red perfectly, but when I move it to the pump house the same ESP module that I used before won’t connect, I tried many others, even different models, none of them will connect, apparently there is a range difference between ESPHome and MQTT, I stopped using MQTT with Homeassistant because every time we had a power outage they all had to be reprogrammed, but ESPHome works fine, I don’t think I can win.

If anyone is interested what finally worked was I used a 433 mhz door contact wired the current switch across the reed switch and am using it with the sonoff RF-Bridge, (the 433 mhz has much better range when you extend the antennas). Does anyone know why the ESPHome has worse range than MQTT?

Worse range than mqtt? MQTT is a messaging protocol, it doeant have a range except for the range of the hardware using it…

That’s what I thought, but the same ESP in the same location worked perfect for years sending webhooks to IFTTT, I know it worked because the wifi turned on once, sent the packet then went into deep sleep with no wake (keeps down on wifi clutter).
This worked about every 3 months perfectly.

So you cant send mqtt from the same location? Im confused. Initially it was mqtt and esphome, now its webhooks and IFTTT

I don’t know about the chicken or the egg but I first used webhooks and IFTTT in 2017, before I had used Homeassistant and ESPHome, here is one of my creations Thingiverse - Digital Designs for Physical Objects