Electrifying the energy system with heat pumps and electric vehicles is a strategy of many countries to reduce CO2 emissions. Large electrification, however, poses several new challenges for the electricity system, particularly in combination with a simultaneous substitution of nuclear power plants by volatile renewables such as photovoltaics. The increasing consumption of electricity and the growing number of installed photovoltaic systems are pushing the existing electrical grid to its limits. Today's grid must be expanded with smart controllers and their components regulated. For this purpose, an understanding of flexible participants such as boilers, heat pumps and electric vehicles, and new production plants such as photovoltaic systems must be built up. The aim of this paper is to present the flexibility potential of the municipality and the proposed energy scheduler for flexible shifting of loads to the optimal location considering defined constraints. The results are used to calculate the new parameters for the locally installed energy management systems, which control appliances according to the scheduler setpoints, to utilise flexibilities for peak shaving optimally.