Substitute sensor value

In the Swimming pool that uses 2 pumps (one for heating, one for filtration) I have a water Temperature sensor, that measures temperature from the boiler room in the circulation contour. Whenever Filtration pump turns off, the water Temperature sensor shows distorted temperature (like 53C or smth) as without water circulation it measures the heat-exchanger temp in fact.
Is there a lifehack to substitute the Sensor data with “N/A” or smth else when a Filtration pump switch is turned OFF?