Need help for Pump Control

Hello,

i try to control a pump with two switches.

if the box become full level (water max is State On) the pump should start and if the water level becomes low (water min State ist OFF) the pump should switch off
Who can help me to realize it in esphome .
I tried

binary_sensor:
  - platform: status
    name: "ESP-Keller-02 System Status"

  - platform: gpio
    name: "water_min"
    id: "water_min"
    pin:
      pcf8574: pcf8574_hub
      # Use pin number 0
      number: 4
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: INPUT
      inverted: true
    on_turn_off:
    - switch.turn_off:pump
    

  - platform: gpio
    name: "water_max"
    id: "water_max"
    pin:
      pcf8574: pcf8574_hub
      # Use pin number 0
      number: 5
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: INPUT
      inverted: true
    on_turn_on:
    - switch.turn_on:pump

switch:
  - platform: gpio
    pin: D7
    id: pump
    name: "pump"
    inverted: true 

What happened when you tried?

Everything i tried he said its not allowed

Why i can use on or off and not only on state ?
Does someone post a Example for me ?

ok with much try and error i find a solution thats works for me.
Mybe someóne has a better way:

binary_sensor:
  - platform: status
    name: "ESP-Keller-02 System Status"

  - platform: gpio
    name: "water_min"
    id: "water_min"
    pin:
      pcf8574: pcf8574_hub
      # Use pin number 0
      number: 4
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: INPUT
      inverted: false
    on_state: 
       then:
        - switch.turn_off: pump 

  - platform: gpio
    name: "water_max"
    id: "water_max"
    pin:
      pcf8574: pcf8574_hub
      # Use pin number 0
      number: 5
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: INPUT
      inverted: true
    on_state: 
      then:
        - switch.turn_on: pump    
     

switch:
  - platform: gpio
    pin: D7
    id: pump
    name: "pump"
    inverted: true
1 Like

I am glad you fixed it because with the level of info you were giving, no one else could have. I suggest you read this some time. How to help us help you - or How to ask a good question

Thank you for your answer

me me its very difficult to understand automations in esphome.
Why can’t i use “on tate On” or “on state off” in binary sensors.
If i try to catch the state x via lambda the debugger says every time “not allowed”
Ther is no good explain and you can’t find any examples of other users

I really do not have that depth of knowledge sorry. All I can do is point to https://esphome.io/guides/automations.html and all the pages it links to.

Plus looking at sample configs on this forum, and here and here