In this paper, a security solution is proposed for IoT smart homes based on constructing behavioral device templates. These templates are being calculated by combining statistical and machine learning techniques according to their network behavior, captured within a smart home. The statistical metrics generated are being processed in order to produce the appropriate features, which are then used for constructing clusters of devices. The main idea relies on the fact that during an abnormal event, the device will be moved away from the center of the cluster, generating an alert that can be further used for proposing mitigation actions. The methodology followed in the proposed approach is given in detail, while validation is performed on a real smart home dataset. This work is part of a transparent cyber security framework developed under EU H2020 Project GHOST.