UNPKG

matterbridge

Version:
817 lines (816 loc) 74.2 kB
/** * This file contains the class MatterbridgeEndpoint that extends the Endpoint class from the Matter.js library. * * @file matterbridgeEndpoint.ts * @author Luca Liguori * @date 2024-10-01 * @version 2.1.1 * * Copyright 2024, 2025, 2026 Luca Liguori. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ import { AnsiLogger, LogLevel } from './logger/export.js'; import { DeviceTypeDefinition, MatterbridgeEndpointOptions } from './matterbridgeDeviceTypes.js'; import { ActionContext, AtLeastOne, Behavior, ClusterId, Endpoint, EndpointNumber, HandlerFunction, NamedHandler, ServerNode } from '@matter/main'; import { ClusterType, Semtag } from '@matter/main/types'; import { PowerSource } from '@matter/main/clusters/power-source'; import { Identify } from '@matter/main/clusters/identify'; import { OnOff } from '@matter/main/clusters/on-off'; import { ColorControl } from '@matter/main/clusters/color-control'; import { WindowCovering } from '@matter/main/clusters/window-covering'; import { FanControl } from '@matter/main/clusters/fan-control'; import { DoorLock } from '@matter/main/clusters/door-lock'; import { ModeSelect } from '@matter/main/clusters/mode-select'; import { ValveConfigurationAndControl } from '@matter/main/clusters/valve-configuration-and-control'; import { PumpConfigurationAndControl } from '@matter/main/clusters/pump-configuration-and-control'; import { SmokeCoAlarm } from '@matter/main/clusters/smoke-co-alarm'; import { AirQuality } from '@matter/main/clusters/air-quality'; import { ConcentrationMeasurement } from '@matter/main/clusters/concentration-measurement'; import { OperationalState } from '@matter/main/clusters/operational-state'; import { DeviceEnergyManagement } from '@matter/main/clusters/device-energy-management'; import { DeviceEnergyManagementMode } from '@matter/main/clusters/device-energy-management-mode'; import { ResourceMonitoring } from '@matter/main/clusters/resource-monitoring'; export type PrimitiveTypes = boolean | number | bigint | string | object | undefined | null; export type CommandHandlerFunction = (data: { request: Record<string, any>; cluster: string; attributes: Record<string, PrimitiveTypes>; endpoint: MatterbridgeEndpoint; }) => void | Promise<void>; export interface MatterbridgeEndpointCommands { identify: HandlerFunction; triggerEffect: HandlerFunction; on: HandlerFunction; off: HandlerFunction; toggle: HandlerFunction; offWithEffect: HandlerFunction; moveToLevel: HandlerFunction; moveToLevelWithOnOff: HandlerFunction; moveToColor: HandlerFunction; moveColor: HandlerFunction; stepColor: HandlerFunction; moveToHue: HandlerFunction; moveHue: HandlerFunction; stepHue: HandlerFunction; moveToSaturation: HandlerFunction; moveSaturation: HandlerFunction; stepSaturation: HandlerFunction; moveToHueAndSaturation: HandlerFunction; moveToColorTemperature: HandlerFunction; upOrOpen: HandlerFunction; downOrClose: HandlerFunction; stopMotion: HandlerFunction; goToLiftPercentage: HandlerFunction; goToTiltPercentage: HandlerFunction; lockDoor: HandlerFunction; unlockDoor: HandlerFunction; setpointRaiseLower: HandlerFunction; step: HandlerFunction; changeToMode: HandlerFunction; open: HandlerFunction; close: HandlerFunction; suppressAlarm: HandlerFunction; enableDisableAlarm: HandlerFunction; selfTestRequest: HandlerFunction; resetCounts: HandlerFunction; setUtcTime: HandlerFunction; setTimeZone: HandlerFunction; setDstOffset: HandlerFunction; pauseRequest: HandlerFunction; resumeRequest: HandlerFunction; pause: HandlerFunction; stop: HandlerFunction; start: HandlerFunction; resume: HandlerFunction; goHome: HandlerFunction; selectAreas: HandlerFunction; boost: HandlerFunction; cancelBoost: HandlerFunction; enableCharging: HandlerFunction; disable: HandlerFunction; setTemperature: HandlerFunction; } export interface SerializedMatterbridgeEndpoint { pluginName: string; deviceName: string; serialNumber: string; uniqueId: string; productId?: number; productName?: string; vendorId?: number; vendorName?: string; deviceTypes: DeviceTypeDefinition[]; endpoint: EndpointNumber | undefined; endpointName: string; clusterServersId: ClusterId[]; } export declare class MatterbridgeEndpoint extends Endpoint { /** The bridge mode of Matterbridge */ static bridgeMode: 'bridge' | 'childbridge' | ''; /** The default log level of the new MatterbridgeEndpoints */ static logLevel: LogLevel; /** The logger instance for the MatterbridgeEndpoint */ log: AnsiLogger; /** The plugin name this MatterbridgeEndpoint belongs to */ plugin: string | undefined; /** The configuration URL of the device, if available */ configUrl: string | undefined; deviceName: string | undefined; serialNumber: string | undefined; uniqueId: string | undefined; vendorId: number | undefined; vendorName: string | undefined; productId: number | undefined; productName: string | undefined; softwareVersion: number | undefined; softwareVersionString: string | undefined; hardwareVersion: number | undefined; hardwareVersionString: string | undefined; productUrl: string; /** The server node of the endpoint, if it is a single not bridged endpoint */ serverNode: ServerNode<ServerNode.RootEndpoint> | undefined; /** The name of the first device type of the endpoint (old api compatibility) */ name: string | undefined; /** The code of the first device type of the endpoint (old api compatibility) */ deviceType: number; /** The id of the endpoint (old api compatibility) */ uniqueStorageKey: string | undefined; tagList?: Semtag[]; /** Maps the DeviceTypeDefinitions with their code */ readonly deviceTypes: Map<number, DeviceTypeDefinition>; /** Command handler for the MatterbridgeEndpoint commands */ readonly commandHandler: NamedHandler<MatterbridgeEndpointCommands>; /** * Represents a MatterbridgeEndpoint. * @constructor * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition(s) of the endpoint. * @param {MatterbridgeEndpointOptions} [options={}] - The options for the device. * @param {boolean} [debug=false] - Debug flag. */ constructor(definition: DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>, options?: MatterbridgeEndpointOptions, debug?: boolean); /** * Loads an instance of the MatterbridgeEndpoint class. * * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition(s) of the device. * @param {MatterbridgeEndpointOptions} [options={}] - The options for the device. * @param {boolean} [debug=false] - Debug flag. * @returns {Promise<MatterbridgeEndpoint>} MatterbridgeEndpoint instance. */ static loadInstance(definition: DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>, options?: MatterbridgeEndpointOptions, debug?: boolean): Promise<MatterbridgeEndpoint>; /** * Get all the device types of this endpoint. * * @returns {DeviceTypeDefinition[]} The device types of this endpoint. */ getDeviceTypes(): DeviceTypeDefinition[]; /** * Checks if the provided cluster server is supported by this endpoint. * * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to check. * @returns {boolean} True if the cluster server is supported, false otherwise. */ hasClusterServer(cluster: Behavior.Type | ClusterType | ClusterId | string): boolean; /** * Checks if the provided attribute server is supported for a given cluster of this endpoint. * * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to check. * @param {string} attribute - The attribute name to check. * @returns {boolean} True if the attribute server is supported, false otherwise. */ hasAttributeServer(cluster: Behavior.Type | ClusterType | ClusterId | string, attribute: string): boolean; /** * Retrieves the initial options for the provided cluster server. * * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to get options for. * @returns {Record<string, boolean | number | bigint | string | object | null> | undefined} The options for the provided cluster server, or undefined if the cluster is not supported. */ getClusterServerOptions(cluster: Behavior.Type | ClusterType | ClusterId | string): Record<string, string | number | bigint | boolean | object | null> | undefined; /** * Retrieves the value of the provided attribute from the given cluster. * * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to retrieve the attribute from. * @param {string} attribute - The name of the attribute to retrieve. * @param {AnsiLogger} [log] - Optional logger for error and info messages. * @returns {any} The value of the attribute, or undefined if the attribute is not found. */ getAttribute(cluster: Behavior.Type | ClusterType | ClusterId | string, attribute: string, log?: AnsiLogger): any; /** * Sets the value of an attribute on a cluster server. * * @param {Behavior.Type | ClusterType | ClusterId | string} clusterId - The ID of the cluster. * @param {string} attribute - The name of the attribute. * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute. * @param {AnsiLogger} [log] - (Optional) The logger to use for logging errors and information. * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set. */ setAttribute(clusterId: Behavior.Type | ClusterType | ClusterId | string, attribute: string, value: boolean | number | bigint | string | object | null, log?: AnsiLogger): Promise<boolean>; /** * Update the value of an attribute on a cluster server only if the value is different. * * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to set the attribute on. * @param {string} attribute - The name of the attribute. * @param {boolean | number | bigint | string | object | null} value - The value to set for the attribute. * @param {AnsiLogger} [log] - (Optional) The logger to use for logging the update. Errors are logged to the endpoint logger. * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the attribute was successfully set. */ updateAttribute(cluster: Behavior.Type | ClusterType | ClusterId | string, attribute: string, value: boolean | number | bigint | string | object | null, log?: AnsiLogger): Promise<boolean>; /** * Subscribes to the provided attribute on a cluster. * * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to subscribe the attribute to. * @param {string} attribute - The name of the attribute to subscribe to. * @param {(newValue: any, oldValue: any, context: ActionContext) => void} listener - A callback function that will be called when the attribute value changes. When context.offline === true then the change is locally generated and not from the controller. * @param {AnsiLogger} [log] - Optional logger for logging errors and information. * @returns {Promise<boolean>} - A boolean indicating whether the subscription was successful. * * @remarks The listener function (cannot be async) will receive three parameters: * - `newValue`: The new value of the attribute. * - `oldValue`: The old value of the attribute. * - `context`: The action context, which includes information about the action that triggered the change. When context.offline === true then the change is locally generated and not from the controller. */ subscribeAttribute(cluster: Behavior.Type | ClusterType | ClusterId | string, attribute: string, listener: (newValue: any, oldValue: any, context: ActionContext) => void, log?: AnsiLogger): Promise<boolean>; /** * Triggers an event on the specified cluster. * @param {ClusterId} cluster - The ID of the cluster. * @param {string} event - The name of the event to trigger. * @param {Record<string, boolean | number | bigint | string | object | undefined | null>} payload - The payload to pass to the event. * @param {AnsiLogger} [log] - Optional logger for logging information. * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the event was successfully triggered. */ triggerEvent(cluster: Behavior.Type | ClusterType | ClusterId | string, event: string, payload: Record<string, boolean | number | bigint | string | object | undefined | null>, log?: AnsiLogger): Promise<boolean>; /** * Adds cluster servers from the provided server list. * * @param {ClusterId[]} serverList - The list of cluster IDs to add. * @returns {this} The current MatterbridgeEndpoint instance for chaining. */ addClusterServers(serverList: ClusterId[]): this; /** * Adds a fixed label to the FixedLabel cluster. If the cluster server is not present, it will be added. * * @param {string} label - The label to add. * @param {string} value - The value of the label. * @returns {Promise<this>} The current MatterbridgeEndpoint instance for chaining. */ addFixedLabel(label: string, value: string): Promise<this>; /** * Adds a user label to the UserLabel cluster. If the cluster server is not present, it will be added. * * @param {string} label - The label to add. * @param {string} value - The value of the label. * @returns {Promise<this>} The current MatterbridgeEndpoint instance for chaining. */ addUserLabel(label: string, value: string): Promise<this>; /** * Adds a command handler for the specified command. * * @param {keyof MatterbridgeEndpointCommands} command - The command to add the handler for. * @param {CommandHandlerFunction} handler - The handler function to execute when the command is received. * @returns {this} The current MatterbridgeEndpoint instance for chaining. * * @remarks * The handler function will receive an object with the following properties: * - `request`: The request object sent with the command. * - `cluster`: The id of the cluster that received the command (i.e. "onOff"). * - `attributes`: The current attributes of the cluster that received the command (i.e. { onOff: true}). * - `endpoint`: The MatterbridgeEndpoint instance that received the command. */ addCommandHandler(command: keyof MatterbridgeEndpointCommands, handler: CommandHandlerFunction): this; /** * Execute the command handler for the specified command. Used ONLY in Jest tests. * * @param {keyof MatterbridgeEndpointCommands} command - The command to execute. * @param {Record<string, boolean | number | bigint | string | object | null>} [request] - The optional request to pass to the handler function. * * @deprecated Used ONLY in Jest tests. */ executeCommandHandler(command: keyof MatterbridgeEndpointCommands, request?: Record<string, boolean | number | bigint | string | object | null>): Promise<void>; /** * Invokes a behavior command on the specified cluster. Used ONLY in Jest tests. * * @param {Behavior.Type | ClusterType | ClusterId | string} cluster - The cluster to invoke the command on. * @param {string} command - The command to invoke. * @param {Record<string, boolean | number | bigint | string | object | null>} [params] - The optional parameters to pass to the command. * * @deprecated Used ONLY in Jest tests. */ invokeBehaviorCommand(cluster: Behavior.Type | ClusterType | ClusterId | string, command: keyof MatterbridgeEndpointCommands, params?: Record<string, boolean | number | bigint | string | object | null>): Promise<void>; /** * Adds the required cluster servers (only if they are not present) for the device types of the specified endpoint. * * @returns {this} The current MatterbridgeEndpoint instance for chaining. */ addRequiredClusterServers(): MatterbridgeEndpoint; /** * Adds the optional cluster servers (only if they are not present) for the device types of the specified endpoint. * * @returns {this} The current MatterbridgeEndpoint instance for chaining. */ addOptionalClusterServers(): MatterbridgeEndpoint; /** * Retrieves all cluster servers. * * @returns {Behavior.Type[]} An array of all cluster servers. */ getAllClusterServers(): Behavior.Type[]; /** * Retrieves the names of all cluster servers. * * @returns {string[]} An array of all cluster server names. */ getAllClusterServerNames(): string[]; /** * Iterates over each attribute of each cluster server of the device state and calls the provided callback function. * * @param {Function} callback - The callback function to call with the cluster name, cluster id, attribute name, attribute id and attribute value. */ forEachAttribute(callback: (clusterName: string, clusterId: number, attributeName: string, attributeId: number, attributeValue: boolean | number | bigint | string | object | null | undefined) => void): void; /** * Adds a child endpoint with the specified device types and options. * If the child endpoint is not already present, it will be created and added. * If the child endpoint is already present, the existing child endpoint will be returned. * * @param {string} endpointName - The name of the new endpoint to add. * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The device types to add. * @param {MatterbridgeEndpointOptions} [options={}] - The options for the endpoint. * @param {boolean} [debug=false] - Whether to enable debug logging. * @returns {MatterbridgeEndpoint} - The child endpoint that was found or added. * * @example * ```typescript * const endpoint = device.addChildDeviceType('Temperature', [temperatureSensor], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true); * ``` */ addChildDeviceType(endpointName: string, definition: DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>, options?: MatterbridgeEndpointOptions, debug?: boolean): MatterbridgeEndpoint; /** * Adds a child endpoint with one or more device types with the required cluster servers and the specified cluster servers. * If the child endpoint is not already present in the childEndpoints, it will be added. * If the child endpoint is already present in the childEndpoints, the device types and cluster servers will be added to the existing child endpoint. * * @param {string} endpointName - The name of the new enpoint to add. * @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The device types to add. * @param {ClusterId[]} [serverList=[]] - The list of cluster IDs to include. * @param {MatterbridgeEndpointOptions} [options={}] - The options for the device. * @param {boolean} [debug=false] - Whether to enable debug logging. * @returns {MatterbridgeEndpoint} - The child endpoint that was found or added. * * @example * ```typescript * const endpoint = device.addChildDeviceTypeWithClusterServer('Temperature', [temperatureSensor], [], { tagList: [{ mfgCode: null, namespaceId: LocationTag.Indoor.namespaceId, tag: LocationTag.Indoor.tag, label: null }] }, true); * ``` */ addChildDeviceTypeWithClusterServer(endpointName: string, definition: DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>, serverList?: ClusterId[], options?: MatterbridgeEndpointOptions, debug?: boolean): MatterbridgeEndpoint; /** * Retrieves a child endpoint by its name. * * @param {string} endpointName - The name of the endpoint to retrieve. * @returns {Endpoint | undefined} The child endpoint with the specified name, or undefined if not found. */ getChildEndpointByName(endpointName: string): MatterbridgeEndpoint | undefined; /** * Retrieves a child endpoint by its EndpointNumber. * * @param {EndpointNumber} endpointNumber - The EndpointNumber of the endpoint to retrieve. * @returns {MatterbridgeEndpoint | undefined} The child endpoint with the specified EndpointNumber, or undefined if not found. */ getChildEndpoint(endpointNumber: EndpointNumber): MatterbridgeEndpoint | undefined; /** * Get all the child endpoints of this endpoint. * * @returns {MatterbridgeEndpoint[]} The child endpoints. */ getChildEndpoints(): MatterbridgeEndpoint[]; /** * Serializes the Matterbridge device into a serialized object. * * @param pluginName - The name of the plugin. * @returns The serialized Matterbridge device object. */ static serialize(device: MatterbridgeEndpoint): SerializedMatterbridgeEndpoint | undefined; /** * Deserializes the device into a serialized object. * * @returns The deserialized MatterbridgeDevice. */ static deserialize(serializedDevice: SerializedMatterbridgeEndpoint): MatterbridgeEndpoint | undefined; /** * Creates a default power source wired cluster server. * * @param wiredCurrentType - The type of wired current (default: PowerSource.WiredCurrentType.Ac) * @returns {this} The current MatterbridgeEndpoint instance for chaining. */ createDefaultPowerSourceWiredClusterServer(wiredCurrentType?: PowerSource.WiredCurrentType): this; /** * Creates a default power source replaceable battery cluster server. * * @param batPercentRemaining - The remaining battery percentage (default: 100). * @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok). * @param batVoltage - The battery voltage (default: 1500). * @param batReplacementDescription - The battery replacement description (default: 'Battery type'). * @param batQuantity - The battery quantity (default: 1). * @returns {this} The current MatterbridgeEndpoint instance for chaining. */ createDefaultPowerSourceReplaceableBatteryClusterServer(batPercentRemaining?: number, batChargeLevel?: PowerSource.BatChargeLevel, batVoltage?: number, batReplacementDescription?: string, batQuantity?: number): this; /** * Creates a default power source rechargeable battery cluster server. * * @param batPercentRemaining - The remaining battery percentage (default: 100). * @param batChargeLevel - The battery charge level (default: PowerSource.BatChargeLevel.Ok). * @param batVoltage - The battery voltage (default: 1500). * @returns {this} The current MatterbridgeEndpoint instance for chaining. */ createDefaultPowerSourceRechargeableBatteryClusterServer(batPercentRemaining?: number, batChargeLevel?: PowerSource.BatChargeLevel, batVoltage?: number): this; /** * Setup the default Basic Information Cluster Server attributes for the server node. * * @param deviceName - The name of the device. * @param serialNumber - The serial number of the device. * @param vendorId - The vendor ID of the device. * @param vendorName - The vendor name of the device. * @param productId - The product ID of the device. * @param productName - The product name of the device. * @param softwareVersion - The software version of the device. Default is 1. * @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'. * @param hardwareVersion - The hardware version of the device. Default is 1. * @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'. * @returns {this} The current MatterbridgeEndpoint instance for chaining. */ createDefaultBasicInformationClusterServer(deviceName: string, serialNumber: string, vendorId: number, vendorName: string, productId: number, productName: string, softwareVersion?: number, softwareVersionString?: string, hardwareVersion?: number, hardwareVersionString?: string): this; /** * Creates a default BridgedDeviceBasicInformationClusterServer for the aggregator endpoints. * * @param deviceName - The name of the device. * @param serialNumber - The serial number of the device. * @param vendorId - The vendor ID of the device. * @param vendorName - The name of the vendor. * @param productName - The name of the product. * @param softwareVersion - The software version of the device. Default is 1. * @param softwareVersionString - The software version string of the device. Default is 'v.1.0.0'. * @param hardwareVersion - The hardware version of the device. Default is 1. * @param hardwareVersionString - The hardware version string of the device. Default is 'v.1.0.0'. * @returns {this} The current MatterbridgeEndpoint instance for chaining. * * @remarks The bridgedNode device type must be added to the deviceTypeList of the Descriptor cluster. */ createDefaultBridgedDeviceBasicInformationClusterServer(deviceName: string, serialNumber: string, vendorId: number, vendorName: string, productName: string, softwareVersion?: number, softwareVersionString?: string, hardwareVersion?: number, hardwareVersionString?: string): this; /** * Creates a default identify cluster server with the specified identify time and type. * * @param {number} [identifyTime=0] - The time to identify the server. Defaults to 0. * @param {Identify.IdentifyType} [identifyType=Identify.IdentifyType.None] - The type of identification. Defaults to Identify.IdentifyType.None. * @returns {this} The current MatterbridgeEndpoint instance for chaining. */ createDefaultIdentifyClusterServer(identifyTime?: number, identifyType?: Identify.IdentifyType): this; /** * Creates a default groups cluster server. * @returns {this} The current MatterbridgeEndpoint instance for chaining. */ createDefaultGroupsClusterServer(): this; /** * Creates a default scenes management cluster server. * @returns {this} The current MatterbridgeEndpoint instance for chaining. * * @remarks The scenes management cluster server is still provisional and so not yet implemented. */ createDefaultScenesClusterServer(): this; /** * Creates a default OnOff cluster server for light devices with feature Lighting. * * @param {boolean} [onOff=false] - The initial state of the OnOff cluster. * @param {boolean} [globalSceneControl=false] - The global scene control state. * @param {number} [onTime=0] - The on time value. * @param {number} [offWaitTime=0] - The off wait time value. * @param {OnOff.StartUpOnOff | null} [startUpOnOff=null] - The start-up OnOff state. Null means previous state. * @returns {this} The current MatterbridgeEndpoint instance for chaining. */ createDefaultOnOffClusterServer(onOff?: boolean, globalSceneControl?: boolean, onTime?: number, offWaitTime?: number, startUpOnOff?: OnOff.StartUpOnOff | null): this; /** * Creates an OnOff cluster server without features. * * @param {boolean} [onOff=false] - The initial state of the OnOff cluster. * @returns {this} The current MatterbridgeEndpoint instance for chaining. */ createOnOffClusterServer(onOff?: boolean): this; /** * Creates a DeadFront OnOff cluster server with feature DeadFrontBehavior. * * @param {boolean} [onOff=false] - The initial state of the OnOff cluster. * @returns {this} The current MatterbridgeEndpoint instance for chaining. */ createDeadFrontOnOffClusterServer(onOff?: boolean): this; /** * Creates an OffOnly OnOff cluster server with feature OffOnly. * * @param {boolean} [onOff=false] - The initial state of the OnOff cluster. * @returns {this} The current MatterbridgeEndpoint instance for chaining. */ createOffOnlyOnOffClusterServer(onOff?: boolean): this; /** * Creates a default level control cluster server for light devices with feature OnOff and Lighting. * * @param {number} [currentLevel=254] - The current level (default: 254). * @param {number} [minLevel=1] - The minimum level (default: 1). * @param {number} [maxLevel=254] - The maximum level (default: 254). * @param {number | null} [onLevel=null] - The on level (default: null). * @param {number | null} [startUpCurrentLevel=null] - The startUp on level (default: null). * @returns {this} The current MatterbridgeEndpoint instance for chaining. */ createDefaultLevelControlClusterServer(currentLevel?: number, minLevel?: number, maxLevel?: number, onLevel?: number | null, startUpCurrentLevel?: number | null): this; /** * Creates a level control cluster server without features. * * @param {number} [currentLevel=254] - The current level (default: 254). * @param {number | null} [onLevel=null] - The on level (default: null). * @returns {this} The current MatterbridgeEndpoint instance for chaining. */ createLevelControlClusterServer(currentLevel?: number, onLevel?: number | null): this; /** * Creates a default color control cluster server with features Xy, HueSaturation and ColorTemperature. * * @param currentX - The current X value (range 0-65279). * @param currentY - The current Y value (range 0-65279). * @param currentHue - The current hue value (range: 0-254). * @param currentSaturation - The current saturation value (range: 0-254). * @param colorTemperatureMireds - The color temperature in mireds (default range 147-500). * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds (default range 147). * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds (default range 500). * @returns {this} The current MatterbridgeEndpoint instance for chaining. * * @remarks colorMode and enhancedColorMode persist across restarts. * @remarks currentHue and currentSaturation persist across restarts. * @remarks currentX and currentY persist across restarts. * @remarks colorTemperatureMireds persists across restarts. * @remarks startUpColorTemperatureMireds persists across restarts. * @remarks coupleColorTempToLevelMinMireds persists across restarts. */ createDefaultColorControlClusterServer(currentX?: number, currentY?: number, currentHue?: number, currentSaturation?: number, colorTemperatureMireds?: number, colorTempPhysicalMinMireds?: number, colorTempPhysicalMaxMireds?: number): this; /** * Creates a Xy color control cluster server with feature Xy and ColorTemperature. * * @param currentX - The current X value. * @param currentY - The current Y value. * @param colorTemperatureMireds - The color temperature in mireds. * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds. * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds. * @returns {this} The current MatterbridgeEndpoint instance for chaining. * * @remarks * From zigbee to matter = Math.max(Math.min(Math.round(x * 65536), 65279), 0) * * @remarks colorMode and enhancedColorMode persist across restarts. * @remarks currentX and currentY persist across restarts. * @remarks colorTemperatureMireds persists across restarts. * @remarks startUpColorTemperatureMireds persists across restarts. * @remarks coupleColorTempToLevelMinMireds persists across restarts. */ createXyColorControlClusterServer(currentX?: number, currentY?: number, colorTemperatureMireds?: number, colorTempPhysicalMinMireds?: number, colorTempPhysicalMaxMireds?: number): this; /** * Creates a default hue and saturation control cluster server with feature HueSaturation and ColorTemperature. * * @param currentHue - The current hue value. * @param currentSaturation - The current saturation value. * @param colorTemperatureMireds - The color temperature in mireds. * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds. * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds. * @returns {this} The current MatterbridgeEndpoint instance for chaining. * * @remarks colorMode and enhancedColorMode persist across restarts. * @remarks currentHue and currentSaturation persist across restarts. * @remarks colorTemperatureMireds persists across restarts. * @remarks startUpColorTemperatureMireds persists across restarts. * @remarks coupleColorTempToLevelMinMireds persists across restarts. */ createHsColorControlClusterServer(currentHue?: number, currentSaturation?: number, colorTemperatureMireds?: number, colorTempPhysicalMinMireds?: number, colorTempPhysicalMaxMireds?: number): this; /** * Creates a color temperature color control cluster server with feature ColorTemperature. * This cluster server is used for devices that only support color temperature control. * * @param colorTemperatureMireds - The color temperature in mireds. Defaults to 250. * @param colorTempPhysicalMinMireds - The physical minimum color temperature in mireds. Defaults to 147. * @param colorTempPhysicalMaxMireds - The physical maximum color temperature in mireds. Defaults to 500. * @returns {this} The current MatterbridgeEndpoint instance for chaining. * * @remarks colorMode and enhancedColorMode persist across restarts. * @remarks colorTemperatureMireds persists across restarts. * @remarks startUpColorTemperatureMireds persists across restarts. * @remarks coupleColorTempToLevelMinMireds persists across restarts. */ createCtColorControlClusterServer(colorTemperatureMireds?: number, colorTempPhysicalMinMireds?: number, colorTempPhysicalMaxMireds?: number): this; /** * Configures the color control mode for the device. * * @param {ColorControl.ColorMode} colorMode - The color mode to set. * * @remarks colorMode and enhancedColorMode persist across restarts. */ configureColorControlMode(colorMode: ColorControl.ColorMode): Promise<void>; /** * Creates a default window covering cluster server with feature Lift and PositionAwareLift. * * @param {number} positionPercent100ths - The position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened. * @param {WindowCovering.WindowCoveringType} type - The type of window covering (default: WindowCovering.WindowCoveringType.Rollershade). Must support feature Lift. * @param {WindowCovering.EndProductType} endProductType - The end product type (default: WindowCovering.EndProductType.RollerShade). Must support feature Lift. * @returns {this} The current MatterbridgeEndpoint instance for chaining. * * @remarks mode attributes is writable and persists across restarts. * currentPositionLiftPercent100ths persists across restarts. * configStatus attributes persists across restarts. */ createDefaultWindowCoveringClusterServer(positionPercent100ths?: number, type?: WindowCovering.WindowCoveringType, endProductType?: WindowCovering.EndProductType): this; /** * Creates a default window covering cluster server with features Lift, PositionAwareLift, Tilt, PositionAwareTilt. * * @param {number} positionLiftPercent100ths - The lift position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened. * @param {number} positionTiltPercent100ths - The tilt position percentage in 100ths (0-10000). Defaults to 0. Matter uses 10000 = fully closed 0 = fully opened. * @param {WindowCovering.WindowCoveringType} type - The type of window covering (default: WindowCovering.WindowCoveringType.TiltBlindLift). Must support features Lift and Tilt. * @param {WindowCovering.EndProductType} endProductType - The end product type (default: WindowCovering.EndProductType.InteriorBlind). Must support features Lift and Tilt. * @returns {this} The current MatterbridgeEndpoint instance for chaining. * * @remarks mode attributes is writable and persists across restarts. * currentPositionTiltPercent100ths persists across restarts. * configStatus attributes persists across restarts. */ createDefaultLiftTiltWindowCoveringClusterServer(positionLiftPercent100ths?: number, positionTiltPercent100ths?: number, type?: WindowCovering.WindowCoveringType, endProductType?: WindowCovering.EndProductType): this; /** * Sets the window covering lift target position as the current position and stops the movement. * */ setWindowCoveringTargetAsCurrentAndStopped(): Promise<void>; /** * Sets the lift current and target position and the status of a window covering. * @param {number} current - The current position of the window covering. * @param {number} target - The target position of the window covering. * @param {WindowCovering.MovementStatus} status - The movement status of the window covering. */ setWindowCoveringCurrentTargetStatus(current: number, target: number, status: WindowCovering.MovementStatus): Promise<void>; /** * Sets the status of the window covering. * @param {WindowCovering.MovementStatus} status - The movement status to set. */ setWindowCoveringStatus(status: WindowCovering.MovementStatus): Promise<void>; /** * Retrieves the status of the window covering. * * @returns The global operational status of the window covering or undefined. */ getWindowCoveringStatus(): WindowCovering.MovementStatus | undefined; /** * Sets the lift target and current position of the window covering. * * @param {number} liftPosition - The position to set, specified as a number. * @param {number} [tiltPosition] - The tilt position to set, specified as a number. */ setWindowCoveringTargetAndCurrentPosition(liftPosition: number, tiltPosition?: number): Promise<void>; /** * Creates a default thermostat cluster server with features Heating, Cooling and AutoMode. * * @param {number} [localTemperature=23] - The local temperature value in degrees Celsius. Defaults to 23°. * @param {number} [occupiedHeatingSetpoint=21] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°. * @param {number} [occupiedCoolingSetpoint=25] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°. * @param {number} [minSetpointDeadBand=1] - The minimum setpoint dead band value. Defaults to 1°. * @param {number} [minHeatSetpointLimit=0] - The minimum heat setpoint limit value. Defaults to 0°. * @param {number} [maxHeatSetpointLimit=50] - The maximum heat setpoint limit value. Defaults to 50°. * @param {number} [minCoolSetpointLimit=0] - The minimum cool setpoint limit value. Defaults to 0°. * @param {number} [maxCoolSetpointLimit=50] - The maximum cool setpoint limit value. Defaults to 50°. * @returns {this} The current MatterbridgeEndpoint instance for chaining. */ createDefaultThermostatClusterServer(localTemperature?: number, occupiedHeatingSetpoint?: number, occupiedCoolingSetpoint?: number, minSetpointDeadBand?: number, minHeatSetpointLimit?: number, maxHeatSetpointLimit?: number, minCoolSetpointLimit?: number, maxCoolSetpointLimit?: number): this; /** * Creates a default heating thermostat cluster server with feature Heating. * @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°. * @param {number} [occupiedHeatingSetpoint] - The occupied heating setpoint value in degrees Celsius. Defaults to 21°. * @param {number} [minHeatSetpointLimit] - The minimum heat setpoint limit value. Defaults to 0°. * @param {number} [maxHeatSetpointLimit] - The maximum heat setpoint limit value. Defaults to 50°. * @returns {this} The current MatterbridgeEndpoint instance for chaining. */ createDefaultHeatingThermostatClusterServer(localTemperature?: number, occupiedHeatingSetpoint?: number, minHeatSetpointLimit?: number, maxHeatSetpointLimit?: number): this; /** * Creates a default cooling thermostat cluster server with feature Cooling. * @param {number} [localTemperature] - The local temperature value in degrees Celsius. Defaults to 23°. * @param {number} [occupiedCoolingSetpoint] - The occupied cooling setpoint value in degrees Celsius. Defaults to 25°. * @param {number} [minCoolSetpointLimit] - The minimum cool setpoint limit value. Defaults to 0°. * @param {number} [maxCoolSetpointLimit] - The maximum cool setpoint limit value. Defaults to 50°. * @returns {this} The current MatterbridgeEndpoint instance for chaining. */ createDefaultCoolingThermostatClusterServer(localTemperature?: number, occupiedCoolingSetpoint?: number, minCoolSetpointLimit?: number, maxCoolSetpointLimit?: number): this; /** * Creates a default thermostat user interface configuration cluster server. * * @remarks * The default values are: * - temperatureDisplayMode: ThermostatUserInterfaceConfiguration.TemperatureDisplayMode.Celsius (writeble). * - keypadLockout: ThermostatUserInterfaceConfiguration.KeypadLockout.NoLockout (writeble). * - scheduleProgrammingVisibility: ThermostatUserInterfaceConfiguration.ScheduleProgrammingVisibility.ScheduleProgrammingPermitted (writeble). */ createDefaultThermostatUserInterfaceConfigurationClusterServer(): this; /** * Creates a default fan control cluster server with features Auto, and Step. * * @param {FanControl.FanMode} [fanMode=FanControl.FanMode.Off] - The fan mode to set. Defaults to `FanControl.FanMode.Off`. * @param {FanControl.FanModeSequence} [fanModeSequence=FanControl.FanModeSequence.OffLowMedHighAuto] - The fan mode sequence to set. Defaults to `FanControl.FanModeSequence.OffLowMedHighAuto`. * @param {number} [percentSetting=0] - The initial percent setting. Defaults to 0. * @param {number} [percentCurrent=0] - The initial percent current. Defaults to 0. * @returns {this} The current MatterbridgeEndpoint instance for chaining. * * @remarks * - fanmode is writable and persists across reboots. * - fanModeSequence is fixed. * - percentSetting is writable. */ createDefaultFanControlClusterServer(fanMode?: FanControl.FanMode, fanModeSequence?: FanControl.FanModeSequence, percentSetting?: number, percentCurrent?: number): this; /** * Creates a fan control cluster server with features MultiSpeed, Auto, and Step. * * @param {FanControl.FanMode} [fanMode=FanControl.FanMode.Off] - The fan mode to set. Defaults to `FanControl.FanMode.Off`. * @param {number} [percentSetting=0] - The initial percent setting. Defaults to 0. * @param {number} [percentCurrent=0] - The initial percent current. Defaults to 0. * @param {number} [speedMax=10] - The maximum speed setting. Defaults to 10. * @param {number} [speedSetting=0] - The initial speed setting. Defaults to 0. * @param {number} [speedCurrent=0] - The initial speed current. Defaults to 0. * @returns {this} The current MatterbridgeEndpoint instance for chaining. * * @remarks * - fanmode is writable and persists across reboots. * - fanModeSequence is fixed. * - percentSetting is writable. * - speedMax is fixed. * - speedSetting is writable. */ createMultiSpeedFanControlClusterServer(fanMode?: FanControl.FanMode, fanModeSequence?: FanControl.FanModeSequence, percentSetting?: number, percentCurrent?: number, speedMax?: number, speedSetting?: number, speedCurrent?: number): this; /** * Creates a base fan control cluster server without features. * * @param {FanControl.FanMode} [fanMode=FanControl.FanMode.Off] - The fan mode to set. Defaults to `FanControl.FanMode.Off`. * @param {FanControl.FanModeSequence} [fanModeSequence=FanControl.FanModeSequence.OffLowMedHigh] - The fan mode sequence to set. Defaults to `FanControl.FanModeSequence.OffLowMedHigh`. * @param {number} [percentSetting=0] - The initial percent setting. Defaults to 0. * @param {number} [percentCurrent=0] - The initial percent current. Defaults to 0. * @returns {this} The current MatterbridgeEndpoint instance for chaining. * * @remarks * fanmode is writable and persists across reboots. * fanModeSequence is fixed. * percentSetting is writable. */ createBaseFanControlClusterServer(fanMode?: FanControl.FanMode, fanModeSequence?: FanControl.FanModeSequence, percentSetting?: number, percentCurrent?: number): this; /** * Creates a default HEPA Filter Monitoring Cluster Server with features Condition and ReplacementProductList. * It supports ResourceMonitoring.Feature.Condition and ResourceMonitoring.Feature.ReplacementProductList. * * @param {ResourceMonitoring.ChangeIndication} changeIndication - The initial change indication. Default is ResourceMonitoring.ChangeIndication.Ok. * @param {boolean | undefined} inPlaceIndicator - The in-place indicator. Default is undefined. * @param {number | undefined} lastChangedTime - The last changed time (EpochS). Default is undefined. * * @returns {this} The current MatterbridgeEndpoint instance for chaining. */ createDefaultHepaFilterMonitoringClusterServer(changeIndication?: ResourceMonitoring.ChangeIndication, inPlaceIndicator?: boolean | undefined, lastChangedTime?: number | undefined): this; /** * Creates a default Activated Carbon Filter Monitoring Cluster Server with features Condition and ReplacementProductList. * * @param {ResourceMonitoring.ChangeIndication} changeIndication - The initial change indication. Default is ResourceMonitoring.ChangeIndication.Ok. * @param {boolean | undefined} inPlaceIndicator - The in-place indicator. Default is undefined. * @param {number | undefined} lastChangedTime - The last changed time (EpochS). Default is undefined. * * @returns {this} The current MatterbridgeEndpoint instance for chaining. */ createDefaultActivatedCarbonFilterMonitoringClusterServer(changeIndication?: ResourceMonitoring.ChangeIndication, inPlaceIndicator?: boolean | undefined, lastChangedTime?: number | undefined): this; /** * Creates a default door lock cluster server. * * @param {DoorLock.LockState} [lockState=DoorLock.LockState.Locked] - The initial state of the lock (default: Locked). * @param {DoorLock.LockType} [lockType=DoorLock.LockType.DeadBolt] - The type of the lock (default: DeadBolt). * @returns {this} The current MatterbridgeEndpoint instance for chaining. * * @remarks * All operating modes NOT supported by a lock SHALL be set to one. The value of the OperatingMode enumeration defines the related bit to be set. */ createDefaultDoorLockClusterServer(lockState?: DoorLock.LockState, lockType?: DoorLock.LockType): this; /** * Creates a default Mode Select cluster server. * * @param {string} description - The description of the mode select cluster. * @param {ModeSelect.ModeOption[]} supportedModes - The list of supported modes. * @param {number} [currentMode=0] - The current mode (default: 0). * @param {number} [startUpMode=0] - The startup mode (default: 0). * @returns {this} The current MatterbridgeEndpoint instance for chaining. * * @remarks * endpoint.createDefaultModeSelectClusterServer('Night mode', [{ label: 'Led ON', mode: 0, semanticTags: [] }, { label: 'Led OFF', mode: 1, semanticTags: [] }], 0, 0); */ createDefaultModeSelectClusterServer(description: string, supportedModes: ModeSelect.ModeOption[], currentMode?: number, startUpMode?: number): this; /** * Creates the default Valve Configuration And Control cluster server with features Level. * * @param {ValveConfigurationAndControl.ValveState} [valveState=ValveConfigurationAndControl.ValveState.Closed] - The valve state to set. Defaults to `ValveConfigurationAndControl.ValveState.Closed`. * @param {number} [valveLevel=0] - The valve level to set. Defaults to 0. * @returns {this} The current MatterbridgeEndpoint instance for chaining.