class

PlaceOS::Driver::Presence::Smoother

Inherits Reference < Object

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.

Constructors

new(window : Time::Span = 3.minutes, threshold : Float64 = 0.70)
Source

Instance methods

confidence(now : Time::Instant = Time.instant) : Float64 | Nil

Returns confidence in the current smoothed output state, from 0.0 to 1.0.

Calling this also evaluates whether the smoothed state should change.

Source
confidence_percent(now : Time::Instant = Time.instant) : Float64 | Nil

Returns confidence in the current smoothed output state as a percentage.

For example, 56.3 means 56.3% confidence.

Source
observe(state : Bool, at : Time::Instant = Time.instant) : Nil

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.

Source
output_state
Source
poll(now : Time::Instant = Time.instant) : Snapshot | Nil

Evaluates the current sliding window and returns the smoothed state, confidence and supporting information.

Returns nil until the first sensor observation.

Source
raw_state
Source

Nested types