Skip to content

UniFi Protect Binding ​

This binding integrates Ubiquiti UniFi Protect into openHAB. It connects to your Protect NVR/CloudKey/UNVR and provides live events and configurable settings for Cameras, Floodlights, Sensors, Doorlocks, and Chimes.

It primarily uses the Private API for device control and monitoring, with the official Protect Integration API (Public API) used for real-time event streaming, WebRTC/RTSPS streams, and talkback sessions. The binding automatically manages API authentication, including auto-creation of API keys when needed.

Thing IDs. Newly discovered or created Protect things use the unifi: binding ID (e.g. unifi:nvr, unifi:camera). Things created with an earlier release keep their legacy unifiprotect: IDs and continue to work unchanged.

Features ​

  • Supports multiple Protect devices (Cameras, Doorbells, Floodlights, Sensors)
  • Has granular triggers and channels for realtime motion events including AI object detection, audio, and line crossing events.
  • Uses websockets for realtime updates without polling
  • Supports WebRTC streaming for cameras with very low server CPU overhead
  • Supports 2-way audio for cameras that support it
  • Uses STUN for external access to cameras when outside your local network (e.g. when using the openHAB cloud service)
  • Provides general purpose image snapshot API endpoints for cameras

Native Binaries ​

  • Uses go2rtc and FFmpeg for WebRTC playback and publishing.
  • The binding will automatically download and extract the binaries if they are not present on linux, mac, windows and freeBSD.
  • By default the binding will first try and find the binaries on the system PATH before downloading them.
  • If your platform is not supported, or downloading the binaries is not possible, install the binaries manually and ensure they are on the system PATH.

See Binding Configuration to enable/disable downloading the binaries.

Supported Things ​

  • nvr (Bridge): The Protect NVR/CloudKey/UNVR. Required to discover and manage child devices. Provides NVR monitoring channels.
  • camera: A Protect camera. Channels are added dynamically based on device capabilities (mic, HDR, smart detection, PTZ, etc.).
  • light: A Protect Floodlight.
  • sensor: A Protect environmental/contact sensor.
  • doorlock: A Protect Smart Doorlock.
  • chime: A Protect Chime device.

Bridge hierarchy. The unifi:nvr bridge is a child of the shared unifi:controller bridge from the parent org.openhab.binding.unifi binding. The NVR thing itself does not carry hostname / username / password — host and credentials come from the parent controller bridge. If you are upgrading from an earlier version of the UniFi Protect Binding, see the UniFi binding README — Upgrading from earlier UniFi bindings section for the reparenting steps.

Discovery ​

  • First create a unifi:controller bridge from the parent UniFi binding pointing at your UniFi console with a local user account.
  • Then add an nvr bridge as a child of that controller bridge. No host/username/password is needed on the NVR itself — they are inherited from the parent.
  • The binding automatically creates a Public API key (named openHAB-<thing-id>) on first connection if no token is provided.
  • Once the NVR is ONLINE, Cameras, Floodlights, Sensors, Doorlocks, and Chimes are discovered automatically and appear in the Inbox.
  • Approve discovered things to add them to your system. Manual creation is also possible using deviceId.

Binding Configuration ​

NameTypeDescriptionRequired
downloadBinariesbooleanDownload binaries if they are not on the system PATH. This setting controls whether the binding should download the native binaries if they are not found. By default, the binding will download the binaries if they are not on the system PATH for supported platformsyes
useStunbooleanUse STUN for external IP discovery. This will allow camera streams to work behind NATs when outside your local network (e.g. when using the openHAB cloud service) and is enabled by default.yes

Note: Enabling STUN will incur an approximately 5-second delay delivering the stream to clients as it discovers your external IP and pins a port on your router for streams. If you are not using the openHAB cloud service with cameras, disabling STUN will allow for near-instant stream starts (video will start within a second of loading) on your local network or over a VPN.

Thing Configuration ​

NVR (Bridge) nvr ​

The nvr bridge is a child of the unifi:controller bridge. Host, port, username, and password come from the parent controller bridge — the NVR itself only carries Protect-specific settings.

NameTypeDescriptionDefaultRequiredAdvanced
tokentextPublic API token. Auto-created if left blank.N/Anoyes

Authentication:

The parent unifi:controller bridge handles console authentication — you configure the local user once on the controller bridge, and the Protect binding reuses that session.

  • API Key (Token): If not provided, the binding automatically creates an API key named openHAB-<thing-id> for the Public API on first connection. The key is stored in the thing configuration and reused on restarts.

