diff --git a/source/_components/binary_sensor.template.markdown b/source/_components/binary_sensor.template.markdown index b09f67aab645..99b7d7ca72f9 100644 --- a/source/_components/binary_sensor.template.markdown +++ b/source/_components/binary_sensor.template.markdown @@ -32,6 +32,8 @@ Configuration variables: - **device_class** (*Optional*): The [type/class](/components/binary_sensor/) of the sensor to set the icon in the frontend. - **value_template** (*Optional*): Defines a [template](/topics/templating/) to extract a value from the payload. - **entity_id** (*Optional*): Add a list of entity IDs so the sensor only reacts to state changes of these entities. This will reduce the number of times the sensor will try to update it's state. + - **on_delay** (*Optional*): The amount of time the template state must be met before this sensor will switch to on. + - **off_delay** (*Optional*): The amount of time the template state must be not met before this sensor will switch to off. ## {% linkable_title Examples %} @@ -110,6 +112,20 @@ sensor: icon_template: {% raw %}'{% if is_state("sun.sun", "above_horizon") %}mdi:weather-sunny{% else %}mdi:weather-night{% endif %}'{% endraw %} ``` +### {% linkable_title Washing Machine Running %} + +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. +binary_sensor: + - platform: template + name: Washing Machine + value_template: {% raw %}'{{ sensor.washing_machine_power > 0 }}'{% endraw %} + off_delay: + minutes: 5 +``` + ### {% linkable_title Is anyone home? %} This example is determining if anyone is home based on the combination diff --git a/source/_docs/automation/trigger.markdown b/source/_docs/automation/trigger.markdown index 0a9db0bd5e1d..ae3a7faf18ee 100644 --- a/source/_docs/automation/trigger.markdown +++ b/source/_docs/automation/trigger.markdown @@ -68,6 +68,12 @@ automation: # At least one of the following required above: 17 below: 25 + + # If given, will trigger when condition has been for X time. + for: + hours: 1 + minutes: 10 + seconds: 5 ```