## 2 System Architecture  
A smart home is the incorporation of automation (not smartness) and intelligent systems (smartness). Devices such as sensors and appliances (automation) are used to monitor and collect environmental information. These data can be stored and analyzed by the intelligent systems, and necessary changes to the environment are implemented through actuators based on the results of the analysis. A smart home architecture should be deployed in a manner that satisfies the requirements of metering home conditions, processing instrumented data, and monitoring home appliances. Generally, a smart home architecture includes the following main elements [13]:  
* Microcontroller-enabled sensors to monitor home conditions. * Database/Data Store to store generated sensory data and cloud services for data analysis and visualization; also serves as a queue for commands being sent to actuators. * Microcontroller-enabled actuators to implement required changes within the environment; microcontrollers send commands to actuators via the cloud services. * Server/API layer to process the received sensory data and store the data in database. In addition to the sensory data, it stores the control commands received from web applications and provides the commands to actuators upon their requests. * Web applications serve as a cloud service to facilitate the measuring and visualization of sensory data, and to enable remote control (via mobile device) of appliances. There are many types of architectures proposed for smart homes. The system-based architecture, proposed by [PERSON] et al. [13], is a scheme of sensors and actuators connected to the microcontroller. Sensors collect information about the environment and the microcontroller makes required changes to the environment through actuators. The physical layer-based architecture, proposed by [PERSON] et al. [14], consists of computer servers, environmental monitoring sensors and detectors, and actuators. The scalable model architecture, proposed by [PERSON] et al. [15], uses a uniform interface model to add or remove the model from the infrastructure of smart homes with less effort. The cloud-based architecture (CloudThings), proposed by [PERSON] et al. [16], aims to speed up the Internet of things (IoT) application,development, and management by providing Internet access to end devices. A simplified cloud-based architecture is illustrated in Figure 1. The internal network consists of appliances, sensors, and actuators. These devices communicate with a gateway located at the network edge which connects the local network to a wide area network such as the Internet. The gateway is a key component of the cloud-based architecture. It supports multiple communication protocols and can easily communicate with end devices [17]; it also has sufficient processing power to perform some data processing before pushing it to the cloud. In addition, the gateway plays a network security layer role for the smart home. Since all communication among the end devices and the outer networks should pass through the gateway, it has the ability to filter the messages before commands make any changes to the end devices which do not possess high level of security and are more vulnerable to attacks [3]. By employing Internet-connected devices, smart homes face privacy and security concerns in general. Interested readers may find a detailed review of these concerns in our previous study [3]. In a smart home, information collected by different resources can be aggregated and processed in the cloud. The cloud is the highest level of the architecture [18] which provides reliable, scalable and autonomous data storage, and the necessary infrastructure for data processing [19; 20]. The cloud-computing model had a good performance in the last decade; however, recently due to the increase in the number of IoT devices uploading data onto the cloud, this model has faced some problems. The most critical problem is the bandwidth limitation.