Home energy management systems (HEMS) in microgrids have played a vital role in revolutionizing the power system. Consumer participation in microgrid load scheduling is a key feature of modern HEMS. Much research has been conducted on minimizing the peak-to-average ratio and cost optimization. This paper proposes a community-based HEMS model incorporating dynamic pricing to achieve these objectives. The loads are dynamically clustered, a process where similar loads are grouped together based on their characteristics and scheduled for one day in 10-minute intervals. The resulting load profile is compared against existing algorithms, demonstrating notable improvements. Moreover, the application of dynamic pricing to the optimized load profile, leveraging resources such as battery-powered electric vehicles, solar PV, battery storage, and the primary grid or main grid, has shown promising results. Priority is given to the renewable and local energy storage to minimize cost. Three case studies, each considering weather-driven variations in appliance usage, demonstrate the potential for significant cost reductions. The surplus energy is returned to the primary grid, while in cases of insufficient microgrid supply, the power is drawn from the primary grid. Net metering with smart meters is used to ensures the accuracy and fairness of the billing process, providing consumers with a transparent and reliable system. The results show a substantial cost reduction of up to 36.2% in the spring and 7.6% in the summer and winter seasons, offering a hopeful outlook for the future of energy management in microgrids.