UniFi Protect

siclark
Posts: 2355
Joined: Tue Jun 13, 2017 5:08 am
Location: UK

UniFi Protect

Post by siclark »

A new simple plugin for monitoring the UniFi Protect devices.

I actually started this without realising Karl’s UniFi WiFi AP plugin now uses the same new API connection method, but I also wanted to have a more lightweight plugin.

Install the plugin and you just need the api key from your system and the IP address. Simple.

It will be in plugin store shortly and read docs here
[URL] https://github.com/simons-plugins/indigo-unifi-protect[/URL

An added bonus, there is a pages folder in the repo and contains an html page.

Copy it to the folder from the readme and you can monitor the cameras in dom.io. Via snapshots for now but streaming options in development.


Simon
siclark
Posts: 2355
Joined: Tue Jun 13, 2017 5:08 am
Location: UK

Re: UniFi Protect

Post by siclark »

WHAT YOU GET

Each Protect camera becomes an Indigo motion-sensor device with:
- motionDetected, plus personDetected / vehicleDetected / animalDetected from Protect's smart detections
- audio: audioDetected, speechDetected, babyCryDetected, smokeAlarmDetected, coAlarmDetected (cameras with a mic)
- lastMotion / lastDetectTypes / lastAudio timestamps
- camera hardware & config states: model, video mode, HDR, mic volume, status LED, OSD settings — pushed live, not polled
- optional RTSPS stream URLs as states (off by default — they contain a token)
- a snapshot action that saves a JPEG into Web Assets, so control pages can show it and can be sent over pushover

Actions: Take Snapshot, Set Status LED, Set OSD Overlay, Set Video Mode, Set HDR Mode, Set Microphone Volume, PTZ go-to-preset / start & stop patrol, Refresh / Delete Stream URLs, and a plugin-level "Trigger Alarm Manager Webhook" so an Indigo trigger can fire a Protect Alarm Manager automation.

It also ships an optional HTML page (cameras.html) that shows every camera's latest snapshot with motion/person/vehicle badges — the plugin installs it into Web Assets for you which dom.io will read and so you can see the details on your iPhone.

Other Protect devices are supported as separate Indigo device types: Protect sensors (door/window, leak, motion, temp/humidity/light), floodlights, doorbell chimes, the NVR's arm/disarm state, and ViewPort viewers (with a "Set Live View" action).

HOW IT WORKS — AND THE ONE THING TO KNOW

Motion arrives over Protect's event WebSocket, not polling: motion-on typically lands in Indigo 1–3 s after Protect sees it, motion-off ~6–7 s (that's Protect's own event timing). Good for occupancy and security; not a PIR replacement for "lights off when motion stops".

Because the socket is the ONLY motion source, every device has a `connected` state. If the socket drops, the plugin sets both motionDetected and connected to False rather than pretending the house is quiet — so gate your triggers on `connected`. That design choice is the reason most of the code exists.

WHAT'S VERIFIED VS NOT

Live-tested on my rig (UNVR, Protect 7.2.105, G5 Turret Ultra / G5 Bullet): cameras, motion + smart detections, audio, config states, the control actions, snapshots, the HTML page, NVR arm state, and the live-view listing.

Built from Ubiquiti's published OpenAPI spec but NOT exercised on real hardware (I don't own any): Protect sensors, floodlights, chimes, ViewPort viewers, PTZ, the Alarm Manager webhook. They're clearly labelled as such in the device dialogs. If you have any of that kit and are willing to try it, a debug-log capture in a GitHub issue would be very welcome — that's how these get promoted to "verified".

REQUIREMENTS
- UniFi OS console (UDM / UNVR / Dream Machine) with the integration API (Settings → Control Plane → Integrations → Create API Key)
- Indigo 2025.2 (Python 3 plugin API)

Docs, the full state list, and the API notes are in the repo README. Issues and PRs welcome.
Post Reply

Return to “Simon’s Plug-ins”