I assume you just cut the WIFI section of your code for security and that you see the switch in home assistant.
Put your meter in resistance measuring mode. Measure from the ESP ground pin to D5.
When the switch is
on the resistance should be very small. When
off the resistance should be large or open circuit. There’s a virtual reverse biased diode in the drain - source of the switch that may mess up this measurement so try it with the leads both ways round (red on D5, black on GND, then swap if not getting the result you expect). One of the ways (or maybe both) should give you this result.
The other way is to hook up a simple test circuit with an LED:
+3V DC -----[ 100 Ohms]—>|----- D5
This is the LED: Anode (+) ------>|------ (-) Cathode
The 100 Ohms isnt important, something around that value will do as long as you are using a red, orange or green LED. The forward voltage of a blue LED may be too much for it to light.
The LED should be on when the switch is on.
Assuming all this works you may have too much stray capacitance in the circuit. Try shortening the the connection between D5 and the foil.
Maybe try putting the circuit in place and power cycling the washing machine. It might have a calibration for the touch sensor on start up.
One last test. With the circuit in place and the switch on, touch the ground pin of the ESP module to the cold water tap.
Hopefully it isn’t a resistive touch sensor… The foil will always short it.