From 0a19873f0cfc9a4b94c59f92b389dfcc7f03f0ba Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 3 Sep 2020 15:24:32 -0500 Subject: [PATCH] Update template Working without entities examples to include as_local() (#14389) Co-authored-by: Franck Nijhof --- .../binary_sensor.template.markdown | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/source/_integrations/binary_sensor.template.markdown b/source/_integrations/binary_sensor.template.markdown index 81c298124fd..675eef2e95a 100644 --- a/source/_integrations/binary_sensor.template.markdown +++ b/source/_integrations/binary_sensor.template.markdown @@ -334,3 +334,21 @@ automation: - service: homeassistant.update_entity entity_id: binary_sensor.minute_is_odd {% endraw %} + +In the case where the template should be updated every minute, replacing `now()` with `as_local(states.sensor.time.last_changed)` +can achieve the desired result without the need to create an automation: + +{% raw %} +```yaml +sensor: + - platform: time_date + display_options: + - 'time' + +binary_sensor: +- platform: template + sensors: + minute_is_odd: + value_template: '{{ as_local(states.sensor.time.last_changed).minute % 2 }}' +``` +{% endraw %}