Manual API Key Creation (optional):

If you prefer to manually create an API key:

  1. In the UniFi Protect UI, go to Settings → Control Plane → Integrations and create an API token.
  2. Copy the token and paste it into the token field in the NVR bridge configuration.
Protect API key creation

camera Configuration ​

NameTypeDescriptionRequired
deviceIdtextUnique device identifier of the camerayes
enableWebRTCbooleanEnable WebRTC streamingyes

When WebRTC is enabled, the camera will be able to stream through openHAB using WebRTC. You can disable WebRTC by setting enableWebRTC to false.

light Configuration ​

NameTypeDescriptionRequired
deviceIdtextUnique device identifier of the floodlightyes

sensor Configuration ​

NameTypeDescriptionRequired
deviceIdtextUnique device identifier of the sensoryes

doorlock Configuration ​

NameTypeDescriptionRequired
deviceIdtextUnique device identifier of the doorlockyes

chime Configuration ​

NameTypeDescriptionRequired
deviceIdtextUnique device identifier of the chimeyes

Channels ​

Below are the channels exposed by each thing type. Some camera channels are created dynamically depending on device capabilities.

nvr Bridge Channels ​

The NVR bridge provides comprehensive monitoring channels for system health, storage, and configuration.

Channel IDItem TypeRWDescriptionAdvanced
storage-totalNumber:DataAmountRTotal storage capacityfalse
storage-usedNumber:DataAmountRUsed storagefalse
storage-availableNumber:DataAmountRAvailable storagefalse
storage-utilizationNumber:DimensionlessRStorage utilization percentagefalse
recording-retentionNumber:TimeRRecording retention durationfalse
nvr-storage-device-healthySwitchRAll storage devices healthyfalse
nvr-camera-utilizationNumberRCamera capacity utilizationtrue
nvr-recording-modeStringRGlobal camera recording modetrue
nvr-recording-disabledSwitchRRecording globally disabledtrue
nvr-recording-motion-onlySwitchRRecording motion onlytrue
nvr-is-awaySwitchRNVR away mode statustrue
nvr-geofencing-enabledSwitchRGeofencing enabledtrue
nvr-smart-detection-availableSwitchRSmart detection availabletrue
nvr-insights-enabledSwitchRInsights enabledtrue
nvr-can-auto-updateSwitchRCan auto-updatetrue
nvr-last-update-atDateTimeRLast update timestamptrue
nvr-protect-updatableSwitchRProtect is updatabletrue

camera Channels ​

  • The following are dynamically created depending on the supported features.
  • Advanced channels are hidden by default in the MainUI, select "Show Advanced" to see them.

Basic Control & Settings ​

Channel IDItem TypeRWDescriptionAdvanced
mic-volumeDimmerRWMicrophone volume (0-100)true
video-modeStringRWCamera video mode (default, highFps, sport, ...)true
hdr-typeStringRWHDR mode (auto, on, off)true
osd-nameSwitchRWShow name on OSDtrue
osd-dateSwitchRWShow date on OSDtrue
osd-logoSwitchRWShow logo on OSDtrue
led-enabledSwitchRWEnable/disable camera status LEDtrue
active-patrol-slotNumberRWActive PTZ patrol slot (set 0 to stop)false

Streaming URLs ​

Channel IDItem TypeRWDescriptionAdvanced
webrtc-url-highStringRWebRTC stream URL for high qualitytrue
webrtc-url-mediumStringRWebRTC stream URL for medium qualitytrue
webrtc-url-lowStringRWebRTC stream URL for low qualitytrue
webrtc-url-packageStringRWebRTC stream URL for package qualitytrue
rtsp-url-highStringRRTSP stream URL for high qualitytrue
rtsp-url-mediumStringRRTSP stream URL for medium qualitytrue
rtsp-url-lowStringRRTSP stream URL for low qualitytrue
rtsp-url-packageStringRRTSP stream URL for package qualitytrue

Snapshots & Images ​

Channel IDItem TypeRWDescriptionAdvanced
snapshotImageRSnapshot image. Send a REFRESH command to updatefalse
snapshot-urlStringRSnapshot image URLfalse
motion-snapshotImageRSnapshot captured around motion eventfalse
smart-detect-audio-snapshotImageRSnapshot captured around smart audio detectionfalse
smart-detect-zone-snapshotImageRSnapshot captured around smart zone detectionfalse
smart-detect-line-snapshotImageRSnapshot captured around smart line detectionfalse
smart-detect-loiter-snapshotImageRSnapshot captured around smart loiter detectionfalse
motion-thumbnailImageRMotion event thumbnail imagefalse
motion-heatmapImageRMotion event heatmap imagefalse

