BB.Controller.PatternMatch (bb v0.15.0)

View Source

Controller that triggers an action when a message matches a predicate.

This is the base reactive controller implementation. Other reactive controllers like BB.Controller.Threshold are convenience wrappers around this module.

Options

  • :topic - PubSub topic path to subscribe to (required)
  • :match - Predicate function fn msg -> boolean end (required)
  • :action - Action to trigger on match (required)
  • :cooldown_ms - Minimum ms between triggers (default: 1000)

Example

controller :collision, {BB.Controller.PatternMatch,
  topic: [:sensor, :proximity],
  match: fn msg -> msg.payload.distance < 0.05 end,
  action: command(:disarm)
}