Can a Script Flag Repeated Sensor Readings?
From the earlier reference collection. Read the current software blog.
A conservative detector can identify suspicious runs of identical sensor values while preserving every reading for review.
Treat repetition as a clue
A run of identical sensor readings can mean several things. A real quantity may have stayed steady; a sensor may have stalled; or an upstream system may have repeated the last available value. A script should therefore flag a pattern for investigation, not delete records or declare a fault. Keep the original timestamps and values intact, and add a separate review marker with the reason it was raised.
First define what counts as identical. A temperature feed might record values rounded to one decimal place, so repeated displayed values do not prove the underlying measurement was unchanged. Decide whether the detector compares stored values exactly, normalized values, or values after an explicitly documented rounding step. Avoid applying an arbitrary tolerance without knowing the sensor’s precision and expected behavior.
Build runs in time order
Sort readings by sensor identifier and timestamp before scanning them. For each sensor, maintain the current value, the start time of its run, and the number of consecutive records. When a different value appears, close the previous run and begin another. A missing timestamp or invalid reading should break the run rather than being skipped as though the sequence were continuous.
For example, readings of 18.2 at 10:00, 10:05, 10:10, and 10:15 form four consecutive identical records. If the review rule is at least four records spanning fifteen minutes, flag that interval. A second sensor with the same four values over a different span should be evaluated independently; readings from separate devices must never be combined into one run.
Make the rule inspectable
Choose thresholds based on the sampling interval and the purpose of the review. A rule can require both a minimum record count and a minimum elapsed duration. The count reduces noise from occasional duplicates; the duration makes the rule meaningful when samples arrive irregularly. Report the observed count, interval, value, and threshold so that an operator can see why a marker exists.
Handle irregular sampling deliberately. Four identical values collected over three minutes may be less concerning than four values over several hours, but a long gap between two samples should not automatically imply that the sensor was stuck throughout the gap. Record the first and last observed timestamps, and describe the span as observed coverage rather than claiming continuous measurement.
Preserve evidence and review outcomes
Store flags alongside the data or in a separate findings table keyed to stable reading identifiers. A finding might include a rule version, run start and end, record count, and review status. This lets a human mark a pattern as expected without changing the raw observations. Re-running the detector should update or reproduce findings predictably rather than add duplicates each time.
Test ordinary variation, a long constant run, a short run, a missing sample, and a sensor change. Include a case where a legitimate stable value is flagged: the point is to verify that the alert is understandable and reversible. A useful detector helps people decide where to look; it does not turn an ambiguous pattern into a certainty.