Categories
Home automation

UniFi Protect Cameras in HomeKit

This article describes how we use HomeBridge and HomeBridge UniFi Protect to bring UniFi Protect G4 camera video into HomeKit.

In an earlier article, I wrote about using EuFy wireless cameras in the latest HomeKit Secure Video enabled series to realize the Greyhound’s Doorbell. Since then, I have added a HomeBridge with HomeBridge UniFi Protect plugin to allow me to bring in the UniFi Protect G4 cameras. UniFi Protect is not currently integrated with any of the smart home ecosystems as Ubiquity’s primary market is professional network system integrators installing video surveillance and entry control systems.

Revisions

  • 2021-07-21 Original

References

  1. https://us.eufylife.com/collections/security?ref=navimenu
  2. https://github.com/hjdhjd/homebridge-unifi-protect#readme

How Dismal Manor uses Video Cameras

The cameras at Dismal Manor are placed to watch the dogs in the garden so I don’t have to stand around on the porch in a dubious state of dress for Rocky’s 0200 turnout. The cameras also tell me when dogs are dancing on the porch to come in. In addition, they show the fence line and will record any incidents occurring at the fence. So far, there have been none.

We use 2 UniFi Protect G4 Bullets to watch the Carport and the Porch. These cameras watch from the side so we can see blighters come and go. Motion detection grabs these. We can also see if a package delivery is sitting on the porch. When we add the EVSE charge point, we may have a camera watch it.

Rocky from the Back Garden G4 Pro

Why HomeKit

We use HomeKit because we like Apple’s architecture for HomeKit. When something leaves the lifelines, Apple has encrypted it locally and stores the item in encrypted form. The active HomeKit hub manages transmission to Apple and retrieval from Apple.

Oh, and we had the necessary hubs for other applications. HomeKit Hub is a collateral duty of AppleTV, Apple HomePod, and Apple iPad. We already had an AppleTV and an Apple HomePod for media playback.

And, HomeKit Secure Video is included with iCloud storage plans. Apple is changing the capacity and pricing with the iOS 15 iCloud rollout. Apple states that an account may have “unlimited” cameras.

Bridges vs Hubs

In HomeKit parlance, a bridge is an intermediate device that allows a family of products to communicate with a HomeKit hub. A HomeKit hub acts as a communication point for HomeKit devices, bridges, and controllers. Using the model, view, controller taxonomy, HomeKit hubs maintain the model. Controllers show views of data obtained from the hub and communicate with the hub to navigate through the data and control those devices that the hub can control.

Dismal Manor’s Kit

Dismal Manor HomeKit has a number of vendor specific and third party bridges.

Our Hubs

We have an Apple TV, an Apple Home Pod original, and an Apple HomePod mini that are pressed into service as HomeKit hubs. The HomePod mini was bought for that purpose because it contains a Thread Router (routes between 802.15.4 protocol and IP protocol). Thread is a protocol used with 802.15.4 devices to allow them to form a mesh network with leaf nodes, forwarding nodes, and routing nodes. 802.15.4 uses low energy signalling to communicate via IP datagrams. By using IP and UDP, routing out to HomeKit controllers is relatively easy. Google, Samsung, and other smart home majors are using Thread.

We are updating the AppleTV from AppleTV HD to AppleTV 4K. This update has 2 big changes, the processor changes from A8 to A12 Bionic. The BlueTooth changes from BlueTooth 4 to BlueTooth 5 and Thread networking is supported. Thread routes between IEEE 802.15.4 protocols and IP. Thread forms mesh networks reducing the need for repeaters.

The HomeKit Hub capable devices chat amongst themselves to determine which device will pick up hub chores. Here, the AppleTV grabs it, probably because it has a fast wired connection. The HomePods, though Hub capable, defer to the AppleTV.

Our Bridges

Dismal Manor’s HomeKit system has 4 bridges, two EuFy HomeBase bridges for the doorbell and wireless cameras. At present, the doorbell just is. EuFy hasn’t released HomeKit integration for the Doorbell product. EuFy has released HomeKit Secure Video integration for selected EuFy security products.

Our two third party bridges are a home brew HomeBridge and a purchased StarlingBridge. The HomeBridge supports a constellation of HomeKit sensors and cameras. The Starling Bridge supports Google devices of the Nest variety. It is most useful integrating Nest Cameras into a HomeKit environment. It also integrates the various Nest Thermsotat models and Nest Protect.

New EuFy Security Cameras go on sale

Since we made our purchase, EuFy has added new Solo products with built in motion activated yard light designed for use in the Amazon Alexa and Google Home environments. These cameras do not require a bridge reducing cost. These cameras are not currently integrated with HomeKit. EuFy’s future plans for HomeKit integration of Solo devices are unknown.

