Water pump control

You’ve really answered your own question:

This is the same logic as your high sensor - so:

  - platform: esp32_touch
    name: "water_tank_full"
    pin: GPIO27
    threshold: 300
    on_press:
      then:
        - switch.turn_off: pump

EDIT: The only issue you may have is - in your Arduibno code, if the filter is at the low sensor, which would normally turn on the pump, this will be overridden by the tank being full. That’s because the order matters in the code you wrote. This is not how ESPhome works - all the triggers are asynchronous. So you need to put a condition on the low sensor:

  - platform: esp32_touch
    name: "low_sensor"
    pin: GPIO13
    threshold: 300
    on_release:
      then:
        - if:
            condition:
              binary_sensor.is_off: water_tank_full
            then:
              switch.turn_on: pump

Make sense? I think that will reproduce the logic of your Arduino code - you will need to test.

Also what triggers the pump to come back on?

In your Arduini code you are continually testing your sensors, waiting for some conditions. So eventually you will get to a point where the low level sensor is read as LOW but so is your tank sensor.

The pump will then start.

ESPHome doesn’t work that way, it’s not looping around looking at states. The triggers only work the once, so you pump will never turn on again.

So you need extra code:

  - platform: esp32_touch
    name: "water_tank_full"
    pin: GPIO27
    threshold: 300
    on_press:
      then:
        - switch.turn_off: pump
    on_release:
      then:
        - if:
            condition:
              binary_sensor.is_off: low_sensor
            then:
              switch.turn_on: pump
# Pump Control
esp32_touch:
  setup_mode: false

switch:
  - platform: gpio
    name: "Water Pump"
    pin: GPIO12
    id: pump
    
binary_sensor:
  - platform: esp32_touch
    name: "low_sensor"
    pin: GPIO13
    id: low_sensor
    threshold: 300
    on_release:
      then:
        - switch.turn_on: pump
    
  - platform: esp32_touch
    name: "high_sensor"
    pin: GPIO14
    id: high_sensor
    threshold: 300
    on_press:
      then:
        - switch.turn_off: pump
        
  - platform: esp32_touch
    name: "water_tank_full"
    pin: GPIO27
    id: water_tank_full
    threshold: 300
    on_press:
      then:
        - switch.turn_off: pump
  
  - platform: esp32_touch
    name: "low_sensor"
    pin: GPIO13
    threshold: 300
    on_release:
      then:
        - if:
            condition:
              binary_sensor.is_off: water_tank_full
            then:
              switch.turn_on: pump
              
  - platform: esp32_touch
    name: "water_tank_full"
    pin: GPIO27
    threshold: 300
    on_press:
      then:
        - switch.turn_off: pump
    on_release:
      then:
        - if:
            condition:
              binary_sensor.is_off: low_sensor
            then:
              switch.turn_on: pump

so the pump still wants to turn on even when the tank is full when the water drops below low_level in the filter

took a quick video

You have two triggers for low_sensor.

Remove the first one.

You also have two for tank full. Again remove the one without the condition.

ah there we go! working as i want now thank you. my dad was the goto guy for this kinda stuff, but he passed away a few years ago, soo ive been trying to learn all this now

i have some hc-sro4 ultrasonic sensors, would those work good for mesuring water level?

Yes they work fine, remembering:

  • they aren’t water proof and they can’t be covered so even if you have a gap between it and high water level, it will eventually fail. They are cheap so this probably won’t be an issue. Maybe use two if reading is critical.
  • they are a 5V device, ESP pins are 3.3V max. I believe a 1K resistor on the signal line will suffice, but if unsure use a level shifter. You will need to power it using VIN pin on the ESP, assuming you are powering via USB and not directly from 3.3V.

so far what i got going, put a dallas temp sensor in it to

1 Like

You have a switch named switch.water_pump from the gpio entity. This switch will be able to turn on/off the pump as long as the water level is between the two sensors.

If you want an override add a template switch.

switch:
  - platform: template
    name: "Enable Auto Fill"
    id: auto_fill
    optimistic: true

then add it to the conditions. When it is shut off you will have full control of the pump using switch.water_pump

  then:
    - if:
        condition:
          and:
            - binary_sensor.is_off: low_sensor
            - switch.is_on: auto_fill