This paper presents an extension of the standard Universal Plug and Play (UPnP) and the use of a modular architecture with two layers in order to adapt it to the integration of home automation subsystems. Then, this extended pattern is used in the upper layer for controlling and the integration of the subsystems. In the bottom layer, each subsystem uses the most appropriate communication technology to control their devices, and it has an UPnP interface to communicate with other subsystems and to allow user control. Thus, subsystems become modules of the home automation system. This proposal enables the user to easily purchase and replace subsystems from different manufacturers, in order to integrate them transparently, resulting in a more flexible home automation system independently of the manufacturer.