Pump template

I was trying to start my well pump from ESP home. I inserted a start stop switch in home assistant & in hardware added two relays. One is for start & another is for stop as my well pump has a starter.

Now I need help to design a template which will have a single button which clicked will start motor & state should be shown. (ON/OFF). & clicking on same it should get turned off. A current clamp meter will be installed at one phase of pump which can be taken as input in esp wemos d1 mini.

I need a esphome program.

Why don’t you post what yaml you have done so far and show us what you have attempted?

Also have a read of this:


1 Like

Thanks for pointing in the right direction. I will improve it.

Here is the current program which i have wrote to achieve the turning on & off of the pump.


name: well-pump


board: d1_mini

Enable logging


Enable Home Assistant API



key: "UFPT+dc+vpn0KKvjejTLQFMCRTi5KCgfJs6h4JYmlq8="


password: “bac3bd519f7ebe3125fb4710b017540f”


ssid: !secret wifi_ssid

password: !secret wifi_password

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


ssid: "Well-Pump Fallback Hotspot"

password: "LlSS19qJAB7E"



  • platform: gpio

    name: Start Motor

    pin: D5

    id: Start

    inverted: True


    • delay: 1s

    • switch.turn_off: Start

  • platform: gpio

    name: Stop Motor

    pin: D6

    id: Stop

    inverted: True


    • delay: 1s

    • switch.turn_off: Stop


  • platform: time_based

    name: “Cover”

    id: my_cover


    • switch.turn_on: Start

    open_duration: 3s


    • switch.turn_on: Stop

    close_duration: 3s


    • switch.turn_off: Start

    • switch.turn_off: Stop

i had tried the cover template to achieve the last state of pump. but was not quite successful.

now i have a current measuring sensor. i would like to add that sensor & take a state of pump. if current is present then the pump is on else off.

i cant decide hoe should i start is from.

You obviously missed the bit in “how to ask a good question” about formatting posts. Read point 11 and edit your post to enclose your yaml in “Preformatted text” tags. They look like </> on the posting toolbar.