ESPHome Trigger if Wifi disconnects

ESPHome Trigger if Wifi disconnects
I want to control water valves with relays on a Wmos mini with Esphome. Therefore, its important to ensure that the waterflow definitely stops if e.g. the Wifi connection to the home assistant breaks down. How can I implement something like

In my esp.yaml

switch:
  - platform: gpio
    pin: GPIO13   #D0
    name: "IN1" 
    id: IN1
  - platform: gpio 
    pin: GPIO12  #D6
    name: "OUT2"
    id: IN2
  - platform: gpio 
    pin: GPIO14  #D5
    name: "OUT3" 
    id: IN3
  - platform: gpio 
    pin: GPIO16  #D5
    name: "OUT4" 
    id: IN4

use condition:

....
      if:
        condition:
          wifi.connected:
            then:
              - .....

or if you want to check it HA is connected:

.....
          - if:
              condition:
                api.connected:
              then:
                - .....

Hello,
I saw this condition, but I want to trigger if wifi.disconnected. Is something like !wifi.connected possible?

You can probably use something like this:

interval:
  - interval: 1min
    then:
      if:
        condition:
          not:
            wifi.connected:
        then:
          ...

I have implemented wifi connect and disconnect events at https://github.com/esphome/esphome/pull/3639