Energy communities (EC) play a crucial role in driving the transition towards renewable energy sources within urban areas. This study focuses on the implementation of EC within linear mass housing in Rome, with particular attention given to the Tor Bella Monaca district. The research proposes and simulates six energy community distinct scenarios using the Urban Modelling Interface (UMI) and Simulink in order to advance understanding of this topic. These scenarios evaluate the integration of photovoltaic systems, heat pumps, and energy storage systems to determine their comprehensive effect on renewable energy production, CO2 emission reduction, and the enhancement of self-consumption. The study findings show that higher electrification levels in an energy community lead to greater consumption of renewable energy and reduced reliance on the grid. The integration of heat pumps and energy storage further enhances energy consumption and self-sufficiency creating sustainable energy models in urban environments. With an increase in self-consumption factor and self-sufficiency factor of 0.15–0.30 and 0.11–0.13, respectively, depending on the scenario. The research highlights the importance of a thorough assessment of technology sizing and integration in order to enhance self-consumption and decrease CO2 emissions. It proposes investigating the incorporation of both thermal and electrical storage to optimize self-consumption. Finally, the simulated scenarios underwent flexibility analyses to determine the precise energy flow capacity and the optimal setting identified through economic evaluation.