Daily Rain at a configurable time of day

I have automated my Garden sprinklers using Smart irrigation custom component.

This uses the daily rainfall as one of the calculation inputs. Now I want to run the sprinklers at 6 in the morning, but my Netatmo daily rain sensor resets at Midnight.

Since I also want to use rain that falls between then and 6 in the morning for the calculation, I need a way to store last days value showrtly before midnight and add anything that comes in after.
Also the value measured till 6 has to be subtracted the next day.

How can I achieve this?

Meanwhile I have come up with a solution myself.

It uses an input_number helper, 2 Automations and a template sensor.

Automation to store rain fallen until 6 in the morning:

alias: Store rain at 6
trigger:
  - platform: time
    at: '06:01:00'
condition: []
action:
  - service: input_number.set_value
    data_template:
      value: '{{ states("sensor.netatmo_regenmesser_rain_today") | float }}'
      entity_id: input_number.regenspeicher
mode: single

Before the reset of rain_today at midnight, the same input_number is used to store rain from 6-24 (subtracting rain until 6 o’clock from the total of the day):

alias: Store rain before 12
trigger:
  - platform: time
    at: '23:59:00'
condition: []
action:
  - service: input_number.set_value
    data_template:
      value: >-
        {{ (states("sensor.netatmo_regenmesser_rain_today") | float -
        states("input_number.regenspeicher") | float) | round(1) }}
      entity_id: input_number.regenspeicher
mode: single

Since Smart Irrigation expects the rain amount from a sensor, I defined a template sensor, that adds the stored value to the current rain_today:

template:
  - sensor:
    - name: "rain_at_six"
      state: '{{ states("sensor.netatmo_regenmesser_rain_today") | float + states("input_number.regenspeicher") | float }}'
      unit_of_measurement: "mm"

The input number will also be persistant in case of a restart.

Just finished the coding, now I am curious if it will work as intended.

Edit: template sensor was derived from the old format - new one is not allowed to have a friendly_name.

After having some rain the last two nights, I can confirm this solution works.

Note that the sensor really only shows a correct value at the selected time.