From c859cd071dd532826c8678e03f7f01d07494169a Mon Sep 17 00:00:00 2001 From: Anders Melchiorsen Date: Mon, 7 Sep 2020 16:11:27 +0200 Subject: [PATCH] Add state trigger examples with to/for and from/for (#14363) --- source/_docs/automation/trigger.markdown | 25 ++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/source/_docs/automation/trigger.markdown b/source/_docs/automation/trigger.markdown index 85ea844e05a..5658838c4e9 100644 --- a/source/_docs/automation/trigger.markdown +++ b/source/_docs/automation/trigger.markdown @@ -152,9 +152,30 @@ automation: from: "not_home" # Optional to: "home" +``` - # If given, will trigger when state has been the to state for X time. - for: "01:10:05" +#### Holding a state + +You can use `for` to have the state trigger only fire if the state holds for some time. + +```yaml +automation: + trigger: + platform: state + entity_id: light.office + # Must stay "on" for 30 seconds + to: "on" + for: "00:00:30" +``` + +```yaml +automation: + trigger: + platform: state + entity_id: media_player.kitchen + # Not "playing" for 30 seconds + from: "playing" + for: "00:00:30" ``` You can also use templates in the `for` option.