class
PlaceOS::Driver::Presence::Smoother
Overview
Smooths the output of an unreliable presence sensor over a sliding time window, latching the state and only switching once the opposing signal dominates the window. Compose one instance per sensor.
Defined in:
placeos-driver/interface/presence_smoother.crConstructors
Instance Method Summary
-
#confidence(now : Time::Instant = Time.instant) : Float64 | Nil
Returns confidence in the current smoothed output state, from 0.0 to 1.0.
-
#confidence_percent(now : Time::Instant = Time.instant) : Float64 | Nil
Returns confidence in the current smoothed output state as a percentage.
-
#observe(state : Bool, at : Time::Instant = Time.instant) : Nil
Records a raw sensor state.
- #output_state : Bool | Nil
-
#poll(now : Time::Instant = Time.instant) : Snapshot | Nil
Evaluates the current sliding window and returns the smoothed state, confidence and supporting information.
- #raw_state : Bool | Nil
Constructor Detail
Instance Method Detail
Returns confidence in the current smoothed output state, from 0.0 to 1.0.
Calling this also evaluates whether the smoothed state should change.
Returns confidence in the current smoothed output state as a percentage.
For example, 56.3 means 56.3% confidence.
Records a raw sensor state.
The first observation establishes the initial smoothed output state. Repeated observations of the same state are ignored because the state continues accumulating time without requiring another transition.
Evaluates the current sliding window and returns the smoothed state, confidence and supporting information.
Returns nil until the first sensor observation.