mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-06-18 04:18:35 +00:00
Update Templates.md
Added template example with float number formatting.
This commit is contained in:
@ -45,6 +45,16 @@ The first two keep to the simple proposal above. The last combines them into a s
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
In order to keep the formatting of floating point numbers under control, you might also like to include a format string as follows. `states()` seems to return a `string` that needs converting to a `float` before the `format()` call can manage the conversion to the required number fo decimal places.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"name": "Hallway",
|
||||||
|
"type": "template",
|
||||||
|
"content": "T:{{ '%.1f'|format(states('sensor.hallway_temperature')|float) }}°C, H:{{ '%.1f'|format(states('sensor.hallway_humidity')|float) }}%"
|
||||||
|
},
|
||||||
|
```
|
||||||
|
|
||||||
## Conditionals
|
## Conditionals
|
||||||
|
|
||||||
Anything between `{%` and `%}` is a directive (`if`, `else`, `elif`, `endif`, etc.). Conditionals are used to dynamically change the content based on the state of the entity.
|
Anything between `{%` and `%}` is a directive (`if`, `else`, `elif`, `endif`, etc.). Conditionals are used to dynamically change the content based on the state of the entity.
|
||||||
|
Reference in New Issue
Block a user