The only problem is that in some rare cases the magnet maybe stops in the right spot to trigger the hall sensor?
Why is that a problem? The sensor will change state when the magnet comes near, and will change state when the magnet moves away. if the magnet never comes, or it the magnet never goes away, there will be no change in state, and the time that the state last changed will get older and older. At some point, it will be old enough that you can scream for help.
Out of 360° then there is 1 to 8 chance that it will stop in the right spot to trigger the sensor?
Maybe it's one in 14. You are the one with the hardware. Don't ask us questions about hardware we can't see.
So the code also needs a line that's trigger the piezo pwm output if it's a solid high or low,
If what is a solid high or low? See the comments under the first quote. It is the age of the last change that is important, NOT anything about the current state.
It depends on what the sensor gives out?
Of course it does.
It should be possible to write a code that is universal?
No. If you change sensors, to something that is more intelligent (does some of the work for you), you would want to take advantage of that intelligence.
I don't think it's needed to do it by math?
The age of a change is now minus then. Oops, that involves math... Good thing that the Arduino is REALLY good at math.
Or in any kind of precision?
Well, in that case, don't bother reading the sensor. Just call random() to determine whether to sound the alarm.
There will not be any value to actually read?
Of course there will be.
for an LCD or the serial monitor?
You won't be reading values from either of them to determine if the pump is still running.
Do you understand what I mean?
I thought I did. Now, I'm not sure.
Have you written ANY code to try to get anything from the sensor?