Motion & Detection ​

Channel IDItem TypeRWDescriptionAdvanced
motion-contactContactRMotion state (OPEN = motion detected)false
smart-detect-audio-contactContactRSmart audio detection active statefalse
smart-detect-zone-contactContactRSmart zone detection active statefalse
smart-detect-line-contactContactRSmart line detection active statefalse
smart-detect-loiter-contactContactRSmart loiter detection active statefalse
is-motion-detectedSwitchRMotion currently detectedfalse
last-motionDateTimeRTimestamp of last motiontrue
last-smart-detectDateTimeRTimestamp of last smart detectionfalse
last-smart-detect-typesStringRTypes of last smart detection (comma-separated)false

Doorbell ​

Channel IDItem TypeRWDescriptionAdvanced
doorbell-default-messageStringRWDefault doorbell LCD message textfalse
doorbell-default-message-reset-timeoutNumber:TimeRWDefault doorbell LCD message reset timeouttrue
doorbell-ring-volumeDimmerRWDoorbell ring volume (0-100)true
doorbell-chime-durationNumber:TimeRWDoorbell chime durationtrue
lcd-messageStringRCurrent LCD message textfalse
is-ringingSwitchRDoorbell is currently ringingfalse
last-ringDateTimeRTimestamp of last doorbell ringtrue
ring-contactContactRRing state (OPEN = ring detected)false
ring-snapshotImageRSnapshot captured around ring eventfalse

Device Status & Health ​

Channel IDItem TypeRWDescriptionAdvanced
is-connectedSwitchRCamera is connectedfalse
is-darkSwitchRScene is currently darkfalse
is-recordingSwitchRCamera is currently recordingfalse
is-smart-detectedSwitchRSmart detection currently activefalse
is-live-heatmap-enabledSwitchRLive heatmap enabledtrue
video-reconfiguration-in-progressSwitchRVideo reconfiguration in progresstrue
device-stateStringRDevice operational statetrue
device-uptimeNumber:TimeRDevice uptimetrue
uptime-startedDateTimeRDevice up since timestamptrue
connected-sinceDateTimeRConnected since timestamptrue
last-seenDateTimeRLast seen timestamptrue
last-smartDateTimeRLast smart detection timestamptrue
connection-hostStringRConnection host addresstrue
last-disconnectDateTimeRLast disconnect timestamptrue
connection-stateStringRConnection statetrue
stateStringRDevice statetrue
wired-connection-stateStringRWired connection statetrue
physical-connection-rateNumber:DataTransferRateRPhysical connection ratetrue

Network & WiFi ​

Channel IDItem TypeRWDescriptionAdvanced
phy-rateNumberRPhysical connection ratetrue
is-probing-for-wifiSwitchRProbing for WiFitrue
is-poor-networkSwitchRNetwork quality is poortrue
is-wireless-uplink-enabledSwitchRWireless uplink enabledtrue
ap-macStringRAccess point MAC addresstrue
wifi-channelNumberRWiFi channel numbertrue
wifi-frequencyNumber:FrequencyRWiFi frequencytrue
wifi-signal-qualityNumber:DimensionlessRWiFi signal quality percentagetrue
wifi-signal-strengthNumber:PowerRWiFi signal strength (dBm)true

Storage & Recording ​

Channel IDItem TypeRWDescriptionAdvanced
storage-usedNumber:DataAmountRStorage used by this camerafalse
storage-rateNumber:DataTransferRateRRecording storage ratetrue

Power & Battery ​

Channel IDItem TypeRWDescriptionAdvanced
voltageNumber:ElectricPotentialRInput voltagetrue
battery-percentageNumber:DimensionlessRBattery charge percentagefalse
battery-is-chargingSwitchRBattery is chargingfalse
battery-sleep-stateStringRBattery sleep statetrue

Recording & Detection Settings ​

Channel IDItem TypeRWDescriptionAdvanced
recording-modeStringRWRecording modetrue
motion-detection-enabledSwitchRWEnable/disable motion detectiontrue
use-global-settingsSwitchRWUse NVR global settings instead of per-cameratrue
ir-modeStringRWIR LED modetrue
hdr-enabledSwitchRWEnable HDR modetrue
high-fps-enabledSwitchRWEnable high frame rate modetrue
mic-enabledSwitchRWEnable/disable microphonetrue
camera-speaker-volumeDimmerRWSpeaker volume (0-100)true
camera-zoom-levelDimmerRWOptical zoom level (0-100)false
camera-wdr-levelNumberRWWide dynamic range level (0-3)true
device-rebootSwitchWReboot device (send ON command)true

