Peak at the first hour of the day in energy dashboard

My sensor for resets daily a few seconds after midnight, so in the energy dashboard there is a peak at the first hour.

I created a utility meter, but there is production displayed where no production was

.

The sensor for the daily yield:

  - sensor:
      - name: "energy_pv_daily"
        unique_id: "PV Energy daily"
        state: >
          {{ (states('sensor.inverters_total_daily_yield') | float) - (states('sensor.battery_1_tagesentladung') | float) + (states('sensor.battery_1_tagesladung') | float) }}
        device_class: energy
        state_class: total_increasing
        unit_of_measurement: 'kWh'

If you create a template sensor like that, you should also create an availability template for it. Also, if these sensors reset dayly, but at slightly different times, you will get weird results.

But most importantly, why do you calculate with them, instead of listing them individually in the dashboard in the places they need to be? The dashboard wants these separately.

According to the integration (Daily Solar Yield · wlcrs/huawei_solar Wiki · GitHub) I use the daily energy should be calculated like that.

I added the availability to the sensor

  - sensor:
      - name: "energy_pv_daily"
        unique_id: "PV Energy daily"
        state: >
          {{ (states('sensor.inverters_total_daily_yield') | float) - (states('sensor.battery_1_tagesentladung') | float) + (states('sensor.battery_1_tagesladung') | float) }}
        device_class: energy
        state_class: total_increasing
        unit_of_measurement: 'kWh'
        availability: >-
            {{ 
            (states('sensor.inverters_total_daily_yield')|is_number)
            and (states('sensor.battery_1_tagesentladung') |is_number) 
            and (states('sensor.battery_1_tagesladung')|is_number) 
            }}        

I found a workaround by not measuring for the first hour of the day

  - sensor:
      - name: "PV Energy daily Helfer"
        unique_id: "filtered_sensor_id"
        state: >
          {% if now().hour >= 1 or now().hour < 0 %}
             {{ (states('sensor.inverters_total_daily_yield') | float) - (states('sensor.battery_1_tagesentladung') | float) + (states('sensor.battery_1_tagesladung') | float) }}
          {% else %}
            0
          {% endif %}
        device_class: energy
        state_class: total_increasing
        unit_of_measurement: 'kWh'
        availability: >-
            {{ 
            (states('sensor.inverters_total_daily_yield')|is_number)
            and (states('sensor.battery_1_tagesentladung') |is_number) 
            and (states('sensor.battery_1_tagesladung')|is_number) 
            }}