Weekly/monthly temperature utility sensor not updating well

Continuation of this topic:

Statistic sensor reset/clear at midnight for daily min & max temperature - Configuration - Home Assistant Community (home-assistant.io)

This is my code for the daily sensors (this works!).

- trigger:
    - platform: time
      at: '00:00:00'
    - platform: state
      entity_id: sensor.buienradar_temperature
  sensor:
    - name: 'Max temp nw'
      unit_of_measurement: '°C'
      device_class: temperature
      state: >
        {% set t_new = states('sensor.buienradar_temperature') | float(-99) %}
        {{ [t_new, this.state | float(-99)] | max if trigger.platform != 'time' else t_new }}
      attributes:
        temperature_updated: "{{ now() | as_local }}"
- trigger:
    - platform: time
      at: '00:00:00'
    - platform: state
      entity_id: sensor.buienradar_temperature
  sensor:
    - name: 'Min temp nw'
      unit_of_measurement: '°C'
      device_class: temperature
      state: >
        {% set t_new = states('sensor.buienradar_temperature') | float(99) %}
        {{ [t_new, this.state | float(99)] | min if trigger.platform != 'time' else t_new }}
      attributes:
        temperature_updated: "{{ now() | as_local }}"

I also want weekly and monthly min max for the temperature. This only works for max temp weekly. Max temp monthly and min temp weekly/monthly looks like it’s increased with 0,1 every hour (intitial value was 0,0 for the max and 99,0 for the min temp sensors).

Code:

utility_meter:
  max_temp_weekly:
    source: sensor.max_temp_nw
    name: Max Temp Weekly
    cycle: weekly
  max_temp_monthly:
    source: sensor.max_temp_nw
    name: Max Temp Monthly
    cycle: monthly
  min_temp_weekly:
    source: sensor.min_temp_nw
    name: Min Temp Weekly
    cycle: weekly
  min_temp_monthly:
    source: sensor.min_temp_nw
    name: Min Temp Monthly
    cycle: monthly

Screenshot of entities:

I need some help with this please :slight_smile:

Hello
Im struggling a little with this too. it seems like the utility meter is recording deltas as oppose to actual values.
19 → 19.5 = 0.5, and thats recorded cumulatively over the day.

I saw theres a deltas argument, but that just treats the recorded values as the deltas:
19 → 19.5 = 38.5

It kinda makes sense I suppose for a utility meter to cumulatively sum records rather than record actual values I guess. The deltas could work if we knew the starting value maybe, but seems awkward.

did you ever figure this out?
Thanks