In this work, a novel algorithm for optimal energy management in smart home devices is developed. This algorithm is based on an intelligent approach to save energy and customer engagement. It preserves customer satisfaction and is more effective than earlier methods. It also lowers energy costs, increases the peak average ratio, and user comfort.