You’re looking for an electric solenoid
however you can also achieve this with air pumps if you get the gravity down
but I don’t see why you want to overwater to collect waste water.
you should instead lookup a DIY Auto Watering system that uses float valves and allows the roots to consume...