Derivative
The derivative (Wikipedia
For sensors that reset to zero after a power interruption and need a “non-negative derivative”, such as bandwidth counters in routers, or rain gauges, you can now use this integration directly. Ensure that the input sensor has a total_increasing
state class, as this is necessary for the integration to handle resets correctly without registering significant changes in the derivative sensor.
配置
要将 Derivative helper 添加到您的 Home Assistant 实例中,请使用此 My 按钮:
手动配置步骤
如果上述 My 按钮不起作用,您也可以手动执行以下步骤:
-
浏览到您的 Home Assistant 实例。
-
转到
设置 > 设备与服务。 -
在屏幕顶部,选择标签:Helpers。
-
在右下角,选择
创建助手 按钮。 -
从列表中选择 Derivative。
-
按照屏幕上的说明完成设置。
The time window in which to calculate the derivative. Derivatives in this window will be averaged with a simple moving average algorithm (SMA) weighted by time. This is for instance useful for a sensor that outputs discrete values, or to filter out short duration noise. By default the derivative is calculated between two consecutive updates without any smoothing.
Metric unit to prefix the derivative result (Wikipedia
YAML configuration
Alternatively, this integration can be configured and set up manually via YAML
instead. To enable the 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
Round the calculated derivative value to at most N decimal places.
Metric unit to prefix the derivative result (Wikipedia
SI unit of time of the derivative. Available units are s, min, h, d. If this parameter is set, the attribute unit_of_measurement will be set like x/y where x is the unit of the sensor given via the source parameter and y is the value given here.
Unit of Measurement to be used for the derivative. This will overwrite the automatically set unit_of_measurement as explained above.
The time window in which to calculate the derivative. Derivatives in this window will be averaged with a Simple Moving Average algorithm weighted by time. This is for instance useful for a sensor that outputs discrete values, or to filter out short duration noise. By default the derivative is calculated between two consecutive updates without any smoothing.
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 YAML configuration that uses time_window
is
sensor:
- platform: derivative
source: sensor.temperature
name: Temperature change per hour
round: 1
unit_time: h # the resulting "unit_of_measurement" will be °C/h if the sensor.temperate has set °C as its unit
time_window: "00:30:00" # we look at the change over the last half hour