Templating Total Solar Production Today

I have multiple inverters running.
The main roof is connected to an E3DC S10 which provides me with a daily production sensor (sensor.s10_solar_production_today). It is reset to 0kWh at midnight and starts counting as soon as the sun comes out.
I would like to create a template sensor to add the solar production of my two Hoymiles inverters (sensor.hoymiles_hm_1500_yieldtotal & sensor.hoymiles_hm_800_yieldtotal). However their sensor is only populated, when the sun is out (i.e. at night, the senosr is set to Unavailable

How can I correctly remember its last value after sunset, reset to zero at midnight and use the default of zero until sunrise? I tried using a helper adding the three sensors, but its value becomes Unavailable as soon as the hoymiles go into sleep.

After a firmware update to the Open DTU, I found out that the DTU itself already provides a Total Yield Day sensor, which does not go unavailable, when the inverters go to sleep. I therefore do no longer need a template entity.

However, if anyone is interested, the template sensor should be something like this:

- trigger:
    - platform: state
      entity_id: sensor.hoymiles_hm_1500_yieldday
      not_to:
        - "unknown"
        - "unavailable"
    - platform: template
      value_template: "{{ now().hour == 0 }}" #resets each day
  sensor:
    # the value of this sensor is only updated
    # if the state of the entity_id is NOT 'unknown' or 'unavailable'
    - name: hoymiles_hm_1500_yieldday_preserved
      state: "{{ '0' if trigger.platform == 'template' else trigger.to_state.state | float(0) }}"
      device_class: energy
      unit_of_measurement: "kWh"
      unique_id: "64ec7a3c-cd78-43b7-a7c1-8821db839025"