UNPKG

homebridge

Version:
99 lines 5 kB
/** * Helper functions for MatterServer.registerAccessory() * Extracted from the monolithic 521-line function for better maintainability */ import type { EndpointType } from '@matter/main'; import type { LevelControl } from '@matter/main/clusters/level-control'; import type { Behavior } from '@matter/node'; import type { MatterAccessory } from './types.js'; /** * Type representing a behavior class (constructor) */ type BehaviorType = Behavior.Type; /** * Cluster IDs from Matter specification * Using Matter.js Cluster references instead of magic numbers */ export declare const CLUSTER_IDS: { readonly AIR_QUALITY: import("@matter/main").Brand<"ClusterId"> & 91; readonly CARBON_MONOXIDE_CONCENTRATION: import("@matter/main").Brand<"ClusterId"> & 1036; readonly COLOR_CONTROL: import("@matter/main").Brand<"ClusterId"> & 768; readonly DOOR_LOCK: import("@matter/main").Brand<"ClusterId"> & 257; readonly LEVEL_CONTROL: import("@matter/main").Brand<"ClusterId"> & 8; readonly NITROGEN_DIOXIDE_CONCENTRATION: import("@matter/main").Brand<"ClusterId"> & 1043; readonly ON_OFF: import("@matter/main").Brand<"ClusterId"> & 6; readonly OZONE_CONCENTRATION: import("@matter/main").Brand<"ClusterId"> & 1045; readonly PM10_CONCENTRATION: import("@matter/main").Brand<"ClusterId"> & 1069; readonly PM25_CONCENTRATION: import("@matter/main").Brand<"ClusterId"> & 1066; readonly THERMOSTAT: import("@matter/main").Brand<"ClusterId"> & 513; readonly WINDOW_COVERING: import("@matter/main").Brand<"ClusterId"> & 258; }; /** * Validates required fields on a Matter accessory * @throws MatterDeviceError if validation fails */ export declare function validateAccessoryRequiredFields(accessory: MatterAccessory): void; /** * Generic feature detection from device type behaviors * Extracts supported features from a device type's cluster definition * * @param deviceType - The Matter device type * @param clusterIdOrName - Cluster ID (number) or name (string) * @param featureExtractor - Function to extract feature names from supportedFeatures * @returns Array of detected features or null if cluster not found */ export declare function detectBehaviorFeatures(deviceType: EndpointType, clusterIdOrName: number | string, featureExtractor: (supportedFeatures: Record<string, boolean>) => string[]): string[] | null; /** * Extract ColorControl features from supportedFeatures */ export declare function extractColorControlFeatures(supportedFeatures: Record<string, boolean>): string[]; /** * Extract Thermostat features from supportedFeatures */ export declare function extractThermostatFeatures(supportedFeatures: Record<string, boolean>): string[]; /** * Extract LevelControl features from supportedFeatures. * * Used to read features off a device type's declared LevelControl requirement * (e.g. DimmableLightDevice's `LevelControlServer.with("Lighting","OnOff")`). * When the device type doesn't declare LevelControl at all (e.g. PumpDevice, * which has LevelControl only in its `optional` requirements and not in * `SupportedBehaviors`), the caller should apply an empty feature set via * `.with()` so the Lighting feature inherited from matter.js's internal * `LevelControlBase = LevelControlBehavior.with(OnOff, Lighting)` is stripped * — otherwise the Pump endpoint inherits the `[LT]` branch of the spec * (minLevel constraint 1-254, initializeLighting warnings) that only applies * to lighting devices. */ export declare function extractLevelControlFeatures(supportedFeatures: Record<string, boolean>): LevelControl.Features[]; /** * Determine ColorControl features based on handlers * Only includes features that have corresponding handler methods */ export declare function determineColorControlFeaturesFromHandlers(handlers: Record<string, unknown>): string[]; /** * Detect WindowCovering features from accessory attributes * Auto-detects Lift and Tilt capabilities based on cluster attributes * * @param accessory - Matter accessory to inspect * @returns Array of detected feature names */ export declare function detectWindowCoveringFeatures(accessory: MatterAccessory): string[]; /** * Detect ServiceArea features from cluster attributes */ export declare function detectServiceAreaFeatures(serviceAreaCluster: Record<string, unknown> | undefined): string[]; /** * Apply WindowCovering features to device type */ export declare function applyWindowCoveringFeatures(deviceType: EndpointType, accessory: MatterAccessory, features: string[]): EndpointType; /** * Build custom behaviors for RoboticVacuumCleaner devices */ export declare function buildRvcCustomBehaviors(accessory: MatterAccessory, serviceAreaFeatures: string[] | null): BehaviorType[]; /** * Apply detected features to a behavior class */ export declare function applyFeaturesToBehavior(behaviorClass: BehaviorType, features: string[] | null, clusterName: string): BehaviorType; export {}; //# sourceMappingURL=serverHelpers.d.ts.map