Getting false gradient on trend sensor

I have 2 trend sensors to know whether the water in the water heater is getting hot or cold.
Here is my config for it:

- platform: trend
  sensors:
    water_temp_falling:
      entity_id: sensor.water_temperature
      sample_duration: 7200
      min_gradient: -0.001
      device_class: cold

    water_temp_rising:
      entity_id: sensor.water_temperature
      sample_duration: 7200
      min_gradient: 0.0030
      device_class: heat

I just noticed that pretty often the gradient is showing an invalid number.

Where normally I should get gradients like this:

Instead sometimes, I am getting gradients like this:

This is resulting in the binary sensor showing as “off” and automations I have created based on it, dont work. What is going on here?

I have tried removing the sensor, restarting HA and then enabling it again, but still the same issue. Anyone any ideas?