The rapid evolution of technology and urban population growth has led to a significant increase in energy consumption, particularly in electricity production. However, the ability to meet energy demands, especially during peak periods, is constrained by various factors including environmental concerns, technological limitations, and economic constraints. Effective energy management strategies are crucial to mitigate these challenges and ensure a sustainable energy future. One promising approach is the implementation of demand response programs. In this context, we explore the potential of Home Energy Management Systems (HEMS) leveraging modern Internet of Things (IoT) technology. HEMS systems are at the forefront of research and development in the field of smart grids (SGs), offering capabilities in demand-side management and power availability control. These systems achieve efficient energy usage by optimizing the operation of home appliances (HAs). To further enhance the performance of HEMS, this study introduces a novel metaheuristic known as the Grey Wolf and Crow Search Optimization Algorithm (GWCSOA). This algorithm is employed to determine the optimal scheduling of HAs within the HEMS framework. Additionally, we utilize MATLAB and ThingSpeak modules to implement and test the HEMS design. The proposed HEMS, integrated with GWCSOA, demonstrates remarkable capabilities in reducing daily power costs, minimizing the peak-to-average ratio (PAR), and enhancing consumer satisfaction. The findings of this study indicate that the devised system holds the promise of substantially diminishing both power expenses and microgrid emissions. Through the optimization of Home Energy Management Systems (HEMS) operations, this methodology plays a vital role in realizing a sustainable urban energy ecosystem. This aligns seamlessly with the overarching objectives of combating climate change and securing the enduring sustainability of our cities. The proposed HEMS, integrated with GWCSOA, demonstrates remarkable capabilities in reducing daily power costs by an average of 25.98 %, minimizing the peak-to-average ratio (PAR) by 30 %, and enhancing consumer satisfaction. The outcomes of this research reveal that the developed system has the potential to significantly reduce both power costs and microgrid emissions. By optimizing HEMS operations, this approach contributes to achieving a sustainable urban energy ecosystem, aligning with the goals of addressing climate change and ensuring the future sustainability of our cities.