Grid-connected energy storage and microgrid energy storage