-
-
Notifications
You must be signed in to change notification settings - Fork 166
Snapshot Limitations
One of the things that Ring does not include in their advertising is the snapshot limitations of their battery cameras. These cameras (even when plugged in to a power source) are unable to take a snapshot while video is being recorded. The practical downside to this issue is that motion notifications through the homebridge-ring
plugin will often not include a snapshot from the camera. This happens when a snapshot has not been captured for more than 2 minutes and a motion event occurs. That motion event triggers a video recording and blocks HomeKit from being able to fetch a new snapshot for 30-40 seconds. If motion is detected again within 2 minutes, the snapshot from the original motion event will be used and will show up immediately in the motion notification. It is important that battery cam owners understand that notifications snapshots are most likely stale, and were not captured at the time of the motion event. My recommendation is that you click on the motion notification when they occur so that you can see the live view from the camera.
Wired cameras, on the other hand, allow snapshots while video is being captured. This means the snapshots should always show up in motion/ding notifications and they will be no more than 10 seconds old at the time of the notification.
- Modes settings can now easily disable motion detection, which prevents new snapshots from being captured
- If snapshots are fetched in the handleSnapshotRequest method, HomeKit will block the entire bridge until the snapshot response is sent. This is a limitation of HomeKit, not homebridge. This has always been the case, but wasn't as big of a deal when cameras were external accessories because only that one accessory was blocked while waiting for a snapshot. Now that cameras are bridged, waiting for a snapshot means that your entire homebridge instance is blocked. This, in combination with the modes issue, meant some users homebridge instances were virtually unusable from the Home app because snapshots were always blocking.
- Most users will still want accurate snapshots from their cameras when motion/dings are detected. This means we can't send the motion event until the snapshot is already downloaded and cached so that we can immediately respond when handleSnapshotRequest is triggered by the motion event So here's how I'm handling these things
- HomeKit will only request a snapshot every 10 seconds if you are on your LAN, or every 60 seconds if you are accessing via your Home Hub over WAN. Snapshots cannot be "pushed" to HomeKit, they can only be "pulled" by HomeKit when it wants one.
- I now check if
camera.settings.motion_detection_enabled === false
when refreshing snapshots. This gives us an indication that Modes is blocking snapshots and we shouldn't keep trying to get a new one. (Thanks for the suggestion on this one @Rubenfer) -
handleSnapshotRequest
will now return immediately with the last cached snapshot, no matter what. If there is no snapshot cached yet, it returns nothing. It also causes a new snapshot to be fetched after releasing HomeKit, so that the next call (which is 10 seconds later if you keep the Home app open on the same network as your home hub) will have a new up-to-date snapshot - Motion and Ding events will now be delayed before they are passed to HomeKit. When motion is detected, it will first fetch an updated snapshot, and then pass the motion update to HomeKit. HomeKit will then immediately call handleSnapshotRequest which can return the image that was just cached. This does mean that motion/ding events will be delayed before showing notifications on your apple devices, but HomeKit was already doing that delay while it waited ~10 seconds for the snapshot to be returned before. These events are not delayed for battery powered devices as they will not return a snapshot while recording a motion/ding event.
- When a snapshot is first requested, a placeholder snapshot ("Fetching Snapshot...") will be returned immediately. A request to get a real snapshot is sent to Ring, and once the snapshot is loaded it is put into a cached. The next time a snapshot is requested (10-60 seconds depending on the network), the cached image will be returned. This image is cached for 2 minutes. If a cached image is pulled, but seen to be more than 10 seconds old, the cached image is returned and a new snapshot load/cache is started.