Return to grid on daily basis in kWh

Hope you can give me a hand here:
I have a bitshake smartreader collectiong data from a powermeter which shows return to grid as negative values on one sensor.

I created a template sensor to do the work:

- sensor:
        name: Einspeisung Jetzt
        unique_id: "einspeisung_jetzt"
        unit_of_measurement: "W"
        device_class: power
        state: "{{ -1 * states('sensor.bitshake_smartmeterreader_mt175_p')|float(0) if states('sensor.bitshake_smartmeterreader_mt175_p') |float(0) < 0 else 0 }}"

I’ve already successfully created a few automations based on this, for instance starting a heatpump when negative values are above a certain level etc. That works quite fine.

Q: How can I show “Return to grid today” ? All attempts so far did not reset at midnight …
Thanks in advance for your help.

Rieman sum Integration helper (with left sum) will allow you to convert W to kWh combined with a utility meter helper should get you what you’re after.

Hi brooksben11, thanks for your reply.
that’s exactly what I was after.