Energy costs for Microsoft’s 120 building main-campus are very high, particularly because of the almost exclusive usage of electric heating there. About 10% of these are demand charges (a peak-usage surcharge), and become very pronounced in the winter. To reduce these, we have modeled building energy consumption to predict demand peaks using random forest and boosted trees regression as implemented in the randomForest and gbm packages (sometimes together with caret) and then piloted in our operations center. Now in a second phase more advanced models were developed to allow this peak-flattening without manual intervention. Transitioning a predictive-model to a command-and-control model like this was complex, and capturing the physical reality required the use of multiple cascaded models, also using tree-based regression techniques. Optimization (to find the best control parameters) and simulation (to gauges the overall impact of intervention) were used and the problems typical for dynamical systems (stabilization, non-convergence, etc.) had to be overcome; these will be addressed in the talks. All of the development and modelling work was done in R and Shiny using R-Studio and later RTVS, afterwards the R-code and ggplot2 plots were deployed to various platforms including Azure ML, PowerBI and R Services for SQL Server.