Master's thesis in Renewable energy (ENE500)Energy storage plays a vital role in paving the way for more renewable penetration. The technology is costly, but intelligent solutions regarding dispatch strategies and system design can help reduce the total cost over the projected lifetime of a system. For this thesis, a customizable linear programming algorithm is created within Python to optimize the battery energy scheduling based on generated PV power, electricity cost and load demand. The commercial system optimization tool HOMER is used to verify the code by running simulations based on historic data collected from Nord Pool and UiAs own photovoltaic system. One benefit of the custom made code is its ability to do day-ahead optimization utilizing data from APIs. To obtain forecasted irradiation and temperature data the Solcast API was used as the only paid service for the Python script to ensure market-leading accuracy