Smart Detection Controls ​

Channel IDItem TypeRWDescriptionAdvanced
smart-detect-person-enabledSwitchRWEnable person detectiontrue
smart-detect-vehicle-enabledSwitchRWEnable vehicle detectiontrue
smart-detect-face-enabledSwitchRWEnable face detectiontrue
smart-detect-license-plate-enabledSwitchRWEnable license plate detectiontrue
smart-detect-package-enabledSwitchRWEnable package detectiontrue
smart-detect-animal-enabledSwitchRWEnable animal detectiontrue

PTZ Controls ​

Channel IDItem TypeRWDescriptionAdvanced
ptz-relative-panNumberRWRelative pan (negative = left, positive = right)false
ptz-relative-tiltNumberRWRelative tilt (negative = down, positive = up)false
ptz-relative-zoomNumberRWRelative zoom (negative = out, positive = in)false
ptz-centerStringWCenter on coordinates (format: x,y,z where 0-1000)false
ptz-set-homeSwitchWSet home position to current (send ON)true
ptz-create-presetStringWCreate preset at current position (slot,name)true
ptz-delete-presetNumberWDelete preset by slot numbertrue

Trigger channels (for rules):

  • Triggers Channels are hidden by default in the MainUI, select "Show Advanced" to see them.
Trigger Channel IDPayload (if any)Description
ringPRESSED, RELEASEDDoorbell ring event
motion-startnoneMotion started
motion-updatenoneMotion updated (debounced update event)
smart-detect-audio-startalrmSmoke, alrmCmonx, alrmSiren, alrmBabyCry, alrmSpeak, alrmBark, alrmBurglar, alrmCarHorn, alrmGlassBreak, noneSmart audio detection started
smart-detect-audio-updatealrmSmoke, alrmCmonx, alrmSiren, alrmBabyCry, alrmSpeak, alrmBark, alrmBurglar, alrmCarHorn, alrmGlassBreak, noneSmart audio detection updated
smart-detect-zone-startperson, vehicle, package, licensePlate, face, animal, noneZone smart detection started
smart-detect-zone-updateperson, vehicle, package, licensePlate, face, animal, noneZone smart detection updated
smart-detect-line-startperson, vehicle, package, licensePlate, face, animal, noneLine smart detection started
smart-detect-line-updateperson, vehicle, package, licensePlate, face, animal, noneLine smart detection updated
smart-detect-loiter-startperson, vehicle, package, licensePlate, face, animal, noneLoiter smart detection started
smart-detect-loiter-updateperson, vehicle, package, licensePlate, face, animal, noneLoiter smart detection updated

Snapshot Channels ​

Snapshot channels can be configured to take a snapshot before or after the trigger event or item state change. By default, a snapshot is taken before the trigger event fires or item state updates so its immediately available for use in rules. This however can cause a slight delay in the rule execution if the snapshot itself is delayed. The order in which the snapshot is taken can be configured via the snapshot channel configuration through textual files or the MainUI. To take a snapshot after the event trigger fires or item state updates, you can set the sequence to "after". If you do not want to take a snapshot on a trigger event or item state update, you can set the sequence to "none".

Motion Contact Channels ​

Motion contact channels are configured to latch/close after a defined delay after a motion event. By default, the contact is considered latched/closed after 5 seconds of no motion events. This delay can be configured via the contact channel configuration through textual files or the MainUI.

Floodlight (light) ​

Channel IDItem TypeRWDescriptionAdvanced
lightSwitchRWMain floodlight on/off (forces light)false
is-darkSwitchRScene is currently darkfalse
pir-motionTrigger-PIR motion eventfalse
last-motionDateTimeRTimestamp of last motiontrue
light-modeStringRWLight mode (always, motion, off)true
enable-atStringRWWhen mode is relevant (fulltime, dark)true
indicator-enabledSwitchRWStatus LED indicator on floodlighttrue
pir-durationNumber:TimeRWHow long the light stays on after motiontrue
pir-sensitivityNumber:DimensionlessRWPIR motion sensitivity (0-100)true
led-levelNumberRWLED brightness level (1-6)true
light-mode-advancedStringRWAdvanced light mode settingstrue
device-rebootSwitchWReboot device (send ON command)true

