## 4 Discussion and Conclusions  
In this paper, we have shown how to integrate user-created routines involving different appliances' activations in the Digital Twin of a smart home able to monitor and simulate smart home behavior in terms of energy consumption. To this purpose, we designed and implemented an Machine Learning-based solution for the recognition of the operation modes of appliances available in a hypothetical home. Then, functionalities were developed to help users avoid undesired situations and choose more efficient routines or better combinations of them, thus eventually enhancing consumption awareness. A sociotechnical approach was adopted to developing the Digital Twin. Indeed, the literature on Digital Twins often lacks consideration of the interaction with the user and the needs the user might satisfy with a Digital Twin. According to the classification of maturity levels for Digital Twins proposed in [39], Digital Twins at level 4 foresee users-in-the-loop  
Figure 11: Details of the _Party time_ routine, which causes the power consumption to exceed the maximum limit. Figure 14: Results of simulating the addition of the _Heavy duty wash_ routine to the system. Figure 12: Results of simulating the _Party time_ routine. for the effective and secure operation and control of the Digital Twin, but most Digital Twins discussed in the literature are at levels 0-2 of maturity (modeling and simulation), while only few of them start the integration with real-time data streams (level 3), due to the significant challenge of data gathering, filtering, and processing in real time [40]. Several Digital Twins have been proposed for building automation and smart home control, but the role of the end user in the modification of smart home behavior (and consequent Digital Twin behavior) has not been adequately explored. On the other hand, End-User Development methods to create routines for smart homes have been studied for many years and have been implemented recently in commercial virtual assistants. Integrating these End-User Development methods in a Digital Twin is a contribution towards achieving Digital Twins at level 4: that is, enabling two-way data integration and interaction [39]. Several open challenges will guide our future research in this field and further system development. For the sake of the experimentation of the simulation modality, a set of routines has been built in the system, and data about appliances' status at different times of the day have been extracted from open-source datasets applying machine learning. In addition, the Digital Twin can only predict energy consumption for the current day. Future versions should enable the system to predict energy consumption for several days ahead, and also to view consumption history for the previous days. This would allow the system to provide more precise recommendations and better handle conflicts among routines. For example, if the user is planning to go on vacation for a week, the Digital Twin could advise to set the boiler to the _holiday_ mode and to turn off the fridge. Moreover, the Digital Twin should be able to handle the manual activation of appliances by end users by automatically detecting their state changes. Indeed, the Digital Twin could monitor the manual activations of appliances and their duration, and use this information to provide suitable recommendations to automate the activations or modify existing routines. For instance, if the user starts the computer daily at 9:00 a.m., the Digital Twin could propose to automate this activation. Suppose the computer stays on for 8 h on average. In that case, the Digital Twin could use this information to anticipate whether this would cause any conflict with existing routines and avoid them before they occur. To carry out a long-term experimentation of the system operation and collect feedback from users about their experience, we plan as future work to install smart devices and the Digital Twin in a few sample homes.