In the last years energy consumption in the home environments has increased considerably. There is an interest to provide users with means to reduce their energy consumption. Introducing a Home Energy Management System (HEMS) into user residences might provide the necessary tools to reduce and optimize the energy consumption in home environments. The main element of HEMS is the home gateway. In this paper, a home gateway suitable for HEMS is presented. The home gateway proposed uses rules to implement the home energy management system. The rules can be downloaded though web services from a rule server. Furthermore, web services are used to provide modularity to the home gateway by enabling the deployment of the different logical components into different devices, if necessary