Photovoltaic (PV) systems are becoming increasingly popular, especially in residential buildings. However, the high penetration of prosumer PV micro-installations can have a negative impact on the operation of distribution networks due to the low self-consumption of the energy produced. One way to mitigate this problem is to use a residential energy storage system (RESS) and load shifting under a demand-side management (DSM) scheme. Energy management systems (EMSs) are used to control the operation of RESSs and to implement DSM. There are two main categories of EMSs: rule-based and optimization-based. Optimization-based EMSs provide better results than rule-based EMSs but can be computationally expensive. This article proposes an optimization-based EMS that is designed specifically for residential buildings. The proposed home energy management system (HEMS) uses a particle swarm optimization method to maximize the prosumer’s financial neutrality, which is calculated based on dynamic energy prices. Simulation-based evaluation using the measurements taken in a building equipped with a PV source, RESS, and shiftable loads shows the improved performance of the proposed HEMS compared to rule-based RESS control. The results show that the designed HEMS increases self-consumption, thus reducing the impact of the prosumer’s PV micro-installations on the distribution grid.