reolink(nvr): ONVIF push-based motion for Home Hub battery cameras#2
reolink(nvr): ONVIF push-based motion for Home Hub battery cameras#2SnoElement wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds an opt-in ONVIF PullPoint (push) event path for Reolink Home Hub (Pro) channels so sleeping battery/solar cameras can still deliver motion and AI/object detections to Scrypted/HomeKit when Reolink polling endpoints return “device offline”.
Changes:
- Adds hub-level ONVIF subscription management in the Reolink NVR device and routes events to cameras by channel.
- Adds a per-camera toggle to use ONVIF for motion/object detection and debounced motion/object emission driven by ONVIF.
- Enhances ONVIF event parsing to extract source channel and interpret Reolink AI rule topics into motion/class signals.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| plugins/reolink/src/nvr/nvr.ts | Starts/stops a single hub-level ONVIF PullPoint subscription and routes interpreted events to the correct camera by channel. |
| plugins/reolink/src/nvr/camera.ts | Adds per-camera “Use ONVIF for Object Detection” toggle and ONVIF-driven motion/object emission; skips polled motion when ONVIF is enabled. |
| plugins/onvif/src/onvif-api.ts | Parses ONVIF events to extract source channel and interpret motion/object topics for push-based consumers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I don't see any need to enable onvif on the hub, considering the hub itsself already ships camera motion while they do sleep (the hub has an internal network catching mail events), if that does not work the fix is something else, please check logs if anything is logged there, I haven't looked at this plugin for a while |
dca0d2c to
dac0369
Compare
Battery/solar cameras behind a Reolink Home Hub (Pro) sleep to save power. While asleep the hub answers the GetMdState/GetAiState polling the NVR client relies on with "device offline", so motion never reaches Scrypted/HomeKit and HomeKit Secure Video never records. The hub does, however, push these events over ONVIF PullPoint. Add an opt-in ONVIF push path for hub channels: - onvif-api.ts: extract the source channel token from each event (<tt:Source> SimpleItem VideoSourceConfigurationToken/Source/VideoSourceToken), interpret the topic into a motion flag plus an optional object class, and emit a separate channel-aware 'onvifChannelEvent' (motion, class, channel). The existing 'onvifEvent'/'event'/'data' emissions are left unchanged, so this is purely additive and existing consumers are unaffected. - nvr.ts: open ONE hub-level PullPoint subscription, route each event by channel to the matching camera, mapping Reolink rule topics (People/Vehicle/DogCat/Face/Package + CellMotion/MotionAlarm) to motion and an optional ObjectDetector class. Raw event XML is logged only when 'Debug Events' is enabled. - camera.ts: add a 'Use ONVIF for Object Detection' control that registers the channel and a debounced triggerOnvifMotion() that sets motionDetected and fires the ObjectDetector event. Validated on real hardware (Home Hub Pro, firmware-current) with sleeping battery cameras: person/vehicle/motion events now arrive over the push subscription and trigger HomeKit recordings where polling returned offline. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
dac0369 to
e242322
Compare
Problem
Battery/solar cameras behind a Reolink Home Hub (Pro) sleep to save power. While asleep, the hub answers the
GetMdState/GetAiStatepolling the NVR client relies on with"device offline" (rspCode -99), so motion never reaches Scrypted/HomeKit and HKSV never records. The hub does push these events over ONVIF PullPoint.Refs koush#1947 (Home Hub NVR support, @apocaliss92) and koush#1642 (battery motion via Home Hub never reaching Scrypted).
Change
Add an opt-in ONVIF push path for hub channels:
onvif/onvif-api.ts—listenEvents()now interprets each event topic once (motion + optional object class), extracts the source channel from the<tt:Source>SimpleItem, and emits an interpreted, channel-awareonvifEvent(motion, className, channel). Adds the ReolinkMyRuleDetector/*AI-rule class map (People/Vehicle/DogCat/Face/Package). Existing standaloneOnvifEventemissions are unchanged.reolink/nvr/nvr.ts— open one hub-level PullPoint subscription and route each event by channel to the matching camera. Start/stop lifecycle tied to whether any camera wants ONVIF; a generation counter prevents a torn-down start (mid-connect) from resurrecting. Raw XML logged only under "Debug Events".reolink/nvr/camera.ts— add a "Use ONVIF for Object Detection" toggle and a debouncedtriggerOnvifMotion()that setsmotionDetected(sharing the existingmotionTimeout) and fires anObjectDetectorevent (guarded by the camera's advertised object types). The polled-motion path is skipped while ONVIF is the source, so the two never race.Validation
Tested on a real Reolink Home Hub Pro with sleeping battery cameras. The ONVIF
Sourcetoken equalsrtspChannel(both 0-based hub index): events route correctly with no cross-fire — e.g. token001→ch1 Front Door (PeopleDetect),005→ch5 Gate Area (motion). Cameras that returneddevice offlineto polling now report motion and trigger HKSV recordings.Note
Like the existing per-camera
onvif-events.ts, the subscription is not explicitly renewed — the continuousPullMessagesloop keeps it alive in practice. A follow-up could addRenewfor hubs whose firmware enforcesTerminationTime.