A device for heating water intended to supply a room with hot water, the device comprising: - a water heater comprising: - a heating member for heating water contained in the water heater, - a temperature probe for measuring the temperature of the water contained in the water heater; and - a calculation and regulation member connected to the heating member and to the temperature probe to regulate the heating member according to a temperature setpoint, the calculation and regulation member being connected to a renewable energy system, for example a photovoltaic system, and to an electrical network in order to deliver energy to the heating member, the temperature setpoint having a base value T1, and a surplus value T2 greater than or equal to the base value T1, when for a day j a surplus of energy produced by the renewable energy system is available the calculation and regulation member is adapted to determine the temperature setpoint for day j such that: when a prediction of the energy Epvj+1 produced by the renewable energy system on the following day j+1 is greater than the prediction of the energy consumption of the room on that day, the temperature setpoint for the same day j is fixed at the base value T1, and when a prediction of the energy produced by the renewable energy system on the following day j+1 is lower than the prediction of energy consumption on that day, the temperature setpoint for the same day j is set at the value of surplus T2 so as to heat the water contained in the water heater thanks to the surplus energy produced by the renewable energy system available on day j. - a water heater comprising: - a heating member for heating water contained in the water heater, - a temperature probe for measuring the temperature of the water contained in the water heater; and - a calculation and regulation member connected to the heating member and to the temperature probe to regulate the heating member according to a temperature setpoint, the calculation and regulation member being connected to a renewable energy system, for example a photovoltaic system, and to an electrical network in order to deliver energy to the heating member, the temperature setpoint having a base value T1, and a surplus value T2 greater than or equal to the base value T1, when for a day j a surplus of energy produced by the renewable energy system is available the calculation and regulation member is adapted to determine the temperature setpoint for day j such that: when a prediction of the energy Epvj+1 produced by the renewable energy system on the following day j+1 is greater than the prediction of the energy consumption of the room on that day, the temperature setpoint for the same day j is fixed at the base value T1, and when a prediction of the energy produced by the renewable energy system on the following day j+1 is lower than the prediction of energy consumption on that day, the temperature setpoint for the same day j is set at the value of surplus T2 so as to heat the water contained in the water heater thanks to the surplus energy produced by the renewable energy system available on day j. when a prediction of the energy Epvj+1 produced by the renewable energy system on the following day j+1 is greater than the prediction of the energy consumption of the room on that day, the temperature setpoint for the same day j is fixed at the base value T1, and when a prediction of the energy produced by the renewable energy system on the following day j+1 is lower than the prediction of energy consumption on that day, the temperature setpoint for the same day j is set at the value of surplus T2 so as to heat the water contained in the water heater thanks to the surplus energy produced by the renewable energy system available on day j.