In this paper, a novel optimization tool is developed for a customer including new devices which are photovoltaic power generation (PV) and storage battery (BT). A treatment of thermal constraints of BT is introduced in the formulation for energy management system (EMS). Especially, thermal constraints are important to achieve the stable operation of demand-side energy system. The authors carry out the operation planning simulation by using nonlinear programming method. In latter section, a real-time simulation tool for the EMS is introduced by using MATLAB/Simulink SimPowerSystems.