Last button pressed is no issue, and is trivial to do (particularly using a micro-controller, which could also easily do all the timing functions as well).
However, I would suggest that's a VERY poor (and mostly useless) solution.
Surely what you need to know is if the valve is open or closed, not if a button has been pressed (and you have no idea if the valve is open or closed, or indeed if it's moved) - you NEED sensors on the valve, or better still use a valve that already has that capability.
There's a standard control system for valves, allowing lot's of options - as you can imagine, mostly to do with reliability.