Skip to content

codechimp-org/ha-codechimp-template-helpers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hacs_badge Version

CodeChimp Template Helpers

This Template extension for Home Assistant contains various helper templates

Installation

Install this in HACS as a custom repository or download the codechimp-template-helpers.jinja from this repository and place the files into your config\custom_templates directory.
Run the homeassistant.reload_custom_templates service call to load the file.

Macros

pluralize(value, singular, plural, spacer=True)

A simple macro that will return the value with the given singular or plural suffix.

Arugment Type Default Example Description
value string, int or float - states('sensor.value') The value to evaluate, will be converted to float
singular string - 'day' The string to use for singular
plural string - 'days' The string to use for plurals & 0
spacer boolean True True (Optional) Whether to add a spacer between the value and the singular/plural suffix

Example

{% from 'codechimp-template-helpers.jinja' import pluralize %}
{{ pluralize( states('sensor.value'), 'day', 'days') }}