Adds a cloud-locked Xiaomi Outdoor Camera CW300 to UniFi Protect as a
third-party camera. The CW300 exposes no local RTSP/ONVIF - it only speaks
Xiaomi's encrypted miss protocol. This bridge:
- Uses go2rtc to pull the camera stream (it fetches the per-connection decryption key from the Xiaomi cloud) and transcodes H.265/Opus to H.264/AAC (Protect dislikes H.265).
- Runs
onvif_adapter.py, a ~250-line stdlib ONVIF Profile S adapter that answers WS-Discovery + SOAP so Protect can discover and adopt the go2rtc RTSP stream.
CW300 (H.265/Opus) -> go2rtc -> transcode H.264/AAC -> onvif_adapter.py -> UniFi Protect
No secrets are committed. Your Xiaomi passToken lives only in go2rtc.yaml
(gitignored) and is written there by go2rtc after you log in.
- go2rtc >= 1.9.13 (native Xiaomi support)
- ffmpeg with a hardware H.264 encoder (Apple Silicon:
h264_videotoolbox) - Python 3.8+ (stdlib only)
- The host must be on the same LAN as the camera and stay powered on
- A Xiaomi account with email + password (Sign-in-with-Apple only accounts must add a password in the Mi Home app first)
-
Install go2rtc and ffmpeg.
-
Copy the config template and start go2rtc:
cp go2rtc.example.yaml go2rtc.yaml ./go2rtc -config go2rtc.yaml -
Open
http://127.0.0.1:1984> Add > Xiaomi and log in. go2rtc writes thexiaomi:passToken block intogo2rtc.yamland lists your cameras. Fill thecw300:line with your camera'sUSER_ID,REGION,CAMERA_IP,DID,MODEL(visible in that list or viaGET /api/xiaomi?id=USER_ID), then restart go2rtc. Verify:ffprobe rtsp://127.0.0.1:8554/cw300_h264 # should show h264 + aac -
Start the ONVIF adapter (config via env vars, see below):
CW300_LAN_IP=192.168.0.7 CW300_ONVIF_USER=protect CW300_ONVIF_PASS=protect \ python3 onvif_adapter.py -
In UniFi Protect: Settings > Cameras > Discover Third-Party Cameras (ONVIF). Adopt the discovered camera using the ONVIF user/pass above.
| Variable | Default | Meaning |
|---|---|---|
CW300_LAN_IP |
autodetect | host IP the Protect console will reach |
CW300_ONVIF_PORT |
8555 |
adapter SOAP/HTTP port |
CW300_ONVIF_USER / CW300_ONVIF_PASS |
protect / protect |
ONVIF credentials (enter the same in Protect) |
CW300_RTSP_PORT |
8554 |
go2rtc RTSP port |
CW300_RTSP_PATH |
cw300_h264 |
go2rtc stream name served to Protect |
CW300_SNAP_SRC |
cw300 |
go2rtc stream used for snapshots |
CW300_GO2RTC_API |
127.0.0.1:1984 |
go2rtc API (local) for snapshots |
CW300_NAME / CW300_MODEL |
Xiaomi CW300 / CW300 |
display name / model |
CW300_WIDTH / CW300_HEIGHT |
848 / 480 |
advertised resolution |
CW300_UUID |
built-in | stable ONVIF device UUID |
python3 -m unittest -v
- Not fully local: every stream (re)connection needs Internet to obtain the Xiaomi per-connection key (~3-4 s). The video itself is then LAN-only.
- Always-on host: the bridge machine is the camera source for Protect.
- Security: the RTSP stream and the ONVIF adapter are exposed on the LAN (they must be, for Protect to reach them). Keep this on a trusted network; do not expose to the Internet.
- The adapter does not strictly validate the ONVIF password (Protect still requires a username/password field). Add validation if you need it.