# Calculate daily temperature difference?

Hi,

A couple of years ago I have made my electric water heater (boiler) smart by retrofitting it with a DS18B20 temperature sensor, Raspberry Pi and a Z-Wave smart plug. This way I can control the water heater as a thermostat, like so:

``````- platform: generic_thermostat
unique_id: thermostat_boiler
name: Boiler
heater: switch.boiler                      # Z-Wave plug
target_sensor: sensor.temperature_boiler   # MQTT sensor
min_temp: 25
max_temp: 75
min_cycle_duration:
minutes: 2
cold_tolerance: 2.5
hot_tolerance: -0.5
precision: 0.1
target_temp_step: 0.5
``````

This has proven really reliable with a MQTT broker and some automations. This has saved me quite a bit of money and normally wasted heat already. As the water heater manufacturer says this device consumes about 9 kW/h a day, while I’m doing about 1.5 kW/h a day currently.

To also monitor the course of temperature I also added a Derivative sensor to calculate the temperature differences over time:

This has a time window of 1 hour and unit of °C/h.

However, now I would like to calculate the daily temperature difference or consumption. So I can see if how much of a surplus of power I’m potentially losing. I was thinking of doing this with a Utility Meter, but I’m unsure of what options to use… Or if this is even the best integration to use?

Otherwise I’m still looking forward to optimize my water heater if you have any more ideas. Especially with the current energy prices. Thanks .

Is the Statistics integration worth looking at? It has a distance_absolute value which looks promising.

Thanks for your reply (which I just noticed, sorry about that). That sounds about right, but it isn’t. Let’s look at this graph:

You’ll notice that I lose a certain amount of temperature every day, but the warm water heater can (and will) heat up multiple times a day as well. I think that detail would be lost when I use the `distance_absolute` Statistics integration. Or do you disagree?

Also, I think I would like to calculate the temperature loss/gain per hour also. Because that way I could plan my warm water usage ahead.