Control of the energy grid