Integrating Unifi Protect Cameras with HomeKit

Ubiquity has not developed an official HomeKit (or other smart home system) integration for UniFi protect which it currently sees as a professional product. I would like to see Ubiquity do so as I will expain in a bit.

The HomeBridge UniFi Protect plugin does an excellent job integrating the UniFi Protect G4 cameras. If you have G3 cameras, I recommend upgrading to G4 cameras as they have much better object detection and smart object identification. These integrate by enabling RTSP streaming. Video is smooth and crystal clear but there may be some stuttering as the motion detection starts and stops streaming.

When a Home App selects a UniFi

HomeBridge also integrates UniFi Protect event notifications into HomeKit. When a camera senses motion, it will send a motion event to the UniFi Protect process controlling the camera. Protect forwards these to HomeBridge quite quickly. The UniFi Protect notification triggers HomeKit object recognition processing for people, vehicles, and animals. HomeKit then generates the proper HomeKit notification for delivery to subscribed Home endpoints.

Addition of HomeBridge to HomeKit is simple. Follow the instructions to scan the QR code produced by the bridge and your iPhone will add the bridge.

Unifi Protect Setup

Follow the HomeBridge Unifi Protect instructions for integrating cameras with your HomeKit. The enabling step is to add a read only user to UniFi Protect that HomeBridge UniFi Protect will use to monitor the cameras. Do not enable 2FA for this user as HomeBridge cannot generate FIDO codes at present.

For each camera you wish to include in HomeKit, enable its RTSP streaming service. HomeBridge UniFi Protect will discover the cameras. In HomeKit, name the cameras and put them in rooms as appropriate. We name our cameras in HomeKit by what they show and not where they are. We have found this makes camera selection easier.

Regular or Smart Motion

Regular motion zones report all motion but are fairly good at rejecting moving foliage and moving shadows by G4 Cameras. G3 cameras were always tricked by shadows and foliage making G3 motion detection pretty much useless in a home garden environment.

G4 camera Smart Motion can look for people or vehicles and is pretty good about filtering vehicles. It is not being fooled by transient headlamp illumination of terrain like G3 was. To detect the pets, you must use G4 motion detection.

Improved G4 Camera Event Detection.

HomeBridge UniFi Protect plugin is designed to receive and forward Ubiquity Protect G4 camera motion events. The G3 cameras were rubbish at motion detection. Shadow movement and wind blown foliage caused G3 events. To have the improved motion detection is our primary motivation for upgrading the cameras to G4.

The G4 cameras are very good at it. Shadow movement and foliage movement rarely trigger the G4 cameras, conserving storage and reducing monitoring load. They are good at filtering vehicles also. Car headlights would trigger the G3 series but not the G4 series.

HomeBridge UniFi Protect Plugin Events

The HomeBridge UniFi Protect plugin receives UniFi Protect events. The setup is to create a UniFi protect view only user. HomeBridge connects to Protect as that user, registers for events, and bridges them over to HomeKit.

The HomeKit event delivery model allows the device (iPhone, iPad, or Mac) to determine which events it will receive when at home or away and by time of day. HomeKit’s design uses the Notifier design pattern. The Notifier design pattern allows each delivery point to determine the event sources and types available and to register with the notifier (a hub) for those events that it desires. This, in practice, is pretty reliable.

HomeKit Integration adds Value to UniFi Protect

The biggest advantage HomeKit integration offers to UniFi protect is that it allows integration of a mixed bag of cameras into a single video system. In our system, UniFi Protect stores archival footage to support property damage reports. But UniFi Protect’s day job is to observe the dog’s behavior at the fence when I’m not with them. Recording is continuous and I can scrub through the footage to review an event. For example, one afternoon, there was some yelping from outdoors. I rolled the film back, found a collision in the side garden, and confirmed that the noise did not involve teeth. Camera pointing is such that people being obnoxious at the fence will also be recorded.

Apple uses its Neural Engine to do extended motion filtering of notification events. The cameras here at Dismal Manor can differentiate between people and not people. And vehicles and not vehicles. They can be configured to report all, people, or vehicles.

They are not critter aware but HomeKit is. HomeKit Secure Video cameras are configured to send all motion events to HomeKit where the hub does person, vehicle, and animal detection processing of the forwarded clip and can be configured to selectively forward events of each type. The porch landing EuFy Cam2 cameras are post processed to report animals on the porch. If they were HomeKit Secure Video enabled, the UniFi Protect cameras could also be processed for critter detection.

iOS 15 to update HSV storage

With iOS 15, Home Kit Secure Video will allow “unlimited” cameras to be associated with an AppleID. I believe Apple are rolling out this capability as I write this so that it will be ready for the iOS 15 fall release.