node-switchbot
Version:
The node-switchbot is a Node.js module which allows you to control your Switchbot Devices through Bluetooth (BLE).
92 lines • 3.27 kB
TypeScript
import type { onadvertisement, ondiscover, Params } from './device.js';
import { EventEmitter } from 'node:events';
import { SwitchbotDevice } from './device.js';
/**
* SwitchBotBLE class to interact with SwitchBot devices.
*/
export declare class SwitchBotBLE extends EventEmitter {
ready: Promise<void>;
noble: any;
ondiscover?: ondiscover;
onadvertisement?: onadvertisement;
/**
* Constructor
*
* @param {Params} [params] - Optional parameters
*/
constructor(params?: Params);
/**
* Emits a log event with the specified log level and message.
*
* @param level - The severity level of the log (e.g., 'info', 'warn', 'error').
* @param message - The log message to be emitted.
*/
log(level: string, message: string): Promise<void>;
/**
* Initializes the noble object.
*
* @param {Params} [params] - Optional parameters
* @returns {Promise<void>} - Resolves when initialization is complete
*/
private initialize;
/**
* Validates the parameters.
*
* @param {Params} params - The parameters to validate.
* @param {Record<string, unknown>} schema - The schema to validate against.
* @returns {Promise<void>} - Resolves if parameters are valid, otherwise throws an error.
*/
validate(params: Params, schema: Record<string, unknown>): Promise<void>;
/**
* Waits for the noble object to be powered on.
*
* @returns {Promise<void>} - Resolves when the noble object is powered on.
*/
private waitForPowerOn;
/**
* Discovers Switchbot devices.
* @param params The discovery parameters.
* @returns A Promise that resolves with an array of discovered Switchbot devices.
*/
discover(params?: Params): Promise<SwitchbotDevice[]>;
/**
* Creates a device object based on the peripheral, id, and model.
*
* @param {NobleTypes['peripheral']} peripheral - The peripheral object.
* @param {string} id - The device id.
* @param {string} model - The device model.
* @returns {Promise<SwitchbotDevice | null>} - The device object or null.
*/
private createDevice;
/**
* Filters advertising data based on id and model.
*
* @param {Ad} ad - The advertising data.
* @param {string} id - The device id.
* @param {string} model - The device model.
* @returns {Promise<boolean>} - True if the advertising data matches the id and model, false otherwise.
*/
private filterAd;
/**
* Starts scanning for SwitchBot devices.
*
* @param {Params} [params] - Optional parameters.
* @returns {Promise<void>} - Resolves when scanning starts successfully.
*/
startScan(params?: Params): Promise<void>;
/**
* Stops scanning for SwitchBot devices.
*
* @returns {Promise<void>} - Resolves when scanning stops successfully.
*/
stopScan(): Promise<void>;
/**
* Waits for the specified time.
*
* @param {number} msec - The time to wait in milliseconds.
* @returns {Promise<void>} - Resolves after the specified time.
*/
wait(msec: number): Promise<void>;
}
export { SwitchbotDevice };
//# sourceMappingURL=switchbot-ble.d.ts.map