Efficient operation of energy systems with substantial amount of renewable energy production is becoming increasingly important. Renewables are dependent on the weather conditions and are therefore by nature volatile and uncontrollable, opposed to traditional energy production based on combustion. The "smart grid" is a broad term for the technology for addressing the challenge of operating the grid with a large share of renewables. The "smart" part is formed by technologies, which models the properties of the systems and efficiently adapt the load to the volatile energy production, by using the available flexibility in the system. In the present thesis methods related to operation of solar energy systems and for optimal energy use in buildings are presented. Two approaches for forecasting of solar power based on numerical weather predictions (NWPs) are presented, they are applied to forecast the power output from PV and solar thermal collector systems. The first approach is based on a developed statistical clear-sky model, which is used for estimating the clear-sky output solely based on observations of the output. This enables local effects such as shading from trees to be taken into account. The second approach to solar power forecasting is based on conditional parametric modelling. It is well suited for forecasting of solar thermal power, since is it can be make non-linear in the inputs. The approach is also extended to a probabilistic solar power forecasting model. The statistical clear-sky model is furthermore used as basis for a method for correction of global radiation observations. This method can used for correction of typical errors, for example from shading trees or buildings. Two methods for ecient energy use in buildings are presented in the last part of the thesis. First a method for forecasting of the heat load in single-family houses based on weather forecasts is presented. A model is identied, which works well when applied to forecast the heat load for sixteen single-family houses. The model adapts to the individual houses and needs only no specic information about the buildings. Finally a procedure for identication of a suitable model for the heat dynamics of a building is presented. The applied models are greybox model based on stochastic dierential equations and the identication is carried out with likelihood ratio tests. The models can be used for providing detailed information of the thermal characteristics of buildings and as basis for optimal control for exible heating of buildings.