Threshold
The threshold integration observes the state of another sensor. If the value is below or higher than the given threshold, then the state of the threshold sensor is changed. It also supports a range if both the upper and lower limits are given.
If the sensor is configured with no hysteresis and the sensor value is equal to the threshold, the sensor is turned off since it is not upper or lower with respect to the threshold.
配置
要将 Threshold helper 添加到您的 Home Assistant 实例中,请使用此 My 按钮:
手动配置步骤
如果上述 My 按钮不起作用,您也可以手动执行以下步骤:
-
浏览到您的 Home Assistant 实例。
-
转到
设置 > 设备与服务。 -
在屏幕顶部,选择标签:Helpers。
-
在右下角,选择
创建助手 按钮。 -
从列表中选择 Threshold。
-
按照屏幕上的说明完成设置。
YAML configuration
Alternatively, this integration can be configured and set up manually via YAML
instead. To enable the Integration sensor in your installation, add the
following to your configuration.yaml
configuration.yaml 文件是 Home Assistant 的主要配置文件。它列出了要加载的集成及其特定配置。在某些情况下,需要直接在 configuration.yaml 文件中手动编辑配置。大多数集成可以在 UI 中配置。 [Learn more] file:
# Example configuration.yaml entry
binary_sensor:
- platform: threshold
entity_id: sensor.random
lower: 20
Configuration Variables
The entity to monitor. Only sensors are supported.
Sets the class of the device, changing the device state and icon that is displayed on the frontend.
The distance the observed value must be from the threshold before the state is changed.
Matrix of state change behavior
Sensor value rising
Set | Turns on when | Turns off when |
---|---|---|
only upper | sensor > (upper + hyst) | never |
only lower | never | sensor > (lower + hyst) |
upper & lower | sensor > (lower + hyst) | sensor > (upper + hyst) |
Sensor value falling
Set | Turns on when | Turns off when |
---|---|---|
only upper | never | sensor < (upper - hyst) |
only lower | sensor < (lower - hyst) | never |
upper & lower | sensor < (upper - hyst) | sensor < (lower - hyst) |
Examples
Is the temperature rising or falling
The hysteresis parameter can be used in this use-case to avoid frequent state changes around the maximum or the minimum of a temperature curve. We also have to utilize the derivative sensor for this use-case:
sensor:
- platform: derivative # will be positive for rising temperatures and negative for falling temperatures
source: sensor.temperature
unit_time: min
name: temperature derivative
time_window: 00:05:00
binary_sensor:
- platform: threshold # will switch state not at 0°C/min but
# will switch on when value rises above 0.1°C/min
# will switch off when value sinks below -0.1°C/min
entity_id: sensor.temperature_derivative
upper: 0
hysteresis: 0.1 # sensor
name: temperature rising