Search documentation of bb

# BB.Controller.PatternMatch (bb v0.17.0)

Copy Markdown 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)
    }