We consider a system where inelastic demand for electric power is met from three sources: the grid, in-house renewables such as wind turbines or solar panels, and an in-house energy storage device. In our setting, power demand, renewable power supply, and cost for grid power are all time-varying and stochastic. Further, there are limits and efficiency issues for charging and discharging the energy storage device. Under such a scenario, at all times across an infinite horizon, we need to determine how to split power demand among the various sources. For that, we formulate an optimization framework that minimizes the long-run average operational cost subject to satisfying demand and meeting capacity constraints. To determine the optimal actions, we construct a dynamic program with parameters estimated from a training data set (that uses real demand, supply and cost data). As the dynamic program is computationally intensive for large-scale problems, we explore an algorithm based on approximate dynamic programming, and apply it to a test data set. We compare its performance against other heuristics that may or may not use the training data. In addition, we ascertain the value of storage as well as the value of installing a renewable source.