protect_subscribe_devices
Subscribe to UniFi Protect device updates via WebSocket to capture real-time state changes (add, update, remove) for cameras, lights, sensors, and more. Use to monitor isRecording status, battery drops, or device adoptions.
Instructions
Connect to the device update WebSocket and collect messages for a specified duration (1-30s). Returns {messages, duration, error?}; each message has {type: 'add'|'update'|'remove', modelKey: 'camera'|'light'|'sensor'|..., id, payload: partial device fields that changed}. Use to detect state changes like isRecording flipping, battery drops, or new devices being adopted — fields delivered are only those that changed, not the full device object.
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 | Actual listen duration in seconds (number) | |
| messages | No | Captured WebSocket messages (add/update/remove or event envelopes) |