Sensor (sensor) ​

Channel IDItem TypeRWDescriptionAdvanced
batteryNumberRBattery charge level (%)false
contactContactRContact state (OPEN/CLOSED)false
temperatureNumber:TemperatureRAmbient temperaturefalse
humidityNumberRAmbient humidityfalse
illuminanceNumber:IlluminanceRAmbient light (Lux)false
alarm-contactContactRSmoke/CO alarm contact (OPEN = alarming)false
water-leak-contactContactRWater leak contact (OPEN = leak)false
tamper-contactContactRTamper contact (OPEN = tampering)false
sensor-tamper-resetSwitchWReset tamper status (send ON)true
device-rebootSwitchWReboot device (send ON command)true

Doorlock (doorlock) ​

Channel IDItem TypeRWDescriptionAdvanced
lockSwitchRWLock control (ON=locked, OFF=unlocked)false
lock-statusStringRCurrent lock statusfalse
calibrateSwitchWCalibrate lock (send ON)true
auto-close-timeNumber:TimeRWAuto-close time in secondstrue
battery-percentageNumber:DimensionlessRBattery charge percentagefalse

Chime (chime) ​

Channel IDItem TypeRWDescriptionAdvanced
play-chimeSwitchWPlay chime sound (send ON)true
play-buzzerSwitchWPlay buzzer sound (send ON)false
volumeDimmerRWChime volume (0-100)false
repeat-timesNumberRWNumber of times to repeat soundtrue

Trigger channels (for rules):

Trigger Channel IDPayload (if any)Description
openeddoor, window, garage, leak, noneSensor opened
closeddoor, window, garage, leak, noneSensor closed
alarmsmoke, CO (optional)Smoke/CO alarm event
water-leakdoor, window, garage, leak, noneWater leak detected
tampernoneTampering detected

Real-time Media ​

If enabled in the binding configuration, openHAB will proxy live media using WebRTC which is compatible with the MainUI video widget.

Stream URLs ​

The URL for WebRTC streams can be found in 2 different ways

  1. As a property on the Camera Thing (webrtc-url-high, webrtc-url-medium, webrtc-url-low, webrtc-url-package)
  2. As an Item linked to a channel on the Camera Thing (webrtc-url-high, webrtc-url-medium, webrtc-url-low, webrtc-url-package)

All of the above URLs are relative to the openHAB instance.

The playback URLs can be used in the MainUI video widget by enabling WebRTC in the advanced settings in the video widget and using an above URL or Item as the source.

An example WebRTC stream URL would be:

/unifi/media/play/unifi:camera:home:1234567890:high

Where unifi:camera:home:1234567890 is the camera's Thing UID and high is the quality (high, medium, low, package) if supported by the camera.

You can either use the String URL or select the Item linked to the channel in the MainUI video widget.

video widget settings

It's also highly recommended to use the camera's Snapshot URL property or the Item linked to the snapshot-url channel to get the live snapshot image URL which can be used for the poster image option in the MainUI video widget.

An example snapshot image URL would be:

/unifi/media/image/unifi:camera:home:1234567890

Where unifi:camera:home:1234567890 is the camera's Thing UID. You can append ?quality=high to the URL to get the a higher quality snapshot image if supported by the camera, but can fail if not supported. The default quality level is suitable for most use cases, and supported by all cameras.

Talkback Support (2-way audio) ​

Some UniFi Protect cameras support "Talkback", which allows you to publish audio back to the camera in a push to talk manner. If supported, you can enable "Two Way Audio" in the MainUI video widget (along with selecting WebRTC under advanced settings in the video widget) which will display a microphone icon for push to talk functionality. This is automatically supported by the binding and will be enabled if supported by the camera.

Full Examples (Textual Configuration) ​

Replace the IDs with your own thing and item names.

Things (.things) ​

The Protect NVR is a child of the unifi:controller bridge from the parent UniFi binding. Host and credentials live on the controller bridge; the NVR bridge only carries Protect-specific settings.

dsl
Bridge unifi:controller:myConsole "UniFi Console" [ host="192.168.1.10", username="localadmin", password="your_password" ] {
    // Protect NVR — token is optional, auto-created if left blank
    Bridge unifi:nvr myNvr "UniFi Protect NVR" [] {
        Thing camera frontdoor "Front Door Camera" [ deviceId="60546f80e4b0abcd12345678", enableWebRTC=true ]
        Thing light driveway "Driveway Floodlight" [ deviceId="60a1b2c3d4e5f67890123456" ]
        Thing sensor garagedoor "Garage Door Sensor" [ deviceId="60112233445566778899aabb" ]
        Thing doorlock frontdoorlock "Front Door Lock" [ deviceId="60c1d2e3f4a5b67890123456" ]
        Thing chime hallwaychime "Hallway Chime" [ deviceId="60d1e2f3a4b5c67890123456" ]
    }
}

