Getting totals by day from a daily incremental sensor?

Hi,

is there any way to create a statistic sensor for the current week? Not for the last 7 days.

I have a card on my dashboard showing the following for rain based on a counting sensor:
This our, Last hour, Today, Yesterday, This week, Last week, This month, Last month.
I use two automations. One handling receiving updates and one handling change of hour, day, week and month.
The sensor is a simple 433mHz with a RFtoMQTT function.

Automation to handle changing counter:

alias: " 0 Rain Update  on message"
description: ""
trigger:
  - platform: state
    entity_id: sensor.rain_mm_total
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: sensor.rain_mm_total
            state: "0"
        sequence:
          - service: input_number.set_value
            target:
              entity_id: input_number.rain_last_read
            data:
              value: "{{ states('sensor.rain_mm_total') | float }}"
    default:
      - service: input_number.set_value
        target:
          entity_id: input_number.rain_this_hour
        data:
          value: |
            {{ (states('input_number.rain_this_hour') | float) +
               (states('sensor.rain_mm_total') | float) -
               (states('input_number.rain_last_read') | float) }}
      - service: input_number.set_value
        target:
          entity_id: input_number.rain_this_day
        data:
          value: |
            {{ (states('input_number.rain_this_day') | float) +
               (states('sensor.rain_mm_total') | float) -
               (states('input_number.rain_last_read') | float) }}
      - service: input_number.set_value
        target:
          entity_id: input_number.rain_this_week
        data:
          value: |
            {{ (states('input_number.rain_this_week') | float) +
               (states('sensor.rain_mm_total') | float) -
               (states('input_number.rain_last_read') | float) }}
      - service: input_number.set_value
        target:
          entity_id: input_number.rain_this_month
        data:
          value: |
            {{ (states('input_number.rain_this_month') | float) +
               (states('sensor.rain_mm_total') | float) -
               (states('input_number.rain_last_read') | float) }}
      - service: input_number.set_value
        target:
          entity_id: input_number.rain_last_read
        data:
          value: "{{ states('sensor.rain_mm_total') | float }}"

Automation to update hourly, daily, weekly and monthly:

alias: Update Rainfall Data
description: Opdaterer regndata pÄ forskellige tidsintervaller
trigger:
  - platform: time_pattern
    seconds: "0"
condition: []
action:
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ now().minute == 0 }}"
        sequence:
          - service: input_number.set_value
            target:
              entity_id: input_number.rain_last_hour
            data:
              value: "{{ states('input_number.rain_this_hour') | float }}"
          - service: input_number.set_value
            target:
              entity_id: input_number.rain_this_hour
            data:
              value: 0
  - choose:
      - conditions:
          - condition: template
            value_template: >-
              {{ now().hour == 0 and now().minute == 0 and now().second >= 0 and
              now().second <= 20 }}
        sequence:
          - service: input_number.set_value
            target:
              entity_id: input_number.rain_last_day
            data:
              value: "{{ states('input_number.rain_this_day') | float }}"
          - service: input_number.set_value
            target:
              entity_id: input_number.rain_this_day
            data:
              value: 0
  - choose:
      - conditions:
          - condition: template
            value_template: >-
              {{ now().weekday() == 0 and now().hour == 0 and now().minute == 0
              and now().second >= 0 and now().second <= 20 }}
        sequence:
          - service: input_number.set_value
            target:
              entity_id: input_number.rain_last_week
            data:
              value: "{{ states('input_number.rain_this_week') | float }}"
          - service: input_number.set_value
            target:
              entity_id: input_number.rain_this_week
            data:
              value: 0
  - choose:
      - conditions:
          - condition: template
            value_template: >-
              {{ now().day == 1 and now().hour == 0 and now().minute == 0 and
              now().second >= 0 and now().second <= 20 }}
        sequence:
          - service: input_number.set_value
            target:
              entity_id: input_number.rain_last_month
            data:
              value: "{{ states('input_number.rain_this_month') | float }}"
          - service: input_number.set_value
            target:
              entity_id: input_number.rain_this_month
            data:
              value: 0
mode: single

Data in configuration.yaml:

mqtt: 
  - sensor: &rain_sensor
      name: Rain Total
      device:
        name: Rain
        identifiers: rainfall
      unique_id: rain_mm_total
      unit_of_measurement: mm
      state_topic: rtl_433/AlectoV1-Rain/206/rain_mm

