UNPKG

matterbridge

Version:
47 lines 2.63 kB
/** * This file contains the helpers functions of Matterbridge. * * @file helpers.ts * @author Luca Liguori * @date 2025-05-12 * @version 1.0.0 * * Copyright 2025, 2026, 2027 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 { Endpoint } from '@matter/node'; import { AggregatorEndpoint } from '@matter/node/endpoints/aggregator'; import { Matterbridge } from './matterbridge.js'; /** * Adds a virtual device to the provided endpoint, sets up an event listener for device state changes, * and ensures the device is initialized in the off state. * * @param {Endpoint<AggregatorEndpoint>} aggregatorEndpoint - The aggragator endpoint to which the virtual device will be added. * @param {string} name - The name of the virtual device. Spaces in the name are removed to form the device ID. * @param {'light' | 'outlet' | 'switch' | 'mounted_switch'} type - The type of the virtual device. Can be 'light', 'outlet', 'switch', or 'mounted_switch'. * @param {() => Promise<void>} callback - A callback function that gets executed when the device's on/off state changes to true. * @returns {Promise<Endpoint>} A promise that resolves with the created virtual device. * @remark The virtual device is created as an instance of `Endpoint` with the `OnOffPlugInUnitDevice` device type. * The onOff state always reverts to false when the device is turned on. */ export declare function addVirtualDevice(aggregatorEndpoint: Endpoint<AggregatorEndpoint>, name: string, type: 'light' | 'outlet' | 'switch' | 'mounted_switch', callback: () => Promise<void>): Promise<Endpoint>; /** * Creates and add the virtual devices to the aggregator. * * @param {Matterbridge} matterbridge - The Matterbridge instance. * @param {Endpoint<AggregatorEndpoint>} aggregatorEndpoint - The aggregator node to add the virtual devices to. * @returns {Promise<void>} A promise that resolves when the virtual devices are added. */ export declare function addVirtualDevices(matterbridge: Matterbridge, aggregatorEndpoint: Endpoint<AggregatorEndpoint>): Promise<void>; //# sourceMappingURL=helpers.d.ts.map