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.
I tried updating it, based on Adding trigger based template to a templates.yaml file? - #4 by Scott8586
I also tried copying in a random example from Automation Trigger - battery_level for a device - #2 by 123
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"