Peaks in template sensors

Hi,

I have a problem with peaks in template sensors. They occurs sometimes after HA restart or host restart (not after every) . For example:
My template sensor:

- name: Licznik wody użytkowej
  state: "{{((states('sensor.glowny_licznik_wody')) | float - (states('sensor.licznik_wody_ogrodowej'))| float) | round (2) }}"

After HA host restart sometimes I have wrong values for a while and this peaks are counted by utility meter.

Any suggestions what is wrong?

Try setting an availibility for your template sensor.

OK, but it should return non-zero value and Attribute available returns:

If the template either fails to render or returns either of True , "1" , "true" , "yes" , "on" , "enable" or a non-zero number, the entity is available