Energy Management and total_increasing sensor

Hi,
I am really happy with the Home Assistant energy module.
I had a small problem with the total_increasing type sensors: at the first change of the month it seems to have added the total value.

This is the definition of my sensor

template:
  - sensor:
      - name: "Solar Energy 2"
        unit_of_measurement: "kWh"
        device_class: energy
        state_class: total_increasing
        state: >-
          {%- if states.sensor.solar_report.attributes.dati.total|float >= 0 -%}
            {{ states.sensor.solar_report.attributes.dati.total }}
          {%- else -%}
            nan
          {%- endif -%}

Has anyone had the same problem?