Switch delay timer override

G’day brains trust,
I’m beating my head against a wall a bit trying to work out how to create an override for an off delay timer. I have a real momentary switch to toggle a water tank pump - gpio input. A ‘virtual’ switch, gpio output controls the relay to the pump which also runs a 6 minute timer (as long as there is at least 5% capacity in the tank).

What’s the simplest way to create an override to bypass the off delay timer so I can empty the tank for periodic cleaning, rather than just keep toggling until it’s empty?

I was thinking of turning to scripting but not sure that will work with the toggle.

Appreciate any ideas :slight_smile:

- platform: gpio
    pin: 
      number: 25
      mode: 
        input: true
        pulldown: true
    name: "Tank Pump Push Button"
    id: pump_pb 
    on_press:
      then:
        - switch.toggle: tank_pump_switch

  - platform: gpio
    name: "Tank Pump Switch"
    id: tank_pump_switch
    pin: GPIO32
    on_turn_on:
      - while:
          condition:
            sensor.in_range:
              id: tank_level
              above: 5.0
          then:
          - switch.turn_off: dht_switch
          - component.suspend: light_level
          - delay: 360s
          - switch.turn_off: tank_pump_switch
    on_turn_off:
      then:
        - delay: 5s 
        - switch.turn_on: dht_switch  
        - component.resume: light_level

I would move the “logic” from the Tank Pump Switch to the Tank Pump Push Button.
That way you can create a new button, either gpio or software button that does not have the delay.

  - platform: gpio
    pin: 
      number: 25
      mode: 
        input: true
        pulldown: true
    name: "Tank Pump Push Button"
    id: pump_pb 
    on_press:
      then:
        - while:
            condition:
              sensor.in_range:
                id: tank_level
                above: 5.0
          then:
          - switch.turn_off: dht_switch      # unsure about the indenting here
          - component.suspend: light_level
          - switch.turn_on: tank_pump_switch
          - delay: 360s
          - switch.turn_off: tank_pump_switch
    on_turn_off:
      then:
        - delay: 5s 
        - switch.turn_on: dht_switch  
        - component.resume: light_level

  - platform: gpio
    name: "Tank Pump Switch"
    id: tank_pump_switch
    pin: GPIO32


button:
  - platform: template
    name: "Empty tank"
    id: empty
    on_press:
      then:
         - while:
             condition:
               sensor.in_range:
                 id: tank_level
                 above: 5.0
            then:
            - switch.turn_on: tank_pump_switch # same here, unsure about indenting, just followed your code
         - switch.turn_off: tank_pump_switch

I don’t know what the light level or dht does, perhaps that is wrong to move those. You need to check that first.

Thanks @Hellis81,
Unfortunately that is not a latching momentary relay, rather just a push and release so I don’t think I can on_presss/on_release like that?

There is some bug/issue when the pump relay turns on it affects the DHT sensor on a seperate GPIO, causes it to throw NANs until rebooted. So that is my work around (dht is used for temp compensation for the water level pressure transducer).