How to reset the value of a sensor every night?

Hi,
I’m rather new to HA but was able to realize many ideas.
Unfortunately, I’m now struggling with an probably very easy question: How Can I reset the value of an sensor every night?

Some background: I want to calculate the efficieny of my solar panels in the format kWh/kWp.
For this I have created a sensor called “NO_Effizienzmultiplikator” that gives me exactly this value. The example given is just for one of the panels.

    - name: NO Effizienzmultiplikator
      unique_id: NO_Effizienzmultiplikator
      state: >-
        {{ ((states('sensor.no_erzeugung_kwh')|float) / 12.96)|round(2)|float }}
      unit_of_measurement: "kWh/kWp"
      device_class: power_factor
      state_class: measurement

So far so good.

The problem is that sensor.no_erzeugung_kwh was created as a Riemann sum integral (left) helper. Unfortunately it does not start from zero every day but just adds the yield from the next day on top.

Therefore I thought I could use an automation that resets the sensor value every night. But this piece of code doesn’t work.

alias: NO & SO Erzeugungszähler auf Null setzen um Mitternacht.
description: ""
trigger:
  - platform: time
    at: "00:00:00"
condition: []
action:
  sensor:
    name: "NO Erzeugung kWh"
    state: "{{ 0 }}"

As soon as I click the Save button I get the following error message:
Message malformed: Unable to determine action @ data[‘action’][0]

It’s probabaly a stupid coding error? Please advise.

PS: I also tried to store the current value of the helper in a variable at midnight and then to subtract it the next day from the helper value which continues to increase. But here I was also struggling. Didn’t manage it to store the value…

Anyways, thanks for your support in advance.

You have to create side sensors that will give you daily, monthly, hourly data as you like.

utility_meter:
  NO_Effizienzmultiplikator_täglich:
    source: sensor.NO_Effizienzmultiplikator
    cycle: daily

I never used utility_meter with other things than kwh sensors, but give it a try.

Merci beaucoup.
I will try it!

Can you tell if it worked?

sorry, I haven’t seen your question.
No, unfortunately it didn’t work.

It is working, I’m doing that for my fridge
First, the Riemann helper (sorry, no code, defined with the UI

Then, utilities

  frigo_energy_monthly:
    source: sensor.frigo_cr_328_azd_conso
    cron: 0 0 1 * *
  frigo_energy_daily:
    source: sensor.frigo_cr_328_azd_conso
    cron: 0 0 * * *
  frigo_energy_weekly:
    source: sensor.frigo_cr_328_azd_conso
    cron: 0 0 * * 1

I did them with cron, as I got some issues of no reset sometimes with the default daily/weekly/monthly cycles.

And here are some data
Riemann sensor


And utilities

My monitoring plug is disconnected right now, it was making my breaker to off.