Method, implemented by computer-based means, for controlling a heating system of a building, over a period of time, comprising, following a definition of at least one time interval and of at least a first setpoint temperature to be reached during said time interval: - building a plurality of programs, referred to as heating programs, such that, for each heating program, an arbitrary temperature within a temperature range that includes the first setpoint temperature is associated with the time interval, said arbitrary temperatures associated with each heating program being different for each heating program, - creating a table in which each heating program is associated with a power consumption related to the power needed to reach the value of the arbitrary temperature associated with said heating program, - determining an optimal heating program, such that said optimal heating program complies with a user command, - sending the optimal heating program to be applied to the input of the heating system characterised in that: - the following are defined: -- three time intervals, corresponding to a comfort period, an absence period and a night period, -- a temperature triplet (T1, T2 and T3) comprising a comfort setpoint temperature, an absence setpoint temperature and a night setpoint temperature, these temperatures being respectively associated with said periods, and - three arbitrary temperatures, within a temperature range that includes the three comfort, absence and night setpoint temperatures, the temperature triplet (T1, T2 and T3) is associated with each heating program, such that each heating program is unique, that an arbitrary temperature is associated with each of the three time intervals, and that the difference between two arbitrary temperatures is equal to a predefined step, - the table comprising said heating programs, each heating program being associated with a power consumption related to the power needed to reach each of the three arbitrary temperatures associated with each of the three time intervals. - building a plurality of programs, referred to as heating programs, such that, for each heating program, an arbitrary temperature within a temperature range that includes the first setpoint temperature is associated with the time interval, said arbitrary temperatures associated with each heating program being different for each heating program, - creating a table in which each heating program is associated with a power consumption related to the power needed to reach the value of the arbitrary temperature associated with said heating program, - determining an optimal heating program, such that said optimal heating program complies with a user command, - sending the optimal heating program to be applied to the input of the heating system - the following are defined: -- three time intervals, corresponding to a comfort period, an absence period and a night period, -- a temperature triplet (T1, T2 and T3) comprising a comfort setpoint temperature, an absence setpoint temperature and a night setpoint temperature, these temperatures being respectively associated with said periods, and - three arbitrary temperatures, within a temperature range that includes the three comfort, absence and night setpoint temperatures, the temperature triplet (T1, T2 and T3) is associated with each heating program, such that each heating program is unique, that an arbitrary temperature is associated with each of the three time intervals, and that the difference between two arbitrary temperatures is equal to a predefined step, - the table comprising said heating programs, each heating program being associated with a power consumption related to the power needed to reach each of the three arbitrary temperatures associated with each of the three time intervals. -- three time intervals, corresponding to a comfort period, an absence period and a night period, -- a temperature triplet (T1, T2 and T3) comprising a comfort setpoint temperature, an absence setpoint temperature and a night setpoint temperature, these temperatures being respectively associated with said periods, and - three arbitrary temperatures, within a temperature range that includes the three comfort, absence and night setpoint temperatures, the temperature triplet (T1, T2 and T3) is associated with each heating program, such that each heating program is unique, that an arbitrary temperature is associated with each of the three time intervals, and that the difference between two arbitrary temperatures is equal to a predefined step, - the table comprising said heating programs, each heating program being associated with a power consumption related to the power needed to reach each of the three arbitrary temperatures associated with each of the three time intervals.