This article determines the optimal capacity of solar photovoltaic (PV) and battery energy storage (BES) for grid-connected households to minimize the net present cost of electricity. The real-time rule-based home energy management systems using actual annual data of solar insolation, ambient temperature, household electricity consumption, and electricity rates are used in the optimization process. The above-mentioned technique is applied to two system configurations-household with a solar PV and a BES. The uncertainty analysis is implemented using ten years of real data to confirm the optimal results. An accurate cash flow analysis is also presented to illustrate the customer payment in each year during the project lifetime. The sensitivity analysis is conducted by varying the cost and capacity of system components, grid constraint, average daily electricity demand, and retail price of electricity. A typical grid-connected household in South Australia is considered as the case study. A practical guideline is presented for the residential consumers in South Australia to select the optimal PV/BES based on their daily average electricity demand and the available rooftop space for PV installation. Finally, the proposed optimization method is applied to households of other Australian States and a comparison of results is presented.