mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-23 17:27:19 +00:00
Add keyword 'condition' for completeness (#1524)
Added the 'condition:' keyword to make it clear that for a basic condition definition, you will need that keyword twice.
This commit is contained in:
parent
ce79bf09b7
commit
5313bf3b96
@ -74,12 +74,13 @@ For above, the condition passes if `value >= above`. For below, the condition pa
|
|||||||
You can optionally use a `value_template` to process the value of the state before testing it.
|
You can optionally use a `value_template` to process the value of the state before testing it.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
condition: numeric_state
|
condition:
|
||||||
entity_id: sensor.temperature
|
condition: numeric_state
|
||||||
above: 17
|
entity_id: sensor.temperature
|
||||||
below: 25
|
above: 17
|
||||||
# If your sensor value needs to be adjusted
|
below: 25
|
||||||
value_template: {% raw %}{{ float(state.state) + 2 }}{% endraw %}
|
# If your sensor value needs to be adjusted
|
||||||
|
value_template: {% raw %}{{ float(state.state) + 2 }}{% endraw %}
|
||||||
```
|
```
|
||||||
|
|
||||||
### {% linkable_title State condition %}
|
### {% linkable_title State condition %}
|
||||||
@ -87,14 +88,15 @@ value_template: {% raw %}{{ float(state.state) + 2 }}{% endraw %}
|
|||||||
Tests if an entity is a specified state.
|
Tests if an entity is a specified state.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
condition: state
|
condition:
|
||||||
entity_id: device_tracker.paulus
|
condition: state
|
||||||
state: not_home
|
entity_id: device_tracker.paulus
|
||||||
# optional: trigger only if state was this for last X time.
|
state: not_home
|
||||||
for:
|
# optional: trigger only if state was this for last X time.
|
||||||
hours: 1
|
for:
|
||||||
minutes: 10
|
hours: 1
|
||||||
seconds: 5
|
minutes: 10
|
||||||
|
seconds: 5
|
||||||
```
|
```
|
||||||
|
|
||||||
### {% linkable_title Sun condition %}
|
### {% linkable_title Sun condition %}
|
||||||
@ -104,10 +106,11 @@ The sun condition can test if the sun has already set or risen when a trigger oc
|
|||||||
[sun_trigger]: /getting-started/automation-trigger/#sun-trigger
|
[sun_trigger]: /getting-started/automation-trigger/#sun-trigger
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
condition: sun
|
condition:
|
||||||
after: sunset
|
condition: sun
|
||||||
# Optional offset value
|
after: sunset
|
||||||
after_offset: "-1:00:00"
|
# Optional offset value
|
||||||
|
after_offset: "-1:00:00"
|
||||||
```
|
```
|
||||||
|
|
||||||
### {% linkable_title Template condition %}
|
### {% linkable_title Template condition %}
|
||||||
@ -115,8 +118,9 @@ after_offset: "-1:00:00"
|
|||||||
The template condition will test if the [given template][template] renders a value equal to true. This is achieved by having the template result in a true boolean expression or by having the template render 'true'.
|
The template condition will test if the [given template][template] renders a value equal to true. This is achieved by having the template result in a true boolean expression or by having the template render 'true'.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
condition: template
|
condition:
|
||||||
value_template: '{% raw %}{{ states.device_tracker.iphone.attributes.battery > 50 }}{% endraw %}'
|
condition: template
|
||||||
|
value_template: '{% raw %}{{ states.device_tracker.iphone.attributes.battery > 50 }}{% endraw %}'
|
||||||
```
|
```
|
||||||
|
|
||||||
Within an automation, template conditions also have access to the `trigger` variable as [described here][automation-templating].
|
Within an automation, template conditions also have access to the `trigger` variable as [described here][automation-templating].
|
||||||
@ -129,14 +133,15 @@ Within an automation, template conditions also have access to the `trigger` vari
|
|||||||
The time condition can test if it is after a specified time, before a specified time or if it is a certain day of the week
|
The time condition can test if it is after a specified time, before a specified time or if it is a certain day of the week
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
condition: time
|
condition:
|
||||||
# At least one of the following is required.
|
condition: time
|
||||||
after: '15:00:00'
|
# At least one of the following is required.
|
||||||
before: '02:00:00'
|
after: '15:00:00'
|
||||||
weekday:
|
before: '02:00:00'
|
||||||
- mon
|
weekday:
|
||||||
- wed
|
- mon
|
||||||
- fri
|
- wed
|
||||||
|
- fri
|
||||||
```
|
```
|
||||||
|
|
||||||
Valid values for `weekday` are `mon`, `tue`, `wed`, `thu`, `fri`, `sat`, `sun`.
|
Valid values for `weekday` are `mon`, `tue`, `wed`, `thu`, `fri`, `sat`, `sun`.
|
||||||
@ -147,9 +152,10 @@ Time condition windows can span across the midnight threshold. In the example ab
|
|||||||
Zone conditions test if an entity is in a certain zone. For zone automation to work, you need to have setup a device tracker platform that supports reporting GPS coordinates. Currently this is limited to the [OwnTracks platform](/components/device_tracker.owntracks/) and the [iCloud platform](/components/device_tracker.icloud/).
|
Zone conditions test if an entity is in a certain zone. For zone automation to work, you need to have setup a device tracker platform that supports reporting GPS coordinates. Currently this is limited to the [OwnTracks platform](/components/device_tracker.owntracks/) and the [iCloud platform](/components/device_tracker.icloud/).
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
condition: zone
|
condition:
|
||||||
entity_id: device_tracker.paulus
|
condition: zone
|
||||||
zone: zone.home
|
entity_id: device_tracker.paulus
|
||||||
|
zone: zone.home
|
||||||
```
|
```
|
||||||
|
|
||||||
### {% linkable_title Examples %}
|
### {% linkable_title Examples %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user