mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-19 15:26:59 +00:00
Add documentation for version in templates (#24131)
Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
c9ca6f42c3
commit
245b047eb6
@ -548,6 +548,23 @@ Example using `is_defined` to parse a JSON payload:
|
||||
|
||||
This will throw an error `UndefinedError: 'value_json' is undefined` if the JSON payload has no `val` attribute.
|
||||
|
||||
### Version
|
||||
|
||||
- `version()` Returns a [AwesomeVersion object](https://github.com/ludeeus/awesomeversion) for the value given inside the brackets.
|
||||
- This is also available as a filter (`| version`).
|
||||
|
||||
Examples:
|
||||
|
||||
{% raw %}
|
||||
|
||||
- `{{ version("2099.9.9") > "2000.0.0" }}` Will return `True`
|
||||
- `{{ version("2099.9.9") < "2099.10" }}` Will return `True`
|
||||
- `{{ "2099.9.9" | version < "2099.10" }}` Will return `True`
|
||||
- `{{ (version("2099.9.9") - "2100.9.10").major }}` Will return `True`
|
||||
- `{{ (version("2099.9.9") - "2099.10.9").minor }}` Will return `True`
|
||||
- `{{ (version("2099.9.9") - "2099.9.10").patch }}` Will return `True`
|
||||
|
||||
{% endraw %}
|
||||
|
||||
### Distance
|
||||
|
||||
@ -556,6 +573,7 @@ Not supported in [limited templates](#limited-templates).
|
||||
- `distance()` will measure the distance in kilometers between home, entity, coordinates.
|
||||
- `closest()` will find the closest entity.
|
||||
|
||||
|
||||
#### Distance examples
|
||||
|
||||
If only one location is passed in, Home Assistant will measure the distance from home.
|
||||
|
Loading…
x
Reference in New Issue
Block a user