Help to create a new sensor with historical value of another sensor (temperature gradient)

Hello,

I’m trying to create a new sensor which will be the result of this calculation:(last_val_sensor_temperature-new_val_sensor_temperature) / (|time_last_temp - time_new_temp|).

This sensor could be refreshed when the temperature sensor will send the updated information.

I think that the automation won’t be a problem for me but I have no idea how to find the time of the new value, the old value. I think I found the time of the last_updated: states.sensor.station_aurel_temperature.last_changed

I think I can find some information with statistics (may be with change) but I didn’t well understand why I have to fill max_age and other parameter in my case.

Do you have some idea ?
Thank you very much.

You can use the derivative integration to get this information.

Hello @petro,

Ok I didn’t know this integration.
Thank you it should be work like this.