Items (.items) ​

dsl
// NVR Monitoring
Number:DataAmount NVR_Storage_Total        "Total Storage [%.0f GB]"            { channel="unifi:nvr:myNvr:storage-total" }
Number:DataAmount NVR_Storage_Used         "Used Storage [%.0f GB]"             { channel="unifi:nvr:myNvr:storage-used" }
Number:DataAmount NVR_Storage_Available    "Available Storage [%.0f GB]"        { channel="unifi:nvr:myNvr:storage-available" }
Number            NVR_Storage_Utilization  "Storage Utilization [%.1f %%]"      { channel="unifi:nvr:myNvr:storage-utilization" }
Switch            NVR_Devices_Healthy      "All Devices Healthy"                { channel="unifi:nvr:myNvr:nvr-storage-device-healthy" }
Number            NVR_Camera_Util          "Camera Utilization [%.0f %%]"       { channel="unifi:nvr:myNvr:nvr-camera-utilization" }
String            NVR_Recording_Mode       "Recording Mode [%s]"                { channel="unifi:nvr:myNvr:nvr-recording-mode" }
Switch            NVR_Away_Mode            "Away Mode"                          { channel="unifi:nvr:myNvr:nvr-is-away" }

// Camera
Dimmer  Cam_Front_MicVolume        "Mic Volume [%d %%]"                 { channel="unifi:camera:myNvr:frontdoor:mic-volume" }
String  Cam_Front_VideoMode        "Video Mode [%s]"                    { channel="unifi:camera:myNvr:frontdoor:video-mode" }
String  Cam_Front_HDR              "HDR [%s]"                           { channel="unifi:camera:myNvr:frontdoor:hdr-type" }
Switch  Cam_Front_OSD_Name         "OSD Name"                           { channel="unifi:camera:myNvr:frontdoor:osd-name" }
Switch  Cam_Front_OSD_Date         "OSD Date"                           { channel="unifi:camera:myNvr:frontdoor:osd-date" }
Switch  Cam_Front_OSD_Logo         "OSD Logo"                           { channel="unifi:camera:myNvr:frontdoor:osd-logo" }
Switch  Cam_Front_LED              "Status LED"                         { channel="unifi:camera:myNvr:frontdoor:led-enabled" }
Number  Cam_Front_PatrolSlot       "PTZ Patrol Slot [%d]"               { channel="unifi:camera:myNvr:frontdoor:active-patrol-slot" }
String  Cam_Front_WebRTC_High      "WebRTC High [%s]"                   { channel="unifi:camera:myNvr:frontdoor:webrtc-url-high" }
Contact Cam_Front_Motion           "Motion [%s]"                        { channel="unifi:camera:myNvr:frontdoor:motion-contact" }
Image   Cam_Front_MotionSnapshot   "Motion Snapshot"                    { channel="unifi:camera:myNvr:frontdoor:motion-snapshot" }
Switch  Cam_Front_Connected        "Camera Connected"                   { channel="unifi:camera:myNvr:frontdoor:is-connected" }
Switch  Cam_Front_IsDark           "Is Dark Outside"                    { channel="unifi:camera:myNvr:frontdoor:is-dark" }
Number  Cam_Front_WiFi_Quality     "WiFi Quality [%.0f %%]"             { channel="unifi:camera:myNvr:frontdoor:wifi-quality" }
DateTime Cam_Front_LastMotion      "Last Motion [%1$ta %1$tR]"          { channel="unifi:camera:myNvr:frontdoor:last-motion" }

