UNPKG

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.

34 lines 2.37 kB
/** * The two leak channels a UniFi Protect sensor can expose. Single-channel devices carry only "internal"; multi-channel environmental devices carry both. */ export type LeakChannel = "external" | "internal"; /** * The sensor facts the leak policy reads, extracted off the projection as primitives so the leaf stays pure and library-decoupled. The caller pulls channelNames off * featureFlags.waterLeak, and leakSettings / mountType off the sensor config. */ export interface LeakChannelContext { channelNames: readonly string[]; leakSettings: { isExternalEnabled: boolean; isInternalEnabled: boolean; }; mountType: string; } /** * Decide whether a leak channel should be exposed as a HomeKit service. * * The device must HAVE the channel (the capability the controller advertises in featureFlags.waterLeak.channelNames) and it must be ENABLED by the model-correct signal. * Single-channel devices (UP-Sense, channelNames ["internal"]) drive leak via the physical mount role - their leakSettings.isInternalEnabled is a stuck capability echo * (always true), so we IGNORE it and read mountType === "leak". Multi-channel devices (USL-Environmental, ["internal","external"]) expose LIVE per-channel toggles, so we * honor leakSettings. ASSUMPTION (documented, accepted): channel arity is the derivable proxy for which enable signal is authoritative - single-channel => mount-role, * multi-channel => live leakSettings. This holds for all known hardware. It could mis-gate in two directions only a future device could introduce: a single-channel * device whose leakSettings is genuinely LIVE (we would wrongly read mountType), or a multi-channel device whose leakSettings is a stuck echo (we would wrongly trust the * flag). If either ships, THIS leaf is the single chokepoint to add a per-capability override - the consumers never need to change. * * @param context - The sensor facts the policy reads: the advertised leak channelNames, the leakSettings toggles, and the mountType. * @param channel - The leak channel under consideration: "internal" or "external". * * @returns true when the channel should be exposed as a HomeKit service, false when it should not. */ export declare function leakChannelEnabled(context: LeakChannelContext, channel: LeakChannel): boolean; //# sourceMappingURL=leak-policy.d.ts.map