OptiFLIDS is a novel intrusion detection system (IDS) approach designed to secure critical IoT environments, such as smart homes and industrial systems. It utilizes federated learning (FL) to perform collaborative model training while preserving data privacy. OptiFLIDS applies pruning techniques during local training to reduce model complexity and energy consumption, and incorporates a custom aggregation method to handle differently pruned models due to non-IID data distributions. Experiments on three IoT IDS datasets—TON_IoT, X-IIoTID, and IDSIoT2024—show that OptiFLIDS improves energy efficiency while maintaining robust detection performance.