// Floodlight
Switch  Light_Driveway_OnOff       "Driveway Light"                     { channel="unifi:light:myNvr:driveway:light" }
Switch  Light_Driveway_IsDark      "Is Dark"                            { channel="unifi:light:myNvr:driveway:is-dark" }
DateTime Light_Driveway_LastMotion "Last Motion [%1$ta %1$tR]"          { channel="unifi:light:myNvr:driveway:last-motion" }
String  Light_Driveway_Mode        "Mode [%s]"                          { channel="unifi:light:myNvr:driveway:light-mode" }
String  Light_Driveway_EnableAt    "Enable At [%s]"                     { channel="unifi:light:myNvr:driveway:enable-at" }
Switch  Light_Driveway_Indicator   "Indicator LED"                      { channel="unifi:light:myNvr:driveway:indicator-enabled" }
Number  Light_Driveway_PIR_Dur     "PIR Duration [%.0f ms]"             { channel="unifi:light:myNvr:driveway:pir-duration" }
Number  Light_Driveway_PIR_Sens    "PIR Sensitivity [%.0f]"             { channel="unifi:light:myNvr:driveway:pir-sensitivity" }
Number  Light_Driveway_LED_Level   "LED Level [%.0f]"                   { channel="unifi:light:myNvr:driveway:led-level" }

// Sensor
Number  Sensor_Garage_Battery      "Battery [%.0f %%]"                  { channel="unifi:sensor:myNvr:garagedoor:battery" }
Contact Sensor_Garage_Contact      "Contact [%s]"                       { channel="unifi:sensor:myNvr:garagedoor:contact" }
Number:Temperature Sensor_Garage_T "Temperature [%.1f %unit%]"          { channel="unifi:sensor:myNvr:garagedoor:temperature" }
Number  Sensor_Garage_Humidity     "Humidity [%.0f %%]"                 { channel="unifi:sensor:myNvr:garagedoor:humidity" }
Number:Illuminance Sensor_Garage_L "Illuminance [%.0f lx]"              { channel="unifi:sensor:myNvr:garagedoor:illuminance" }
Contact Sensor_Garage_Alarm        "Alarm [%s]"                         { channel="unifi:sensor:myNvr:garagedoor:alarm-contact" }
Contact Sensor_Garage_Leak         "Leak [%s]"                          { channel="unifi:sensor:myNvr:garagedoor:water-leak-contact" }
Contact Sensor_Garage_Tamper       "Tamper [%s]"                        { channel="unifi:sensor:myNvr:garagedoor:tamper-contact" }

// Doorlock
Switch  Lock_Front_Lock            "Front Door Lock"                    { channel="unifi:doorlock:myNvr:frontdoorlock:lock" }
String  Lock_Front_Status          "Lock Status [%s]"                   { channel="unifi:doorlock:myNvr:frontdoorlock:lock-status" }
Number:Time Lock_Front_AutoClose   "Auto-Close Time [%.0f s]"           { channel="unifi:doorlock:myNvr:frontdoorlock:auto-close-time" }
Number  Lock_Front_Battery         "Battery [%.0f %%]"                  { channel="unifi:doorlock:myNvr:frontdoorlock:battery-percentage" }

// Chime
Dimmer  Chime_Hallway_Volume       "Chime Volume [%d %%]"               { channel="unifi:chime:myNvr:hallwaychime:volume" }
Number  Chime_Hallway_Repeat       "Repeat Times [%.0f]"                { channel="unifi:chime:myNvr:hallwaychime:repeat-times" }

Sitemap (.sitemap) ​

dsl
sitemap home label="Home" {
    Frame label="Front Door Camera" {
        Text item=Cam_Front_Motion
        Image item=Cam_Front_MotionSnapshot
    }
    Frame label="Driveway Floodlight" {
        Switch item=Light_Driveway_OnOff
        Text item=Light_Driveway_IsDark
        Text item=Light_Driveway_LastMotion
        Selection item=Light_Driveway_Mode mappings=[always="Always", motion="Motion", off="Off"]
        Selection item=Light_Driveway_EnableAt mappings=[fulltime="Full time", dark="Dark"]
        Setpoint item=Light_Driveway_PIR_Sens minValue=0 maxValue=100 step=1
        Setpoint item=Light_Driveway_LED_Level minValue=1 maxValue=6 step=1
    }
    Frame label="Garage Sensor" {
        Text item=Sensor_Garage_Contact
        Text item=Sensor_Garage_T
        Text item=Sensor_Garage_Humidity
        Text item=Sensor_Garage_L
        Text item=Sensor_Garage_Battery
    }
}

Rules ​

Examples showing trigger channels.

rules
// Camera motion start/update
rule "Front door motion alert"
when
    Channel "unifi:camera:myNvr:frontdoor:motion-start" triggered
then
    logInfo("protect", "Front door motion started")
end

rule "Front door motion update"
when
    Channel "unifi:camera:myNvr:frontdoor:motion-update" triggered
then
    logInfo("protect", "Front door motion update")
end

