Derivative
The derivative
platform creates a sensor that estimates the derivative of the values provided by a source sensor.
Derivative sensors are updated upon changes of the source.
Configuration
To enable Derivative Sensor in your installation, add the following to your configuration.yaml
file:
# Example configuration.yaml entry
sensor:
 platform: derivative
source: sensor.current_speed
Configuration Variables
 source
(string)(Required)
The entity ID of the sensor providing numeric readings
 name

(string)(Optional)
Name to use in the frontend.
Default value:
source entity ID meter
 round

(integer)(Optional)
Round the calculated derivative value to at most N decimal places.
Default value:
3
 unit_prefix

(string)(Optional)
Metric unit to prefix the derivative result (Wikipedia). Available symbols are “n” (1e9), “µ” (1e6), “m” (1e3), “k” (1e3), “M” (1e6), “G” (1e9), “T” (1e12).
Default value:
None
 unit_time

(string)(Optional)
SI unit of time of the derivative. Available units are s, min, h, d.
Default value:
h
 unit
(string)(Optional)
Unit of Measurement to be used for the derivative.
 time_window

(time)(Optional)
The time window in which to calculate the derivative. This is useful for sensor that output discrete values. By default the derivative is calculated between two consecutive updates.
Default value:
0
Temperature example
For example, you have a temperature sensor sensor.temperature
that outputs a value every few seconds, but rounds to the nearest half number.
That means that two consecutive output values might be the same (so the derivative is Δy/Δx=0
because Δy=0
!)
However, the temperature might actually be changing over time.
In order to capture this, you should use a time_window
, such that immediate jumps don’t result in high derivatives and that after the next sensor update, the derivatives doesn’t vanish to zero.
An example configuration that uses time_window
is
sensor:
 platform: derivative
source: sensor.temperature
name: Temperature change per hour
round: 1
unit_time: h
time_window: "00:30:00" # we look at the change over the last half hour