Abstract: A method for controlling the opening of a valve (10) in an HVAC system (100) to regulate the flow ? of a fluid through a thermal energy exchanger (2) of the HVAC system (100) and adjust the amount of energy E exchanged by the thermal energy exchanger (2). According to the method, an energy-per-flow gradient ? E ? ? is determined, and the opening of the valve (10) is controlled depending on the energy-per-flow gradient ? E ? ? . The energy-per-flow gradient ? E ? ? is determined by measuring at consecutive points in time the flow ?1, ?2, through the valve (10), by determining the amounts of energy E1, E2 exchanged by the thermal energy exchanger (2) at these points in time, and by calculating the energy-per-flow gradient ? E ? ? = E 2 - E 1 ? 2 - ? 1 from the flow ?1, ?2, and exchanged energy E1, E2.