A smart hybrid energy system (SHES) is presented using a combination of battery, PV systems, and gas/diesel engines. The economic/environmental dispatch optimization algorithm (EEDOA) is employed to minimize the total operating cost or total CO2 emission. In the face of the uncertainty of renewable power generation, the constraints for loss-of-load probability (LOLP) and the operating reserve for the rechargeable battery are taken into account for compensating the imbalance between load demand and power supplies. The grid-connected and islanded modes of SHES are demonstrated to address a low-carbon community. For forecasting load demand, PV power, and locational-based marginal pricing (LBMP), the proper forecast model, such as long short-term memory (LSTM) or extreme gradient boosting (XGBoost), is implemented to improve the EEDOA. A few comparisons show that (i) the grid-connected mode of SHES is superior to the islanded-connected mode of SHES due to lower total operating cost and less total CO2-eq emissions, and (ii) the forecast-assisted EEDOA could effectively reduce total operating cost and total CO2-eq emissions of both modes of SHES as compared to no forecast-assisted EEDOA.