Optimisation Of Battery Usage In Smart Grids