Power Calculation Between Certain Times

Hi all, im hoping someone can help.

I’m hoping to create a template sensor that gives me the total amount of Solar i have sold back to the grid from when my Inverter becomes available after sunrise until it becomes unavailable after sunset. I know HA has this as a Graph called Net returned to the grid.

SO far i have this, but i need it to be calculated daily. Is there a way to do this all in the same template??

 #### Net Solar Sold To grid
      - name: "Net Solar Sold To Grid"
        icon: mdi:transmission-tower-export
        unit_of_measurement: "kWh"
        state: "{{ states('sensor.fronius_real_energy_consumed')|float / 1000  | round(2) - states('sensor.fronius_real_energy_produced')|float / 1000  | round(2) }}"
        device_class: energy
        state_class: total_increasing
        availability: "{{ states('sensor.fronius_real_energy_consumed')|is_number and states('sensor.fronius_real_energy_produced')|is_number }}"

Feed that sensor to a utility meter with a daily cycle.

yeah i have now, cheers

Just unsure which to select

Net consumption or Delta?


Net consumption allows the reading to go backwards. You don’t want this as your sensor is always reporting in one direction (to grid).

Delta is for sensors that only report the change between readings. Yours is not this. It is an always increasing sensor.

So don’t set either of those options to true.

Ahh thanks for the better explanation! make sense