Variable demand, dynamic electricity pricing and intermittent renewable energy are sources of variability and uncertainty in smart grid systems. Energy storage devices can be used to absorb these fluctuations and reduce the overall cost. The goal is to find the best policy for storing, buying, selling and using energy in the presence of this variability and uncertainty. This paper explores a comprehensive methodology to study the effect of integrating renewable sources and energy storage in reducing the cost of smart grid operation and the sizing and control of such systems. In this paper, we consider grid-connected dwellings with a solar panel and battery as an example scenario. Numerical results illustrate the performance of our proposed methodology.