From a3cb9a61c7a5626953d12372d7a100dbf115a6b3 Mon Sep 17 00:00:00 2001 From: TehRobot Date: Mon, 29 Oct 2018 00:55:59 +1300 Subject: [PATCH] Update sensor.template.markdown (#7185) * Update sensor.template.markdown Update documents to cover how to fix errors arising from the 81.0 update around templates. Shows both methods (adding entity_id and using the new service `update_entity` ### has no entity ids configured to track nor were we able to extract the entities to track from the ### template(s). This entity will only be able to be updated manually. * Fix typo --- source/_components/sensor.template.markdown | 35 +++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/source/_components/sensor.template.markdown b/source/_components/sensor.template.markdown index 6915c2c262a..551b3d3b369 100644 --- a/source/_components/sensor.template.markdown +++ b/source/_components/sensor.template.markdown @@ -306,3 +306,38 @@ sensor: unit_of_measurement: "Days" ``` {% endraw %} + +### {% linkable_title Template tracking %} + +This example shows how to add `entity_id` to a template to allow tracking of updates. Fixing an error caused in (81.0) + +{% raw %} +```yaml +sensor: +- platform: template + sensors: + nonsmoker: + entity_id: now.strptime + value_template: '{{ (( as_timestamp(now()) - as_timestamp(strptime("06.07.2018", "%d.%m.%Y")) ) / 86400 ) | round(2) }}' + friendly_name: 'Not smoking' + unit_of_measurement: "Days" +``` +{% endraw %} + +Note: If a template uses more than one sensor they can be listed + + +The alternative to this is to create an `Automation`using the new (81.0) service `homeassistant.update_entity` and list all entity's requiring updates and setting the interval based on time. + +{% raw %} +```yaml +automation: + - alias: 'nonsmoker_update' + trigger: + - platform: time + minutes: '/1' + action: + - service: homeassistant.update_entity + entity_id: sensor.nonsmoker +``` +{% endraw %}