Subscribe events
protect_subscribe_eventsCapture real-time event messages from UniFi Protect devices by listening to the event WebSocket for a set duration, returning structured data for monitoring and automation.
Instructions
Connect to the Protect event WebSocket and collect messages for a specified duration (1-30s). Returns {messages, duration, error?, truncated?}; stops early with truncated=true after 200 messages or 100,000 characters of JSON, whichever comes first. A connection that fails before any message arrives returns an error. Each message is an envelope {type: 'add' | 'update', item: {id, modelKey: 'event', type (event kind, e.g. 'ring'), start, end (epoch ms), device (ID of the camera/sensor that raised it)}} (7.3.70 docs). The full set of event kinds and any further event fields are not documented — inspect the captured messages. Not available over Cloud Connector (api.ui.com).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| duration | No | Seconds to listen (1-30, default 5) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| error | No | Connection error, if any | |
| duration | No | Seconds actually spent listening, to 0.1s (number); shorter than requested when the message cap or an error ends the listen early | |
| messages | No | Captured WebSocket messages (add/update/remove or event envelopes) | |
| truncated | No | true when listening stopped early at the message cap (boolean, absent otherwise) |