Trigger on not matching to/from states (#22322)

This commit is contained in:
Franck Nijhof 2022-04-12 23:18:42 +02:00 committed by GitHub
parent 88dd32b169
commit c3fabfa466
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -326,7 +326,7 @@ If for your use case this is undesired, you could consider using the automation
## State trigger ## 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. 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 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`. If at least one of `from`, `to`, `not_from`, or `not_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`, `to`, `not_from`, or `not_to` to `null`.
<div class='note'> <div class='note'>
@ -370,6 +370,21 @@ automation:
to: to:
``` ```
The `not_from` and `not_to` options are the counter parts of `from` and `to`. They can be used to trigger on state changes that are **not** the specified state. This can be useful to trigger on all state changes, except specific ones.
```yaml
automation:
trigger:
- platform: state
entity_id: vacuum.test
not_from:
- "unknown"
- "unavailable"
to: "on"
```
You cannot use `from` and `not_from` at the same time. The same applies to `to` and `not_to`.
### Triggering on attribute changes ### Triggering on attribute changes
When the `attribute` option is specified, the trigger only fires When the `attribute` option is specified, the trigger only fires