mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-17 06:16:50 +00:00
Tweak template documentation
This commit is contained in:
parent
1a4599572f
commit
76cd19a506
@ -149,7 +149,7 @@ automation:
|
|||||||
|
|
||||||
#### {% linkable_title Template trigger %}
|
#### {% linkable_title Template trigger %}
|
||||||
|
|
||||||
Template triggers work by evaluating a [template] on each state change. The trigger will fire if the state change caused the template to render 'true'.
|
Template triggers work by evaluating a [template] on each state change. The trigger will fire if the state change caused the template to render 'true'. This is achieved by having the template result in a true boolean expression (`{% raw %}{{ is_state('device_tracker.paulus', 'home') }}{% endraw %}`) or by having the template render 'true' (example below).
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
automation:
|
automation:
|
||||||
@ -244,14 +244,16 @@ automation:
|
|||||||
|
|
||||||
#### {% linkable_title Template condition %}
|
#### {% linkable_title Template condition %}
|
||||||
|
|
||||||
The template condition will test if [given template][template] renders a value equal to true.
|
The template condition will test if [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
|
||||||
automation:
|
automation:
|
||||||
condition:
|
condition:
|
||||||
platform: template
|
platform: template
|
||||||
value_template: '{% raw %}{{ state.attributes.battery }}{% endraw %}'
|
value_template: '{% raw %}{{ state.attributes.battery > 50 }}{% endraw %}'
|
||||||
|
# Or value_template could be:
|
||||||
|
# {% raw %}{% if state.attributes.battery > 50 %}true{% else %}false{% endif %}{% endraw %}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### {% linkable_title Time condition %}
|
#### {% linkable_title Time condition %}
|
||||||
|
@ -25,6 +25,7 @@ sensor:
|
|||||||
monitored_variables:
|
monitored_variables:
|
||||||
- name: temperature
|
- name: temperature
|
||||||
unit_of_measurement: '°C'
|
unit_of_measurement: '°C'
|
||||||
|
value_template: '{% raw %}{{ value | round(1) }}{% endraw %}'
|
||||||
- name: humidity
|
- name: humidity
|
||||||
unit_of_measurement: '%'
|
unit_of_measurement: '%'
|
||||||
pins:
|
pins:
|
||||||
@ -43,6 +44,7 @@ Configuration variables:
|
|||||||
- **monitored_variables** array (*Optional*): List of exposed variables.
|
- **monitored_variables** array (*Optional*): List of exposed variables.
|
||||||
- **name** (*Required*): The name of the variable you wish to monitor.
|
- **name** (*Required*): The name of the variable you wish to monitor.
|
||||||
- **unit** (*Optional*): Defines the units of measurement of the sensor, if any.
|
- **unit** (*Optional*): Defines the units of measurement of the sensor, if any.
|
||||||
|
- **value_template** (*Optional*): Defines a [template](/getting-started/templating/) to extract a value from the payload.
|
||||||
- **pins** array (*Optional*): List of pins to monitor. Analog pins need a leading **A** for the pin number.
|
- **pins** array (*Optional*): List of pins to monitor. Analog pins need a leading **A** for the pin number.
|
||||||
- **name** (*Optional*): The name of the variable you wish to monitor.
|
- **name** (*Optional*): The name of the variable you wish to monitor.
|
||||||
- **unit_of_measurement** (*Optional*): Defines the unit of measurement of the sensor, if any.
|
- **unit_of_measurement** (*Optional*): Defines the unit of measurement of the sensor, if any.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user