What you need to do is learn what a finite state machine (FSM) is.
An FSM is a way of having the Arduino in one of a finite number of states, such as "light flashing", or "letting water in", etc.
I have written a reasonable (IMHO) tutorial here: http://hacking.majenko.co.uk/finite-state-machinehttps://hackingmajenkoblog.wordpress.com/2016/02/01/the-finite-state-machine/