// Camera smart detection with payload
rule "Front door smart zone detect"
when
    Channel "unifi:camera:myNvr:frontdoor:smart-detect-zone-start" triggered
then
    // Access payload from the trigger channel event (person, vehicle, package, licensePlate, face, animal, none)
    val String payload = receivedEvent.getEvent()
    logInfo("protect", "Smart zone detection started: {}", payload)
end

rule "Front door smart zone update"
when
    Channel "unifi:camera:myNvr:frontdoor:smart-detect-zone-update" triggered
then
    val String payload = receivedEvent.getEvent()
    logInfo("protect", "Smart zone detection updated: {}", payload)
end

// Camera smart audio detect with payload
rule "Front door smart audio detect"
when
    Channel "unifi:camera:myNvr:frontdoor:smart-audio-detect-start" triggered
then
    val String payload = receivedEvent.getEvent() // alrmSmoke, alrmCmonx, alrmSiren, alrmBabyCry, alrmSpeak, alrmBark, alrmBurglar, alrmCarHorn, alrmGlassBreak, none
    logInfo("protect", "Smart audio detected: {}", payload)
end

rule "Front door smart audio update"
when
    Channel "unifi:camera:myNvr:frontdoor:smart-audio-detect-update" triggered
then
    val String payload = receivedEvent.getEvent()
    logInfo("protect", "Smart audio detection updated: {}", payload)
end

// Camera doorbell ring with payload filtering
rule "Front doorbell pressed"
when
    Channel "unifi:camera:myNvr:frontdoor:ring" triggered PRESSED
then
    logInfo("protect", "Doorbell pressed")
end

// Or handle any ring payload generically
rule "Front doorbell ring generic"
when
    Channel "unifi:camera:myNvr:frontdoor:ring" triggered
then
    val String payload = receivedEvent.getEvent() // PRESSED, RELEASED
    logInfo("protect", "Doorbell ring event: {}", payload)
end

// Floodlight PIR motion trigger
rule "Driveway PIR motion"
when
    Channel "unifi:light:myNvr:driveway:pir-motion" triggered
then
    logInfo("protect", "Driveway PIR motion")
    // Optionally turn on the light for a bit
    sendCommand(Light_Driveway_OnOff, ON)
    createTimer(now.plusSeconds(30), [ sendCommand(Light_Driveway_OnOff, OFF) ])
end

// Sensor opened/closed with payload
rule "Garage sensor opened"
when
    Channel "unifi:sensor:myNvr:garagedoor:opened" triggered
then
    val String payload = receivedEvent.getEvent() // door, window, garage, leak, none
    logInfo("protect", "Garage sensor opened: {}", payload)
end

rule "Garage sensor closed"
when
    Channel "unifi:sensor:myNvr:garagedoor:closed" triggered
then
    val String payload = receivedEvent.getEvent() // door, window, garage, leak, none
    logInfo("protect", "Garage sensor closed: {}", payload)
end

// Sensor water leak
rule "Garage water leak"
when
    Channel "unifi:sensor:myNvr:garagedoor:water-leak" triggered
then
    val String payload = receivedEvent.getEvent() // door, window, garage, leak, none
    logWarn("protect", "Water leak detected by garage sensor: {}", payload)
end

Tips and Tricks ​

Main UI Widgets ​

It can be helpful to display a live preview of multiple cameras in the MainUI using low quality streams, much like the UniFi Protect app, where clicking on a camera preview opens a higher quality version in a popup. The following widget creates a preview card for a camera, muting the audio and will open another widget or page when clicked anywhere on the card. Use the "low" quality stream for this preview widget, and the "high" quality stream for the popup, such as a dedicated page with a single video widget for the camera. A modest server can support dozens of simultaneous streams for MainUI clients with many camera views in a single page.

yaml
uid: unifi-webrtc-video-preview
tags: []
props:
  parameters:
    - description: Thing UID
      label: Thing UID
      name: thingUid
      required: true
      type: TEXT
  parameterGroups:
    - name: clickAction
      context: action
      label: Click Action
component: f7-card
config: {}
slots:
  default:
    - component: oh-video
      config:
        hideControls: true
        playerType: webrtc
        posterURL: ='/unifi/media/image/' + props.thingUid + '?quality=low'
        startMuted: true
        style:
          position: absolute
        url: ='/unifi/media/play/' + props.thingUid + ':low'
    - component: oh-button
      config:
        actionPropsParameterGroup: clickAction
        style:
          height: 100%
          margin: 0px
          opacity: 100%
          position: absolute
          top: 0px
          width: 100%