From 9289169c3987a502b0f47c1daadcdb0a8da38092 Mon Sep 17 00:00:00 2001 From: Greg Laabs Date: Thu, 10 Aug 2017 15:21:26 -0700 Subject: [PATCH 1/2] Add delay feature to Threshold sensor The threshold must be met constantly for on_delay or off_delay amount of time in order to switch to the respective state. Among other things, this allows turning an energy meter in to a "device is running" state, because it can ignore the small periods of time where the energy meter drops to zero. --- .../binary_sensor.threshold.markdown | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/source/_components/binary_sensor.threshold.markdown b/source/_components/binary_sensor.threshold.markdown index 025b2f2c0645..7a4471d0d1e7 100644 --- a/source/_components/binary_sensor.threshold.markdown +++ b/source/_components/binary_sensor.threshold.markdown @@ -9,7 +9,7 @@ sharing: true footer: true logo: home-assistant.png ha_category: Binary Sensor -ha_iot_class: "Local Polling" +ha_iot_class: "Local Push" ha_release: 0.34 --- @@ -31,6 +31,18 @@ binary_sensor: threshold: 15 type: lower entity_id: sensor.random + + # If present, sensor will only switch to on if the threshold is met for this amount of time + on_delay: + hours: 1 + minutes: 10 + seconds: 5 + + # Same as above, but for the sensor switching to off + off_delay: + hours: 1 + minutes: 10 + seconds: 5 ``` Configuration variables: @@ -39,4 +51,25 @@ Configuration variables: - **threshold** (*Required*): The value which is the threshold. - **type** (*Required*): `lower` if the value needs to be below the threshold or `upper` if higher. - **name** (*Optional*): Name of the sensor to use in the frontend. Defaults to `Stats`. +- **on_delay** (*Optional*): The amount of time the threshold must be met before this sensor will switch to on +- **off_delay** (*Optional*): The amount of time the threshold must be not met before this sensor will switch to off + +## {% linkable_title Examples %} + +In this section you find some real life examples of how to use this sensor. + +### {% linkable_title Washing Machine Running %} +This example uses `off_delay` to convert an energy meter connected to a washing machine to determine when a load is finished. During the washer's operation, the energy meter will fluctuate wildly, hitting zero frequently even before the load is finished. By utilizing `off_delay`, we can have this sensor only turn off if there has been no washer activity for 5 minutes. + +```yaml +# Determine when the washing machine has a load running +binary_sensor: + - platform: threshold + name: Washing Machine + threshold: 0 + type: upper + entity_id: sensor.washing_machine_power + off_delay: + minutes: 5 +``` From 71c0e829314b11122f6b5646adf47b9665c3bc91 Mon Sep 17 00:00:00 2001 From: Greg Laabs Date: Fri, 11 Aug 2017 00:31:23 -0700 Subject: [PATCH 2/2] Some minor punctuation and rewording a confusing line --- source/_components/binary_sensor.threshold.markdown | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/_components/binary_sensor.threshold.markdown b/source/_components/binary_sensor.threshold.markdown index 7a4471d0d1e7..7530aa494827 100644 --- a/source/_components/binary_sensor.threshold.markdown +++ b/source/_components/binary_sensor.threshold.markdown @@ -32,13 +32,13 @@ binary_sensor: type: lower entity_id: sensor.random - # If present, sensor will only switch to on if the threshold is met for this amount of time + # If present, sensor will only switch to on if the threshold is met for this amount of time. on_delay: hours: 1 minutes: 10 seconds: 5 - # Same as above, but for the sensor switching to off + # Same as above, but for the sensor switching to off. off_delay: hours: 1 minutes: 10 @@ -51,8 +51,8 @@ Configuration variables: - **threshold** (*Required*): The value which is the threshold. - **type** (*Required*): `lower` if the value needs to be below the threshold or `upper` if higher. - **name** (*Optional*): Name of the sensor to use in the frontend. Defaults to `Stats`. -- **on_delay** (*Optional*): The amount of time the threshold must be met before this sensor will switch to on -- **off_delay** (*Optional*): The amount of time the threshold must be not met before this sensor will switch to off +- **on_delay** (*Optional*): The amount of time the threshold must be met before this sensor will switch to on. +- **off_delay** (*Optional*): The amount of time the threshold must be not met before this sensor will switch to off. ## {% linkable_title Examples %} @@ -60,10 +60,10 @@ In this section you find some real life examples of how to use this sensor. ### {% linkable_title Washing Machine Running %} -This example uses `off_delay` to convert an energy meter connected to a washing machine to determine when a load is finished. During the washer's operation, the energy meter will fluctuate wildly, hitting zero frequently even before the load is finished. By utilizing `off_delay`, we can have this sensor only turn off if there has been no washer activity for 5 minutes. +This example creates a washing machine "load running" sensor by monitoring an energy meter connected to the washer. During the washer's operation, the energy meter will fluctuate wildly, hitting zero frequently even before the load is finished. By utilizing `off_delay`, we can have this sensor only turn off if there has been no washer activity for 5 minutes. ```yaml -# Determine when the washing machine has a load running +# Determine when the washing machine has a load running. binary_sensor: - platform: threshold name: Washing Machine