**2. Materials and Methods**

Figure 1 provides a functional overview of the generalized structure of an HEMS. As defined above, the primary objective of the HEMS is to fulfill the electricity, heat, and mobility demand of the household. For this purpose, the HEMS retrieves historical load profiles from an internal database and various other input data, e.g., user preferences, weather, and price forecasts from external sources. Then, an optimizer inside the HEMS calculates cost-optimal operating strategies for all controllable devices. Based on those operating schedules, the HEMS buys and sells energy on the energy market. Afterwards, the HEMS can offer deviations from the cost-optimal operating strategy as flexibility to SOs via a flexibility platform.

## *2.1. Input Data, Generation, and Consumption Forecast*

The HEMS receives data from various parties, e.g., household inhabitants, forecast providers and weather stations. In an initial configuration step, household inhabitants insert device parameters like the charging station's maximal charging power, or EV's battery capacity, etc. More frequently, inhabitants update operational constraints, such as the daytime when an EV needs to be fully charged or the room temperature they find comfortable. Besides those user inputs, the HEMS is fed with different forecasts such as the upcoming weather conditions and expected energy prices. Finally, the optimization is triggered whenever new input data arrives or a certain amount of time has passed.
