Energy storage off-grid and grid-connected control strategies