Energy Management in Buildings Using Photovoltaics