You need to set a flag when the button is pressed then check the flag so as not to reopen the valve until the button is released and flag reset.
If button not pressed
Flag = false
If button pressed and flag is false
Flag = true
Open valve for time required
Weedpharma