# `BB.Controller.Threshold`
[🔗](https://github.com/beam-bots/bb/blob/main/lib/bb/controller/threshold.ex#L5)

Convenience wrapper around PatternMatch for threshold monitoring.

Transforms threshold options into a PatternMatch configuration and
delegates all message handling to PatternMatch.

## Options

- `:topic` - PubSub topic path to subscribe to (required)
- `:field` - Field path to extract from message payload (required)
- `:min` - Minimum acceptable value (at least one of min/max required)
- `:max` - Maximum acceptable value (at least one of min/max required)
- `:action` - Action to trigger when threshold exceeded (required)
- `:cooldown_ms` - Minimum ms between triggers (default: 1000)

## Example

    controller :over_current, {BB.Controller.Threshold,
      topic: [:sensor, :servo_status],
      field: :current,
      max: 1.21,
      action: command(:disarm)
    }

This is equivalent to:

    controller :over_current, {BB.Controller.PatternMatch,
      topic: [:sensor, :servo_status],
      match: fn msg -> Map.get(msg.payload, :current) > 1.21 end,
      action: command(:disarm)
    }

---

*Consult [api-reference.md](api-reference.md) for complete listing*
