mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-15 13:26:54 +00:00
Support 'for' without setting the 'to'-state in automation state trigger (#14423)
This commit is contained in:
parent
c6c4936172
commit
0ea561ae9d
@ -158,6 +158,9 @@ automation:
|
||||
|
||||
You can use `for` to have the state trigger only fire if the state holds for some time.
|
||||
|
||||
This example fires, when the entity state changed to `"on"` and holds that
|
||||
state for 30 seconds:
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
@ -168,14 +171,49 @@ automation:
|
||||
for: "00:00:30"
|
||||
```
|
||||
|
||||
You can also fire the trigger when the state value changed from a specific
|
||||
state, but hasn't returned to that state value for the specified time.
|
||||
|
||||
This can be useful, e.g., checking if a media player hasn't turned "off" for
|
||||
the time specified, but doesn't care about "playing" or "paused".
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: media_player.kitchen
|
||||
# Not "playing" for 30 seconds
|
||||
from: "playing"
|
||||
for: "00:00:30"
|
||||
# Not "off" for 30 minutes
|
||||
from: "off"
|
||||
for: "00:30:00"
|
||||
```
|
||||
|
||||
Please note, that when using `from`, `to` and `for`, only the value of the
|
||||
`to` option is considered for the time specified.
|
||||
|
||||
In this example, the trigger fires if the state value of the entity remains the
|
||||
same for `for` the time specified, regardless of the current state value.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: media_player.kitchen
|
||||
# The media player remained in its current state for 1 hour
|
||||
for: "01:00:00"
|
||||
```
|
||||
|
||||
When the `attribute` option is specified, all of the above works, but only
|
||||
applies to the specific state value of that attribute.
|
||||
|
||||
For example, this trigger only fires if the boiler was heating for 10 minutes:
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: climate.living_room
|
||||
attribute: hvac_action
|
||||
state: "heating"
|
||||
```
|
||||
|
||||
You can also use templates in the `for` option.
|
||||
|
Loading…
x
Reference in New Issue
Block a user