jonbloom / homebridge-ufp

Unifi Protect plugin for homebridge: https://github.com/nfarina/homebridge
Apache License 2.0
2 stars 0 forks source link

homebridge-ufp

Unifi Protect plarform plugin for Homebridge

This plugin is intended to automatically configure all the cameras you have setup in UniFi Protect to make them available via HomeKit. It requires the camera-ffmpeg plugin in order to provide that functionality.

This package is based on the excellent work of homebridge-camera-unifi.

Why use this homebridge plugin?

This plugin aims to be a one-stop-shop for UniFi Protect to HomeKit connectivity. Over time, it is my hope to add motion sensors and any other capabilities that make sense to this plugin to enable HomeKit users to easily connect the UniFi Protect and HomeKit worlds.

Installation

If you are new to Homebridge, please first read the Homebridge documentation. If you are running on a Raspberry, you will find a tutorial in the homebridge-punt Wiki.

Install homebridge:

sudo npm install -g homebridge

Install homebridge-ufp:

sudo npm install -g homebridge-ufp

You will need a working ffmpeg installation for this plugin to work. Configuring ffmpeg is beyond the scope of this manual. Please refer to the excellent documentation for camera-ffmpeg.

Finally, adding cameras requires the same steps outlined in camera-ffmpeg. Install the accessories and use the Homebridge setup code for the camera accessories.

Configuration

Add the platform in config.json in your home directory inside .homebridge.

If you're using a UniFi Protect device that is not running UniFi OS (UDM-Pro < 1.6, UniFi NVR-4 < 1.3.0, or CloudKey Gen2+), you can use the following config (note the port 7443).

"platforms": [
  {
    "platform": "Camera-UniFi-Protect",
    "name": "UniFi Protect",

    "controllers": [
      {
        "url": "https://my-ufp-device:7443",
        "username": "some-homebridge-user (or create a new one just for homebridge)",
        "password": "some-password"
      }
    ]
  }
]

If you're using a device running UniFi OS (UDM-Pro ≥ 1.6.0, UniFi NVR-4 ≥ 1.3.0), drop the port and use your regular Ubiquiti Account credentials. This does not currently support 2FA. You may also be able to create a read-only account, but this has not been tested.

"platforms": [
  {
    "platform": "Camera-UniFi-Protect",
    "name": "UniFi Protect",

    "controllers": [
      {
        "url": "https://my-ufp-device",
        "username": "your-ubiquiti-account",
        "password": "your-ubiquiti-password"
      }
    ]
  }
]

Advanced Configuration (Optional)

This step is not required. For those that prefer to tailor the defaults to their liking, here are the supported parameters.

"platforms": [
  {
    "platform": "Camera-UniFi-Protect",
    "name": "UniFi Protect",
    "videoProcessor" : "/usr/local/bin/ffmpeg",

    "controllers": [
      {
        "url": "https://my-ufp-device",
        "username": "some-homebridge-user (or create a new one just for homebridge)",
        "password": "some-password"
      }
    ],

    "videoConfig": {
        "sourcePrefix": "-re -rtsp_transport http",
        "additionalCommandline": "-preset slow -profile:v high -level 4.2 -x264-params intra-refresh=1:bframes=0",
        "mapaudio": "0:0",
        "mapvideo": "0:1",
        "maxStreams": 4,
        "maxWidth": 1920,
        "maxHeight": 1080,
        "maxFPS": 20
    } 
  }
]
Fields Description Default Required
platform Must always be Camera-UniFi-Protect. Yes
name For logging purposes. No
videoProcessor Specify path of ffmpeg or avconv "ffmpeg" No
url URL for your UniFi Protect NVR Yes
username Your UniFi Protect username Yes
password Your UniFi Protect password Yes
sourcePrefix Prefix to apply to ffmpeg source command. "-re -rtsp_transport http" No
additionalCommandline Additional parameters to pass ffmpeg to render video. "-preset slow -profile:v high -level 4.2 -x264-params intra-refresh=1:bframes=0" No
mapaudio Mapping of audio channels for ffmpeg. "0:0" No
mapvideo Mapping of video channels for ffmpeg. "0:1" No
maxStreams Maximum number of streams allowed for a camera. 4 No
maxWidth Maximum width of a video stream allowed. 1920 No
maxHeight Maximum height of a video stream allowed. 1080 No
maxFPS Maximum framerate for a video stream. 20 No