input_number:
  rain_last_read:
    name: Rain Last Read
    min: 0
    max: 1000
    step: 0.01
    unit_of_measurement: 'mm'
  rain_this_hour:
    name: Rain This Hour
    min: 0
    max: 1000
    step: 0.01
    unit_of_measurement: 'mm'
  rain_last_hour:
    name: Rain Last Hour
    min: 0
    max: 1000
    step: 0.01
    unit_of_measurement: 'mm'
  rain_this_day:
    name: Rain This Day
    min: 0
    max: 1000
    step: 0.01
    unit_of_measurement: 'mm'
  rain_last_day:
    name: Rain Last Day
    min: 0
    max: 1000
    step: 0.01
    unit_of_measurement: 'mm'
  rain_this_week:
    name: Rain This Week
    min: 0
    max: 1000
    step: 0.01
    unit_of_measurement: 'mm'
  rain_last_week:
    name: Rain Last Week
    min: 0
    max: 1000
    step: 0.01
    unit_of_measurement: 'mm'
  rain_this_month:
    name: Rain This Month
    min: 0
    max: 1000
    step: 0.01
    unit_of_measurement: 'mm'
  rain_last_month:
    name: Rain Last Month
    min: 0
    max: 1000
    step: 0.01
    unit_of_measurement: 'mm'
  left_markise_position:
    name: Venstre Markise Position
    min: 0
    max: 100
    step: 1
    unit_of_measurement: "%"
  right_markise_position:
    name: HĂžjre Markise Position
    min: 0
    max: 100
    step: 1
    unit_of_measurement: "%"
  kitchen_markise_position:
    name: KĂžkken Markise Position
    min: 0
    max: 100
    step: 1
    unit_of_measurement: "%"

sensor:
  - platform: template
    sensors:
      rain_this_hour_display:
        unique_id: rain_this_hour_display
        friendly_name: "Rain This Hour Display"
        unit_of_measurement: mm
        value_template: "{{ states('input_number.rain_this_hour') }}"
        icon_template: "mdi:weather-rainy"

      rain_last_hour_display:
        unique_id: rain_last_hour_display
        friendly_name: "Rain Last Hour Display"
        unit_of_measurement: mm
        value_template: "{{ states('input_number.rain_last_hour') }}"
        icon_template: "mdi:weather-rainy"

      rain_this_day_display:
        unique_id: rain_this_day_display
        friendly_name: "Rain This Dat Display"
        unit_of_measurement: mm
        value_template: "{{ states('input_number.rain_this_day') }}"
        icon_template: "mdi:weather-rainy"

      rain_last_day_display:
        unique_id: rain_last_day_display
        friendly_name: "Rain Last Day Display"
        unit_of_measurement: mm
        value_template: "{{ states('input_number.rain_last_day') }}"
        icon_template: "mdi:weather-rainy"

      rain_this_week_display:
        unique_id: rain_this_week_display
        friendly_name: "Rain This Week Display"
        unit_of_measurement: mm
        value_template: "{{ states('input_number.rain_this_week') }}"
        icon_template: "mdi:weather-rainy"

      rain_last_week_display:
        unique_id: rain_last_week_display
        friendly_name: "Rain Last Week Display"
        unit_of_measurement: mm
        value_template: "{{ states('input_number.rain_last_week') }}"
        icon_template: "mdi:weather-rainy"

      rain_this_month_display:
        unique_id: rain_this_month_display
        friendly_name: "Rain This Month Display"
        unit_of_measurement: mm
        value_template: "{{ states('input_number.rain_this_month') }}"
        icon_template: "mdi:weather-rainy"

      rain_last_month_display:
        unique_id: rain_last_month_display
        friendly_name: "Rain Last Month Display"
        unit_of_measurement: mm
        value_template: "{{ states('input_number.rain_last_month') }}"
        icon_template: "mdi:weather-rainy"


 and the code for the card:

type: entities
title: Rain Data
entities:
  - entity: sensor.rain_this_hour_display
    name: Denne Time
  - entity: sensor.rain_last_hour_display
    name: Sidste time
  - entity: sensor.rain_this_day_display
    name: I dag
  - entity: sensor.rain_last_day_display
    name: I gÄr
  - entity: sensor.rain_this_week_display
    name: Denne uge
  - entity: sensor.rain_last_week_display
    name: Sidste uge
  - entity: sensor.rain_this_month_display
    name: Denne mÄned
  - entity: sensor.rain_last_month_display
    name: Sidste mÄned