UNPKG

matterbridge

Version:
114 lines 3.88 kB
/** * This file contains the DeviceManager class. * * @file devices.ts * @author Luca Liguori * @date 2024-07-26 * @version 1.0.9 * * 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 { LogLevel } from './logger/export.js'; import { NodeStorage } from './storage/export.js'; import { Matterbridge } from './matterbridge.js'; import { MatterbridgeEndpoint } from './matterbridgeEndpoint.js'; /** * Manages Matterbridge devices. */ export declare class DeviceManager { private readonly _devices; private readonly matterbridge; private readonly nodeContext; private readonly log; /** * Creates an instance of DeviceManager. * * @param {Matterbridge} matterbridge - The Matterbridge instance. * @param {NodeStorage} nodeContext - The node storage context. */ constructor(matterbridge: Matterbridge, nodeContext: NodeStorage); /** * Gets the number of devices. * * @returns {number} The number of devices. */ get length(): number; /** * Gets the number of devices. * * @returns {number} The number of devices. */ get size(): number; /** * Checks if a device with the specified unique ID exists. * * @param {string} uniqueId - The unique ID of the device. * @returns {boolean} True if the device exists, false otherwise. */ has(uniqueId: string): boolean; /** * Gets a device by its unique ID. * * @param {string} uniqueId - The unique ID of the device. * @returns {MatterbridgeEndpoint | undefined} The device, or undefined if not found. */ get(uniqueId: string): MatterbridgeEndpoint | undefined; /** * Adds a device to the manager. * * @param {MatterbridgeEndpoint} device - The device to add. * @returns {MatterbridgeEndpoint} The added device. * @throws {Error} If the device does not have a unique ID. */ set(device: MatterbridgeEndpoint): MatterbridgeEndpoint; /** * Removes a device from the manager. * * @param {MatterbridgeEndpoint} device - The device to remove. * @returns {boolean} True if the device was removed, false otherwise. * @throws {Error} If the device does not have a unique ID. */ remove(device: MatterbridgeEndpoint): boolean; /** * Clears all devices from the manager. */ clear(): void; /** * Gets an array of all devices. * * @returns {MatterbridgeEndpoint[]} An array of all devices. */ array(): MatterbridgeEndpoint[]; /** * Iterates over all devices. * * @returns {IterableIterator<MatterbridgeEndpoint>} An iterator for the devices. */ [Symbol.iterator](): MapIterator<MatterbridgeEndpoint>; /** * Asynchronously iterates over each device and calls the provided callback function. * * @param {Function} callback - The callback function to call with each device. * @returns {Promise<void>} A promise that resolves when all callbacks have been called. */ forEach(callback: (device: MatterbridgeEndpoint) => Promise<void>): Promise<void>; /** * Sets the log level. * * @param {LogLevel} logLevel - The log level to set. */ set logLevel(logLevel: LogLevel); } //# sourceMappingURL=deviceManager.d.ts.map