There is a power deficit in Uppsala's power grid. Municipal companies have an obligation to contribute with solutions to the power deficit. Skolfastigheter AB have therefore installed an environmentally friendly salt water battery in one of their properties. The goal of this project is to create an algorithm for controlling the battery so that it cuts power peaks at a preschool in Uppsala. The algorithm is created based on economical, environmental, and political aspects. A model of the battery is constructed in which technical specifications for the real battery are used. The model is tested using historical power usage data from one of Skolfastigheter AB's preschool properties. The resulting model successfully cuts the facility's power peaks as intended. The model succeeds even when the input data are varied. The algorithm is also applied in reality and controls the battery via a programmable logic controller (PLC). The goal of cutting power peaks is also met with the PLC. Simulation of the battery cuts power peaks more optimally than when the algorithm is implemented in reality. To improve the model, data from more preschools as well as possibilities to perform more experiments are required. The usage of programmable power storage is today not economically profitable. Batteries do however contribute to reaching Uppsala municipality's environmental and climate goals. Batteries also contribute to a more robust energy system where fossil power reserves can be avoided