import { Buffer } from 'node:buffer'; import type { IotCertificate } from '../types.js'; export declare function base64ToHex(base64: string): string; export declare function hexToBase64(hex: string): string; export declare function cenToFar(temp: number): number; export declare function farToCen(temp: number): number; export declare function generateCodeFromHexValues(hexValues: (number | number[])[], returnAsHexBuffer?: boolean): string | Buffer; export declare function generateRandomString(length: number): string; export declare function getTwoItemPosition(array: T[], part: number): T; export declare function hasProperty(obj: unknown, prop: string): boolean; export declare function hexToDecimal(hex: string): number; export declare function hexToTwoItems(hex: string): string[]; export declare function nearestHalf(num: number): number; export declare function parseDeviceId(deviceId: string): string; export declare function parseError(err: unknown, hideStack?: string[]): string; export declare function pfxToCertAndKey(pfxPath: string, p12Password: string): IotCertificate; export declare function sleep(ms: number): Promise; export declare function statusToActionCode(statusCode: string): string; /** * Convert rotation speed percentage (0-100) to a discrete speed value. * @param speed - Speed percentage (0-100) * @param maxSpeed - Maximum speed value (e.g., 3, 4, 5, 8, 9) * @param roundingFn - Optional rounding function (default: Math.floor) * @returns Converted speed value (1 to maxSpeed) */ export declare function speedPercentToValue(speed: number, maxSpeed: number, roundingFn?: (n: number) => number): number; /** * Convert a discrete speed value to percentage. * @param value - Speed value (1 to maxSpeed) * @param maxSpeed - Maximum speed value * @returns Speed percentage */ export declare function speedValueToPercent(value: number, maxSpeed: number): number; /** * Command handler type for processCommands utility */ export type CommandHandlerFn = (hexParts: string[], hexString: string) => void; /** * Process device commands with a map of handlers. * Parses base64-encoded commands and dispatches to appropriate handlers. * * @param commands - Array of base64-encoded commands * @param handlers - Map of device function codes to handler functions * @param defaultHandler - Optional handler for unknown commands */ export declare function processCommands(commands: string[], handlers: Record, defaultHandler?: (command: string, hexString: string, deviceFunction: string) => void): void; /** * Generate a night light command code from HSB values. * @param brightness - Brightness value (0-100) * @param hue - Hue value (0-360) * @param saturation - Saturation value (0-100) * @returns Base64-encoded command string */ export declare function generateNightLightCode(brightness: number, hue: number, saturation: number): string; /** * Generate a night light off command code. * @returns Base64-encoded command string */ export declare function generateNightLightOffCode(): string; /** * Create a debounced async guard. * Returns a function that, when called, waits `delayMs` then returns `true` * only if no subsequent call was made during the wait. * * Usage: * private debounceBrightness = createDebouncedGuard(350); * async internalBrightnessUpdate(value: number) { * if (!await this.debounceBrightness()) return; * // ... proceed with update * } */ export declare function createDebouncedGuard(delayMs: number): () => Promise;