Even while living circumstances and construction techniques have generally improved, occupants of these spaces frequently feel unsatisfied with the sense of security they provide, which leads to looking for and eventually enacting ever-more-effective safety precautions. The continuous uncertainty that contemporary individuals experience, particularly with regard to their protection in places like cities, prompted the field of computing to design smart devices that attempt to reduce threats and ultimately strengthen people’s sense of protection. Intelligent apps were developed to provide protection and make a residence a smart and safe home. The proliferation of technology for smart homes necessitates the implementation of rigorous safety precautions to protect users’ personal information and avoid illegal access. The importance of establishing cyber security has been recognized by academic and business institutions all around the globe. Providing reliable computation for the Internet of Things (IoT) is also crucial. A new method for enhancing safety in smart home environments’ sustainability using IoT devices is presented in this paper, combining the Whale Optimization Algorithm (WOA) with Deep Convolutional Neural Networks (DCNNs). WOA-DCNN hybridization seeks to enhance safety measures by efficiently identifying and averting possible attacks in real time. We show how effective the proposed approach is in defending smart home systems from a range of safety risks via in-depth testing and analysis. By providing a potential path for protecting smart home surroundings in a world that is growing more linked, this research advances the state of the art in IoT security.