Add state trigger examples with to/for and from/for (#14363)

This commit is contained in:
Anders Melchiorsen 2020-09-07 16:11:27 +02:00 committed by GitHub
parent 68a3779895
commit c859cd071d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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.