I am Setting up an automatic refill system for a swimming pool. I have a float-switch that operates when the pool reaches a preset level. That all work fine.
The issue I need to address has to do with removing noise from the float-switch. That is, as it nears the switch point, it oscillates (1 or more times per second) between On (low water) and Off (pool full). These fluctuations are caused by surface turbulence in the pool. I have a lot of damping between the pool and float-switch, but I still get oscillations. Since the difference between On and Off is <2mm, I could just ignore the oscillation and accept the level at whatever time I test it (that is done once a day). But, just to keep things clean, I would like to define two states: low and full and store that value in a variable, and update it no more than once a minute, maybe once every 5 minutes.
The question is how to do this. I have thought of a few ways, but I really wanted to see what creative (and maybe even elegant) suggestions the community here might have.
Here is a quick summary of the challenge: I have an Indigo Device which represents the float-switch. It has one state: on or off. I wish to maintain a variable which indicates some smoothing of the device state. It could be an average, last observed, or whatever you think might be appropriate. One note. It is better to error in the direction of stating the pool is full, when it is actually slightly low. That is, over-filling is worse than too low a water level.
Ideas?
BTW, just to keep this interesting, I'd like to try to do this using standard Indigo features. I.e., avoiding custom scripting.