diff --git a/homeassistant/helpers/template.py b/homeassistant/helpers/template.py index d3f49c003c8..8d55615f661 100644 --- a/homeassistant/helpers/template.py +++ b/homeassistant/helpers/template.py @@ -425,6 +425,8 @@ ENV.filters['timestamp_custom'] = timestamp_custom ENV.filters['timestamp_local'] = timestamp_local ENV.filters['timestamp_utc'] = timestamp_utc ENV.filters['is_defined'] = fail_when_undefined +ENV.filters['max'] = max +ENV.filters['min'] = min ENV.globals['float'] = forgiving_float ENV.globals['now'] = dt_util.now ENV.globals['utcnow'] = dt_util.utcnow diff --git a/tests/helpers/test_template.py b/tests/helpers/test_template.py index 1948d8ab052..b2134879640 100644 --- a/tests/helpers/test_template.py +++ b/tests/helpers/test_template.py @@ -186,6 +186,20 @@ class TestHelpersTemplate(unittest.TestCase): template.Template('{{ %s | timestamp_local }}' % inp, self.hass).render()) + def test_min(self): + """Test the min filter.""" + self.assertEqual( + '1', + template.Template('{{ [1, 2, 3] | min }}', + self.hass).render()) + + def test_max(self): + """Test the max filter.""" + self.assertEqual( + '3', + template.Template('{{ [1, 2, 3] | max }}', + self.hass).render()) + def test_timestamp_utc(self): """Test the timestamps to local filter.""" tests = {