npm package: @roftebro88/n8n-nodes-unifip
Description: N8n community node for UniFi Protect API
Author: roftebro88
Latest version: 0.2.1

# n8n-nodes-unifip

This is an n8n community node that provides integration with UniFi Protect, the video surveillance and smart home platform from Ubiquiti.

[n8n](https://n8n.io/) is a fair-code licensed workflow automation platform.

## Installation

Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in the n8n community nodes documentation.

### npm

```bash
npm install @roftebro88/n8n-nodes-unifip
```

### Manual Installation

1. Navigate to your n8n installation directory
2. Install the package:
   ```bash
   npm install @roftebro88/n8n-nodes-unifip
   ```
3. Restart n8n

## Operations

This node provides access to the following UniFi Protect resources:

### Bootstrap
- **Get**: Retrieve the complete system configuration including all devices and settings

### Camera
- **Get**: Get a specific camera by ID
- **Get Many**: Get all cameras
- **Update**: Update camera settings (name, recording mode, HDR, status light)
- **Get Snapshot**: Get a snapshot image from a camera

### Doorbell
- **Get**: Get a specific doorbell by ID
- **Get Many**: Get all doorbells

### Event
- **Get**: Get a specific event by ID
- **Get Many**: Get events with filtering options
  - Filter by time range (start/end)
  - Filter by event type (motion, ring, smart detect)
  - Filter by camera
  - Limit results

### File Management
- **Download Recording**: Download video recordings from cameras
  - Specify time range (start/end)
  - Choose video quality (high, medium, low)
  - Custom filename support
- **Get Recording Thumbnail**: Extract a still image from a recording at a specific timestamp
  - Specify exact timestamp for the frame
  - Optional width/height for resizing
  - Returns image as binary data
- **Upload Custom Image**: Upload custom images to doorbells
  - LCD message backgrounds
  - Custom doorbell messages (Do Not Disturb, Leave Package, etc.)
  - Duration settings

### Light
- **Get**: Get a specific light by ID
- **Get Many**: Get all lights
- **Update**: Update light settings (name, on/off, mode)

### Sensor
- **Get**: Get a specific sensor by ID
- **Get Many**: Get all sensors
- **Update**: Update sensor settings (name, status light)

## Credentials

To use this node, you need to configure the following credentials:

- **Controller URL**: The URL of your UniFi Protect controller (e.g., `https://192.168.20.1` or `https://protect.local`)
- **Username**: Your UniFi Protect username
- **Password**: Your UniFi Protect password

## Finding Device IDs

**Important**: Device IDs in UniFi Protect are unique identifiers (UUIDs), **NOT** IP addresses or MAC addresses.

### What Device IDs Look Like
- Format: UUID (e.g., `5f7a9b2c3d4e5f6a7b8c9d0e`)
- NOT an IP address (e.g., ~~192.168.1.100~~)
- NOT a MAC address (e.g., ~~AA:BB:CC:DD:EE:FF~~)

### How to Find Device IDs

1. **Using the Bootstrap operation**:
   - Select Resource: `Bootstrap`
   - Operation: `Get`
   - Run the node
   - The response contains all devices with their IDs under `cameras`, `lights`, `sensors`, etc.

2. **Using "Get Many" operations**:
   - Select the resource type (Camera, Light, Sensor, etc.)
   - Operation: `Get Many`
   - Run the node
   - Each device in the response will have an `id` field

3. **Example workflow**:
   - First node: Camera > Get Many → Returns all cameras with their IDs
   - Second node: File Management > Get Recording Thumbnail → Use the `id` from the first node

## Compatibility

Tested with:
- n8n version 1.0.0+
- UniFi Protect version 3.0+

## Resources

- [n8n community nodes documentation](https://docs.n8n.io/integrations/community-nodes/)
- [UniFi Protect library](https://github.com/hjdhjd/unifi-protect)

## License

[MIT](LICENSE.md)