mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-05-02 09:17:35 +00:00
Document setting state trigger to
or from
to null (#20324)
This commit is contained in:
parent
f610407c07
commit
32e347edf7
@ -295,7 +295,7 @@ The `for` template(s) will be evaluated when an entity changes as specified.
|
||||
## State trigger
|
||||
|
||||
Fires when the state of any of given entities changes. If only `entity_id` is given, the trigger will fire for all state changes, even if only state attributes change.
|
||||
If only one of `from` or `to` are given, the trigger will fire on any matching state change, but not if only attributes change.
|
||||
If at least one of `from` or `to` are given, the trigger will fire on any matching state change, but not if only attributes change. To trigger on all state changes, but not on changed attributes, set at least one of `from` or `to` to `null`.
|
||||
|
||||
<div class='note'>
|
||||
|
||||
@ -329,7 +329,45 @@ automation:
|
||||
to: "error"
|
||||
```
|
||||
|
||||
### Holding a state
|
||||
Trigger on all state changes, but not attributes by setting `to` to `null`:
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: vacuum.test
|
||||
to:
|
||||
```
|
||||
|
||||
### Triggering on attribute changes
|
||||
|
||||
When the `attribute` option is specified, the trigger only fires
|
||||
when the specified attribut changes. Changes to other attributes or the
|
||||
state are ignored.
|
||||
|
||||
For example, this trigger only fires when the boiler has been heating for 10 minutes:
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: climate.living_room
|
||||
attribute: hvac_action
|
||||
to: "heating"
|
||||
for: "00:10:00"
|
||||
```
|
||||
|
||||
This trigger fires whenever the boiler's `hvac_action` attribute changes:
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: climate.living_room
|
||||
attribute: hvac_action
|
||||
```
|
||||
|
||||
### Holding a state or attribute
|
||||
|
||||
You can use `for` to have the state trigger only fire if the state holds for some time.
|
||||
|
||||
@ -380,22 +418,6 @@ automation:
|
||||
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. In this case the
|
||||
normal state value of the entity is ignored.
|
||||
|
||||
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
|
||||
to: "heating"
|
||||
for: "00:10:00"
|
||||
```
|
||||
|
||||
You can also use templates in the `for` option.
|
||||
|
||||
{% raw %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user