The following template filters and functions will now log a warning instead of silently returning the input if the input is invalid and no default value is specified:
float
How is this done best ?
This seems to work :
{## Imitate available variables: ##}
{% set my_test_json = {
"temperature": 25,
"unit": "°C"
} %}
The temperature is {{ my_test_json.temperature | default(0) | float }} {{ my_test_json.unit }}.
The temperature is {{ my_test_json.temperature | float | default(0) }} {{ my_test_json.unit }}.