A few years ago this community helped me refine the following template to capture the daily outdoor high and low temperatures:
Working daily hi/low template
template:
- trigger:
- platform: time
at: '00:00:00'
- platform: state
entity_id: sensor.outdoor_temp
sensor:
- name: "Outdoor Daily High Temperature"
unit_of_measurement: '°F'
device_class: temperature
state: >
{% set t_high = states('sensor.outdoor_temp') | float(-99) %}
{{ [t_high, this.state | float(-99)] | max if trigger.platform != 'time' else t_high }}
attributes:
temperature_updated: "{{ now() | as_local }}"
icon: mdi:arrow-up-circle-outline
- name: "Outdoor Daily Low Temperature"
unit_of_measurement: '°F'
device_class: temperature
state: >
{% set t_low = states('sensor.outdoor_temp') | float(120) %}
{{ [t_low, this.state | float(120)] | min if trigger.platform != 'time' else t_low }}
attributes:
temperature_updated: "{{ now() | as_local }}"
icon: mdi:arrow-down-circle-outline
I’m trying to modify this format to reset annually (Jan 1st at midnight). I have been looking at the documentation for templates, automatons, and triggers for the last couple days. I’m not seeing an obvious solution to this.
This results in the error message Expected HH:MM, HH:MM:SS, an Entity ID with domain 'input_datetime' or 'sensor', a combination of a timestamp sensor entity and an offset, or Limited Template
After further reviewing the documentation, that does make sense. This format does not match any of those expected formats.
The only method I can come up with to accomplish this is to use a local calendar event set to reoccur on Jan 1st of every year and use that event to trigger the reset. I have not tried to set this up yet.
If you want to record the highest/lowest yearly temperatures, use the Utility Meter integration (if you want, you can also use it to record weekly and monthly highs/lows).
Our lowest temperature over the last three days has been 15.4 and the high temperature has only been 71.3. I’ve been over the docs for the Utility Meter several times and I can’t see what I’m missing.
I’m looking at other posts in the community for this topic now.
My apologies; looks like my suggestion was wrong. It’s reporting a running sum of the temperature values (which is not what you want).
I suggest you consider doing what this person did:
The user provides several examples for resetting at various time intervals (except for yearly). Here’s my suggestion for resetting on January 1st at 00:00.
value_template: "{{ now().month == 1 and now().day == 1 and now().hour == 0 and now().minute == 0 }}"