How much do you need/want to build the controller for this yourself?
Aren't there hydrid inverters out there from the big brands (ABB, Fronius, etc.) that do what you want?
With the panels and good sun-light the payback time is 10 years or longer - over here in northern europe at least.
If you add to that a li-ion battery pack for 10 keur that will make the break-even time even longer?
So I guess you need to decide if you want to do it because of economy or because of the environment, or as a hobby/project - or a bit of everything...