Delayed or earlier sensor value

You could create something like this:

template:
  - trigger:
      - platform: time_pattern
        minutes: "/1"
    sensor:
      - name: bathroom temperature history
        state: "{{ states('sensor.bathroom_temperature') }}"
        attributes:
          min0: "{{ states('sensor.bathroom_temperature')|float(0) }}"
          min1: "{{ this.attributes['min0'] }}"
          min2: "{{ this.attributes['min1'] }}"
          min3: "{{ this.attributes['min2'] }}"
          min4: "{{ this.attributes['min3'] }}"
          min5: "{{ this.attributes['min4'] }}"
          min6: "{{ this.attributes['min5'] }}"
          min7: "{{ this.attributes['min6'] }}"
          min8: "{{ this.attributes['min7'] }}"
          min9: "{{ this.attributes['min8'] }}"
          min10: "{{ this.attributes['min9'] }}"

Then the temperature as of ten minutes ago is in:

{{ state_attr('sensor.bathroom_temperature_history', 'min10') }}

Obviously, it’ll take ten minutes to populate fully as the values cascade down.

You could just use minutes: "/10" and two attributes, but this way you get more data…

1 Like