declare module 'meross-iot' { import { EventEmitter } from 'events'; export type Logger = (message: string, ...args: any[]) => void; export enum TransportMode { MQTT_ONLY = 0, LAN_HTTP_FIRST = 1, LAN_HTTP_FIRST_ONLY_GET = 2 } export const OnlineStatus: { NOT_ONLINE: 0; ONLINE: 1; OFFLINE: 2; UNKNOWN: -1; UPGRADING: 3; }; export enum ThermostatMode { HEAT = 0, COOL = 1, ECONOMY = 2, AUTO = 3, MANUAL = 4 } export enum LightMode { MODE_RGB = 1, MODE_TEMPERATURE = 2, MODE_LUMINANCE = 4 } export enum DiffuserLightMode { ROTATING_COLORS = 0, FIXED_RGB = 1, FIXED_LUMINANCE = 2 } export enum DiffuserSprayMode { LIGHT = 0, STRONG = 1, OFF = 2 } export enum SprayMode { OFF = 0, CONTINUOUS = 1, INTERMITTENT = 2 } export const DNDMode: { DND_DISABLED: 0; DND_ENABLED: 1; }; export enum SmokeAlarmStatus { NORMAL = 23, MUTE_TEMPERATURE_ALARM = 26, MUTE_SMOKE_ALARM = 27, INTERCONNECTION_STATUS = 170 } export enum TimerType { SINGLE_POINT_WEEKLY_CYCLE = 1, SINGLE_POINT_SINGLE_SHOT = 2, CONTINUOUS_WEEKLY_CYCLE = 3, CONTINUOUS_SINGLE_SHOT = 4, AUTO_OFF = 1, COUNTDOWN = 2 } export enum TriggerType { SINGLE_POINT_WEEKLY_CYCLE = 1, SINGLE_POINT_SINGLE_SHOT = 2, CONTINUOUS_WEEKLY_CYCLE = 3, CONTINUOUS_SINGLE_SHOT = 4 } export class MerossError extends Error { readonly code: string; readonly errorCode: number | null; readonly isOperational: boolean; readonly cause: Error | null; toJSON(): Record; } export class MerossAuthError extends MerossError {} export class MerossDeviceError extends MerossError {} export class MerossApiError extends MerossError {} export class MerossNetworkError extends MerossError {} export interface TokenData { token: string; key: string; userId: string; userEmail?: string; domain: string; mqttDomain: string; issuedOn?: string; } export interface DeviceDefinition { uuid: string; onlineStatus: number; devName: string; deviceType: string; domain: string; channels: Array<{ channel?: number; [key: string]: any }>; [key: string]: any; } export interface SubdeviceInfo { hubUuid: string; hubName: string; hubDeviceType: string; subdeviceId: string; subdeviceType: string; subdeviceName: string; [key: string]: any; } export interface ToggleFeature { set(options: { on: boolean; channel?: number }): Promise; get(options?: { channel?: number }): Promise; isOn(options?: { channel?: number }): boolean | undefined; getAll(): Map; } export interface TimerFeature { get(options?: { channel?: number; timerId?: string }): Promise; getAll(): Promise; count(): Promise; invalidateCache(options?: { channel?: number }): void; set(options?: any): Promise; delete(options: { timerId: string; channel?: number }): Promise; findTimerByAlias(options: { alias: string; channel?: number }): Promise; deleteTimerByAlias(options: { alias: string; channel?: number }): Promise; enableTimerByAlias(options: { alias: string; channel?: number }): Promise; disableTimerByAlias(options: { alias: string; channel?: number }): Promise; deleteAllTimers(options?: { channel?: number }): Promise; timeToMinutes(time: string | Date | number): number; minutesToTime(minutes: number): string; daysToWeekMask(days: Array, repeat?: boolean): number; createTimer(options?: Record): Record; } export interface TriggerFeature { get(options?: { channel?: number }): Promise; getAll(): Promise; count(): Promise; invalidateCache(options?: { channel?: number }): void; set(options?: any): Promise; delete(options: { triggerId: string; channel?: number }): Promise; findTriggerByAlias(options: { alias: string; channel?: number }): Promise; deleteTriggerByAlias(options: { alias: string; channel?: number }): Promise; enableTriggerByAlias(options: { alias: string; channel?: number }): Promise; disableTriggerByAlias(options: { alias: string; channel?: number }): Promise; deleteAllTriggers(options?: { channel?: number }): Promise; durationToSeconds(duration: string | number): number; secondsToDuration(seconds: number): string; createTrigger(options?: Record): Record; } export interface LightFeature { set(options?: { channel?: number; on?: boolean; rgb?: number[] | number | { r: number; g: number; b: number }; luminance?: number; temperature?: number; gradual?: boolean | number }): Promise; get(options?: { channel?: number }): Promise; isOn(options?: { channel?: number }): boolean | undefined; getRgbColor(options?: { channel?: number }): number[] | undefined; getBrightness(options?: { channel?: number }): number | undefined; getTemperature(options?: { channel?: number }): number | undefined; supportsRgb(options?: { channel?: number }): boolean; supportsLuminance(options?: { channel?: number }): boolean; supportsTemperature(options?: { channel?: number }): boolean; } export interface ThermostatFeature { set(options?: Record): Promise; get(options?: { channel?: number }): Promise; getSchedule(options?: { channel?: number }): Promise; getTimer(options?: { channel?: number }): Promise; } export interface RollerShutterFeature { set(options: { channel?: number; position: number }): Promise; get(options?: { channel?: number }): Promise; open(options?: { channel?: number }): Promise; close(options?: { channel?: number }): Promise; stop(options?: { channel?: number }): Promise; getPosition(options?: Record): Promise; getConfig(options?: Record): Promise; setConfig(options: { config: any | any[] }): Promise; } export interface GarageFeature { set(options: { channel?: number; open: boolean }): Promise; get(options?: { channel?: number }): Promise; isOpen(options?: { channel?: number }): boolean | undefined; isClosed(options?: { channel?: number }): boolean | undefined; open(options?: { channel?: number }): Promise; close(options?: { channel?: number }): Promise; toggle(options?: { channel?: number }): Promise; getConfig(options?: Record): Promise; setConfig(options?: Record): Promise; } export interface ElectricityFeature { get(options?: { channel?: number }): Promise; getRaw(options?: { channel?: number }): Promise; } export interface ConsumptionFeature { get(options?: { channel?: number }): Promise; getConfig(): Promise; } export interface SprayFeature { set(options: { channel?: number; mode: number }): Promise; get(options?: { channel?: number }): Promise; getMode(options?: { channel?: number }): number | null; } export interface DiffuserFeature { set(options?: Record): Promise; get(options?: { channel?: number; type?: 'light' | 'spray' }): Promise; getLight(options?: { channel?: number }): Promise; getSpray(options?: { channel?: number }): Promise; getSensor(options?: Record): Promise; setSensor(options?: Record): Promise; } export interface DeviceCapabilities { channels?: { ids: number[]; count: number; }; [key: string]: any; } export interface PresenceFeature { get(options?: { channel?: number }): Promise; getConfig(options?: { channel?: number }): Promise; setConfig(options?: Record): Promise; } export interface AlarmFeature { get(options?: { channel?: number }): Promise; getLastEvents(): any[]; } export interface RuntimeFeature { get(): Promise; getCached(): any; } export interface ScreenFeature { set(options?: Record): Promise; get(options?: { channel?: number }): Promise; } export interface DNDFeature { set(options?: { mode?: number }): Promise; get(options?: Record): Promise; } export interface ChildLockFeature { set(options?: { channel?: number; lock?: number | boolean }): Promise; get(options?: { channel?: number }): Promise; } export interface ConfigFeature { get(options?: Record): Promise; set(options?: Record): Promise; } export interface TempUnitFeature { set(options?: { channel?: number; unit?: number }): Promise; get(options?: { channel?: number }): Promise; } export interface SmokeConfigFeature { get(options?: { channel?: number }): Promise; set(options?: { channel?: number; status: number }): Promise; } export interface SensorHistoryFeature { get(options?: { channel?: number }): Promise; } export interface SystemFeature { getAllData(): Promise; getDebug(): Promise; getAbilities(): Promise; getEncryptSuite(): Promise; getEncryptECDHE(): Promise; getOnlineStatus(): Promise; getConfigWifiList(): Promise; getConfigTrace(): Promise; getHardware(): Promise; getFirmware(): Promise; getTime(): Promise; getPosition(): Promise; getFactory(): Promise; getLedMode(): Promise; setLedMode(options: { mode: number }): Promise; getMcuFirmware(): Promise; } export class MerossDevice extends EventEmitter { readonly uuid: string; readonly name: string; readonly deviceType: string; readonly onlineStatus: number; readonly deviceConnected: boolean; readonly capabilities: DeviceCapabilities | null; getChannelIds(): number[]; readonly toggle?: ToggleFeature; readonly light?: LightFeature; readonly thermostat?: ThermostatFeature; readonly rollerShutter?: RollerShutterFeature; readonly garage?: GarageFeature; readonly electricity?: ElectricityFeature; readonly consumption?: ConsumptionFeature; readonly spray?: SprayFeature; readonly diffuser?: DiffuserFeature; readonly presence?: PresenceFeature; readonly alarm?: AlarmFeature; readonly runtime?: RuntimeFeature; readonly screen?: ScreenFeature; readonly dnd?: DNDFeature; readonly childLock?: ChildLockFeature; readonly config?: ConfigFeature; readonly tempUnit?: TempUnitFeature; readonly smokeConfig?: SmokeConfigFeature; readonly sensorHistory?: SensorHistoryFeature; readonly system?: SystemFeature; readonly timer?: TimerFeature; readonly trigger?: TriggerFeature; readonly [key: string]: any; } export class MerossSubDevice extends MerossDevice {} export class MerossHubDevice extends MerossDevice { getSubdevices(): MerossSubDevice[]; } export class HubTempHumSensor extends MerossSubDevice {} export class HubThermostatValve extends MerossSubDevice {} export class HubWaterLeakSensor extends MerossSubDevice {} export class HubSmokeDetector extends MerossSubDevice {} export class ManagerDevices { get(identifier: string | { hubUuid: string; id: string }): MerossDevice | MerossHubDevice | MerossSubDevice | null; list(): Array; find(filters?: Record): Array; discover(options?: { deviceTypes?: string[]; onlineOnly?: boolean; excludeHubs?: boolean }): Promise; discoverSubdevices(options?: { hubUuids?: string[]; subdeviceType?: string; onlineOnly?: boolean }): Promise; initialize(options?: { uuids?: string[] }): Promise; initializeDevice(identifier: string | { hubUuid: string; id: string }): Promise; remove(identifier: string | { hubUuid: string; id: string }): Promise; } export interface ManagerSubscription extends EventEmitter { subscribe(device: MerossDevice, config?: Record): void; unsubscribe(deviceUuid: string): void; subscribeToDeviceList(): void; unsubscribeFromDeviceList(): void; destroy(): void; } /** HTTP/MQTT diagnostics counters; enable only when needed to limit overhead. */ export interface ManagerStatistics { enable(maxSamples?: number): void; disable(): void; isEnabled(): boolean; getMqttStats(timeWindowMs?: number): any | null; getHttpStats(timeWindowMs?: number): any | null; getDelayedMqttStats(timeWindowMs?: number): any | null; getDroppedMqttStats(timeWindowMs?: number): any | null; } /** Public transport preferences on {@link Meross}. */ export interface ManagerTransport { defaultMode: number; readonly errorBudgetMaxErrors: number; readonly errorBudgetTimeWindow: number; getBudget(deviceUuid: string): number; resetBudget(deviceUuid: string): void; isOutOfBudget(deviceUuid: string): boolean; } export interface ManagerAuth { readonly token: string | null; readonly key: string | null; readonly userId: string | null; readonly userEmail: string | null; readonly httpDomain: string | null; readonly authenticated: boolean; readonly mqttDomain: string; getTokenData(): TokenData | null; logout(): Promise; } export interface ManagerMqttConnection { client?: { connected?: boolean; reconnecting?: boolean; options?: Record }; deviceList?: string[]; [key: string]: any; } /** MQTT broker clients keyed by domain. */ export interface ManagerMqtt { readonly connections: Record; readonly clientResponseTopic: string | null; readonly mqttDomain: string; hasConnection(domain: string): boolean; getConnection(domain: string): ManagerMqttConnection | null; disconnectAll(force?: boolean): void; } export class Meross extends EventEmitter { /** Same enum as the named {@link TransportMode} export (attached for `Meross.TransportMode` usage). */ static TransportMode: typeof TransportMode; static authenticate(options: { email?: string; password?: string; mfaCode?: string; token?: string; key?: string; userId?: string; domain?: string; mqttDomain?: string; logger?: Logger; }): Promise; static connect(options: { email?: string; password?: string; mfaCode?: string; token?: string; key?: string; userId?: string; domain?: string; mqttDomain?: string; logger?: Logger; }): Promise; /** Prefer {@link Meross.authenticate} or {@link Meross.connect}; the HTTP client is not part of the public API. */ constructor(options: { httpClient: object }); readonly auth: ManagerAuth; readonly devices: ManagerDevices; readonly mqtt: ManagerMqtt; readonly subscription: ManagerSubscription; readonly transport: ManagerTransport; readonly statistics: ManagerStatistics; readonly options: { logger?: Logger | null; [key: string]: any }; readonly authenticated: boolean; readonly token: string | null; readonly key: string | null; readonly userId: string | null; readonly userEmail: string | null; readonly httpDomain: string | null; readonly mqttDomain: string; timeout: number; logger: Logger | null; connect(): Promise; login(): Promise; logout(): Promise; disconnectAll(force?: boolean): void; getTokenData(): TokenData | null; } export default Meross; }