Devices in a smart home should be connected in an optimal way; this helps save energy and money. Among numerous optimization models that can be found in the literature, we would like to highlight artificial immune systems, which use special bioinspired algorithms to solve optimization problems effectively. The aim of this work is to present the application of an artificial immune system in the context of different energy optimization problems. Likewise, a case study is performed in which an artificial immune system is incorporated in order to solve an energy management problem in a domestic environment. A thorough analysis of the different strategies is carried out to demonstrate the ability of an artificial immune system to find a successful optima which satisfies the problem constraints.