Template entity shows the wrong value

Hi, I have created the following template, and sometimes the sensor shows a different value (100%) than the graph below (65%). It doesn’t happen every time, but sometimes it shows 100% instead of the correct value.
Thanks

  - platform: template
    sensors:
      self_consumption_solar_battery_devide_load_consumption_monthly:
        friendly_name: "Podíl vlastní výroby na spotřebu - měsíční"
        icon_template: mdi:home-lightning-bolt-outline
        value_template: "{{ ( states('sensor.spotreba_z_vlastni_vyroby_mesicni_new') | float / states('sensor.spotreba_energie_mesicni_new') | float * 100) | round(1) }}"
        unit_of_measurement: '%'

That’s a problem with the history chart that pops up on the quick view.

Any idea how to solve it? The entity state is dislayed everywhere like “100%”.