homebridge-unifi-protect
Version:
Homebridge UniFi Protect plugin providing complete HomeKit integration for the entire UniFi Protect ecosystem with full support for most features including HomeKit Secure Video, multiple controllers, blazing fast performance, and much more.
32 lines • 2.36 kB
TypeScript
import type { RecoveryContext, RecoveryDecision } from "unifi-protect";
import type { NvrHealthState } from "../nvr/nvr-health.ts";
import type { NvrPhase } from "../nvr/nvr.ts";
export declare const LIVE_SELF_HEAL_THRESHOLD = 10;
/**
* The pure decision core of the plugin's livestream recovery policy. Given the library-observable {@link RecoveryContext} and a snapshot of the plugin's
* controller-health and lifecycle-phase reads, it returns the {@link RecoveryDecision} the library's recovery loop will honor. It is pure - no live reads, no side
* effects - so it is exhaustively unit-testable with constructed inputs, and the live reads are supplied by the thin closure wired at `ProtectClient.connect`.
*
* Establishment is delegated wholesale to the library default (it is hardware-bound and health-independent); past establishment the ordered policy is a sequence of
* steps, the first match winning:
*
* 1. An induced disruption (our own reboot/shutdown) waits, so we do not fight our own teardown with reconnects.
* 2. A drowning controller (the hard reachability gate) waits indefinitely and never reboots a camera.
* 3. This one camera is unavailable on an otherwise-healthy controller, so wait rather than burn reconnect attempts toward the self-heal give-up.
* 4. A wedged camera on a reachable controller gives up after the self-heal threshold, so the consumer reboots it.
* 5. An idle stream under elevated-but-reachable symptoms eases off for a bounded window.
* 6. Otherwise - healthy, latency-sensitive, or soft budget spent - reconnect with the library default's self-tuning timing.
*
* @param context - The library-observable recovery context (attempts, cameraId, elapsedMs, phase, toleranceMs).
* @param nvr - A snapshot of the plugin's controller-health and lifecycle-phase reads at the decision point.
* @param cameraReachable - Whether the episode's camera is currently reachable, resolved by the consumer's closure (the unavailable-defer gate's sole input).
*
* @returns The recovery decision for this step.
*/
export declare function livestreamRecoveryDecision(context: RecoveryContext, nvr: {
healthState: NvrHealthState;
isHealthy: boolean;
isThrottled: boolean;
phase: NvrPhase;
}, cameraReachable: boolean): RecoveryDecision;
//# sourceMappingURL=livestream-recovery-policy.d.ts.map