I feel like an idiot for having to ask this, but can someone help me with how to format a template sensor with trigger in a template.yaml file? Before I try to get started with the sensor I really want, I experimented with the example from Template - Home Assistant.
Can someone help me with formatting my code or sharing one of your own examples of a template trigger that works in template.yaml? Seeing a working example would really help me with understanding the logic.
- trigger:
- trigger: time_pattern
# This will update every night
hours: 0
minutes: 0
sensor:
# Keep track how many days have past since a date
- name: "Not smoking"
state: '{{ ( ( as_timestamp(now()) - as_timestamp(strptime("06.07.2018", "%d.%m.%Y")) ) / 86400 ) | round(default=0) }}'
unit_of_measurement: "Days"
I made a mistake with coping the code in my post, apologies. I have edited my original post so the code is the same as the screenshot.
As you can see in the screenshot, removing the dash does not solve the issue.