v1.5.0-beta.1: Jinja2-style template filters
Pre-release
Pre-release
Pre-release v1.5.0-beta.1
Added
- Jinja2-style template filters for
text_template: Thetext_templatefield now supports
a filter pipeline using{{ variable | filter }}syntax, compatible with common Jinja2 filters
Variables:
state- entity state (respectsdecimalsconfig)name- entity friendly nameattributes.<attr>- any entity attribute (e.g.attributes.unit_of_measurement)
Filters:
upper- convert to uppercaselower- convert to lowercasetitle- title caseround(n)- round to n decimal placesint- convert to integerfloat- convert to floatreplace('a', 'b')- string replacementtruncate(n)- truncate to n charactersdefault('value')- fallback if value is empty
Examples:
text_template: "Charging:\n {{ state | upper }}"
text_template: "{{ state | round(1) }} {{ attributes.unit_of_measurement }}"
text_template: "{{ state | replace('_', ' ') | title }}"
text_template: "{{ state | upper | truncate(8) }}"Filters can be chained. Fully backward compatible with existing {{ state }} and {{ name }} templates.
See the updated README for full documentation.
NOTE: This is a pre-release for testing. Please report any issues before the stable release.