## 2 Proposed HEMS Framework
The V2H system adds an additional layer of flexibility by allowing electric vehicles to not only charge but also supply power back to the home when necessary, ensuring a reliable power supply even during outages or times of low energy production. A significant aspect of this HEMS is its ability to acquire and monitor data in real-time. The system continuously collects and processes information about the home's energy demand, the power generated by the PV panels and wind turbines, and the current electricity price based on TOU pricing. TOU pricing is crucial for the system's operation, enabling the HEMS to make smart decisions about when to use stored energy, when to rely on real-time generated power, and when to shift the operation of specific appliances to times when electricity is more affordable. This integration with DR strategies ensures that energy costs are minimized while maximizing the use of renewable energy. Figure 1: Proposed Framework of the HEMS. The HEMS demonstrates its versatility by managing different types of household appliances, which are categorized as shiftable, elastic, and fixed. Shiftable appliances, namely dishwashers and clothes dryers, are scheduled to operate during off-peak hours or when energy is plentiful, reducing strain on the grid and lowering costs. Elastic appliances, including air conditioners and water heaters, have their energy consumption adjusted by the HEMS to align with the availability of renewable energy and price signals. Fixed appliances, namely lighting and TVs, are monitored to ensure they operate efficiently within the overall energy management strategy. Figure 2 provides a detailed diagram that outlines the methodology of the proposed integrated smart HEMS. AI techniques are integrated into the HEMS to optimize energy management strategies dynamically. Additionally, AI-based anomaly detection improves system reliability by identifying and addressing potential issues before they escalate. A practical application of the HEMS framework can be seen in a case study of a home in Liaoning Province, China. The framework is structured into three main sections: system configuration, methodology, and findings evaluation, each providing a clear view of the system's components, operational strategy, and outcomes. The system configuration section illustrates the core components of the home energy system. The home primarily relies on main RESs, namely WTs and PV panels, which generate electricity based on weather conditions and the availability of wind and sunlight. These renewable sources are essential for powering residential loads, contributing to a sustainable and energy-efficient household. To ensure continuous energy supply, even when the RES are insufficient, the system is supported by a backup system that includes batteries, V2H technology, and FCs. The V2H integration allows electric vehicles not only to charge from the grid but also to supply power back to the home when needed, providing additional flexibility and resilience. The methodology section is divided into two stages: the optimization of individual renewable energy sources and the development of an adaptive AI-based smart HEMS. In the first stage, the system focuses on modeling renewable energy sources, assessing energy demand effectively, conducting resource assessments, selecting appropriate technologies, and gathering weather data. This stage is crucial for understanding the potential of renewable resources at the specific location of the home and ensuring that energy generation is optimized to meet the household's needs. The second stage involves the implementation of an adaptive AI-based HEMS that incorporates user preferences, assesses operating costs, determines decision variables, conducts sensitivity analysis, and selects optimal technologies. This adaptive approach ensures that the HEMS can dynamically respond to changing conditions, maintaining optimal performance and cost efficiency.