Energy management (EM) is a critical strategy that spans the production and consumption of electricity, enhancing the stability of the electricity network. Smart grid technology significantly improves the electrical system's energy efficiency (EE), facilitating a transformation from a conventional power grid (PG) to a smart PG. This paper presents a key strategy for modeling the EE of the smart grid tailored to domestic demand, establishing smart coordination between domestic demand, energy production, and storage to reduce energy waste and costs. Our model integrates various energy sources, including renewable energy (RE), photovoltaic (PV) systems, wind power, and an energy storage system (ESS), interconnected with the PG. The model's structure ensures the coordinated flow of electricity in a residential house through an optimal control method (OCM). To develop a robust closed-loop control model, we employ Demand Response (DR) schemes within the Real-Time Electricity Pricing (RTEP) framework. We construct a dynamic model of the ESS to compute the System Performance Index (SPI), corresponding to energy costs. To enhance our model, we introduce a Dynamic Distributed Energy Storage Strategy (DDESS). Additionally, we introduce a novel optimization algorithm inspired by the behavioral patterns of wild mice, called the Wild Mice Colony (WMC). By analyzing the targeted and advantageous behaviors of wild mice in colonies, we propose that these behaviors can serve as a model for addressing complex, uncertain problems. This strategy is highly advantageous, capable of reducing total energy consumption (EC) from the main grid by over 100 % of the load demand, optimizing the energy system, and ensuring synchronization. The performance of DDESS optimizes energy flow (EF) during the repayment plan, leading to minimized EC costs from the PG.