meross-iot 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/README.md +65 -67
  3. package/index.d.ts +330 -3502
  4. package/index.js +11 -112
  5. package/lib/{controller/features/alarm-feature.js → abilities/alarm.js} +27 -17
  6. package/lib/{controller/features/child-lock-feature.js → abilities/child-lock.js} +7 -5
  7. package/lib/{controller/features/config-feature.js → abilities/config.js} +8 -6
  8. package/lib/{controller/features/consumption-feature.js → abilities/consumption.js} +14 -18
  9. package/lib/{controller/features/control-feature.js → abilities/control.js} +10 -7
  10. package/lib/abilities/diffuser.js +192 -0
  11. package/lib/{controller/features/digest-timer-feature.js → abilities/digest-timer.js} +6 -5
  12. package/lib/{controller/features/digest-trigger-feature.js → abilities/digest-trigger.js} +6 -5
  13. package/lib/{controller/features/dnd-feature.js → abilities/dnd.js} +10 -11
  14. package/lib/{controller/features/electricity-feature.js → abilities/electricity.js} +20 -24
  15. package/lib/{controller/features/encryption-feature.js → abilities/encryption.js} +7 -8
  16. package/lib/{controller/features/garage-feature.js → abilities/garage.js} +47 -95
  17. package/lib/{controller/features/hub-feature.js → abilities/hub.js} +75 -52
  18. package/lib/{controller/features/light-feature.js → abilities/light.js} +137 -148
  19. package/lib/{controller/features/presence-sensor-feature.js → abilities/presence.js} +147 -91
  20. package/lib/abilities/roller-shutter.js +236 -0
  21. package/lib/{controller/features/runtime-feature.js → abilities/runtime.js} +6 -5
  22. package/lib/{controller/features/screen-feature.js → abilities/screen.js} +7 -5
  23. package/lib/{controller/features/sensor-history-feature.js → abilities/sensor-history.js} +7 -5
  24. package/lib/{controller/features/smoke-config-feature.js → abilities/smoke-config.js} +7 -5
  25. package/lib/abilities/spray.js +122 -0
  26. package/lib/{controller/features/system-feature.js → abilities/system.js} +59 -25
  27. package/lib/{controller/features/temp-unit-feature.js → abilities/temp-unit.js} +9 -7
  28. package/lib/{controller/features/thermostat-feature.js → abilities/thermostat.js} +220 -258
  29. package/lib/{controller/features/timer-feature.js → abilities/timer.js} +137 -24
  30. package/lib/abilities/toggle.js +149 -0
  31. package/lib/{controller/features/trigger-feature.js → abilities/trigger.js} +127 -34
  32. package/lib/{http-api.js → api/client.js} +55 -123
  33. package/lib/{model → api}/constants.js +4 -0
  34. package/lib/{model/http → api}/device.js +12 -12
  35. package/lib/{model/http → api}/error-codes.js +1 -1
  36. package/lib/{model/http → api}/subdevice.js +10 -10
  37. package/lib/{model/channel-info.js → device/channel.js} +4 -0
  38. package/lib/device/device.js +1618 -0
  39. package/lib/{device-factory.js → device/factory.js} +121 -120
  40. package/lib/{controller/hub-device.js → device/hubdevice.js} +17 -44
  41. package/lib/{device-registry.js → device/registry.js} +4 -44
  42. package/lib/{controller → device}/subdevice.js +97 -150
  43. package/lib/dispatcher.js +257 -0
  44. package/lib/exception.js +211 -0
  45. package/lib/meross.js +426 -0
  46. package/lib/{model/push → push}/factory.js +14 -10
  47. package/lib/{model/push → push}/generic.js +24 -1
  48. package/lib/{model/push → push}/index.js +2 -2
  49. package/lib/{model/states → states}/diffuser-light-state.js +1 -1
  50. package/lib/{model/states → states}/index.js +1 -1
  51. package/lib/{model/states → states}/light-state.js +1 -1
  52. package/lib/utilities/cache.js +51 -0
  53. package/lib/utilities/conversion.js +3 -3
  54. package/lib/utilities/heartbeat.js +30 -48
  55. package/lib/utilities/options.js +25 -5
  56. package/lib/utilities/request-queue.js +2 -2
  57. package/lib/utilities/state-ordering.js +57 -0
  58. package/lib/utilities/timer.js +14 -18
  59. package/lib/utilities/trigger.js +15 -17
  60. package/manager/auth.js +157 -0
  61. package/manager/base.js +18 -0
  62. package/{lib/managers → manager}/devices.js +179 -177
  63. package/{lib/managers → manager}/http.js +46 -62
  64. package/{lib/managers → manager}/mqtt.js +153 -112
  65. package/manager/registry.js +26 -0
  66. package/manager/statistics.js +114 -0
  67. package/{lib/managers → manager}/subscription.js +28 -248
  68. package/manager/transport.js +260 -0
  69. package/package.json +4 -2
  70. package/lib/controller/device.js +0 -1491
  71. package/lib/controller/features/diffuser-feature.js +0 -287
  72. package/lib/controller/features/roller-shutter-feature.js +0 -332
  73. package/lib/controller/features/spray-feature.js +0 -181
  74. package/lib/controller/features/toggle-feature.js +0 -188
  75. package/lib/error-budget.js +0 -138
  76. package/lib/manager.js +0 -510
  77. package/lib/managers/statistics.js +0 -158
  78. package/lib/managers/transport.js +0 -217
  79. package/lib/model/exception.js +0 -786
  80. package/lib/model/http/exception.js +0 -204
  81. package/lib/utilities/debug.js +0 -153
  82. /package/lib/{model/enums.js → enums.js} +0 -0
  83. /package/lib/{model/push → push}/alarm.js +0 -0
  84. /package/lib/{model/push → push}/bind.js +0 -0
  85. /package/lib/{model/push → push}/common.js +0 -0
  86. /package/lib/{model/push → push}/diffuser-light.js +0 -0
  87. /package/lib/{model/push → push}/diffuser-spray.js +0 -0
  88. /package/lib/{model/push → push}/hub-battery.js +0 -0
  89. /package/lib/{model/push → push}/hub-mts100-all.js +0 -0
  90. /package/lib/{model/push → push}/hub-mts100-mode.js +0 -0
  91. /package/lib/{model/push → push}/hub-mts100-temperature.js +0 -0
  92. /package/lib/{model/push → push}/hub-online.js +0 -0
  93. /package/lib/{model/push → push}/hub-sensor-alert.js +0 -0
  94. /package/lib/{model/push → push}/hub-sensor-all.js +0 -0
  95. /package/lib/{model/push → push}/hub-sensor-smoke.js +0 -0
  96. /package/lib/{model/push → push}/hub-sensor-temphum.js +0 -0
  97. /package/lib/{model/push → push}/hub-subdevicelist.js +0 -0
  98. /package/lib/{model/push → push}/hub-togglex.js +0 -0
  99. /package/lib/{model/push → push}/online.js +0 -0
  100. /package/lib/{model/push → push}/presence-study.js +0 -0
  101. /package/lib/{model/push → push}/sensor-latestx.js +0 -0
  102. /package/lib/{model/push → push}/timerx.js +0 -0
  103. /package/lib/{model/push → push}/togglex.js +0 -0
  104. /package/lib/{model/push → push}/triggerx.js +0 -0
  105. /package/lib/{model/push → push}/unbind.js +0 -0
  106. /package/lib/{model/push → push}/water-leak.js +0 -0
  107. /package/lib/{model/states → states}/diffuser-spray-state.js +0 -0
  108. /package/lib/{model/states → states}/garage-door-state.js +0 -0
  109. /package/lib/{model/states → states}/presence-sensor-state.js +0 -0
  110. /package/lib/{model/states → states}/roller-shutter-state.js +0 -0
  111. /package/lib/{model/states → states}/spray-state.js +0 -0
  112. /package/lib/{model/states → states}/thermostat-state.js +0 -0
  113. /package/lib/{model/states → states}/timer-state.js +0 -0
  114. /package/lib/{model/states → states}/toggle-state.js +0 -0
  115. /package/lib/{model/states → states}/trigger-state.js +0 -0
package/index.d.ts CHANGED
@@ -1,588 +1,11 @@
1
1
  declare module 'meross-iot' {
2
- import { EventEmitter } from 'events'
2
+ import { EventEmitter } from 'events';
3
3
 
4
- /**
5
- * Logger function type for debug output.
6
- *
7
- * @param message - The log message
8
- * @param args - Additional arguments to log
9
- *
10
- * @example
11
- * ```typescript
12
- * const logger: Logger = (msg, ...args) => console.log(`[Meross] ${msg}`, ...args);
13
- * ```
14
- */
15
- export type Logger = (message: string, ...args: any[]) => void
4
+ export type Logger = (message: string, ...args: any[]) => void;
16
5
 
17
- /**
18
- * Channel data structure from device definitions.
19
- *
20
- * Represents channel information parsed from device initialization data.
21
- * Devices can have multiple channels (e.g., master channel at index 0, sub-channels at 1-n).
22
- */
23
- export interface ChannelData {
24
- /** Channel index. 0 is master channel, 1-n are sub-channels. */
25
- channel?: number
26
- deviceName?: string
27
- /** Non-zero if this is the master channel. */
28
- master?: number
29
- [key: string]: any
30
- }
31
-
32
- /**
33
- * Device definition structure from the Meross API.
34
- *
35
- * Contains all device metadata returned from the HTTP API when fetching device lists.
36
- * This is the raw device information used to initialize MerossDevice instances.
37
- *
38
- * @example
39
- * ```typescript
40
- * const devices = await httpClient.getDevices();
41
- * const deviceDef = devices[0]; // DeviceDefinition
42
- * ```
43
- */
44
- export interface DeviceDefinition {
45
- uuid: string
46
- /** Online status: 0=connecting, 1=online, 2=offline, -1=unknown, 3=upgrading */
47
- onlineStatus: number
48
- devName: string
49
- devIconId: string
50
- /** Unix timestamp when device was bound to account */
51
- bindTime: number
52
- deviceType: string
53
- subType: string
54
- channels: ChannelData[]
55
- region: string
56
- fmwareVersion: string
57
- hdwareVersion: string
58
- userDevIcon: string
59
- iconType: number
60
- skillNumber: string
61
- domain: string
62
- reservedDomain: string
63
- }
64
-
65
- /**
66
- * Subdevice information structure with hub context.
67
- *
68
- * Contains subdevice metadata returned from discoverSubdevices() with additional
69
- * hub context information for device selection UIs.
70
- *
71
- * @example
72
- * ```typescript
73
- * const smokeAlarms = await manager.devices.discoverSubdevices({ subdeviceType: 'ma151' });
74
- * const alarm = smokeAlarms[0]; // SubdeviceInfo
75
- * console.log(`Smoke alarm: ${alarm.subdeviceName} on hub ${alarm.hubName}`);
76
- * ```
77
- */
78
- export interface SubdeviceInfo {
79
- hubUuid: string
80
- hubName: string
81
- hubDeviceType: string
82
- subdeviceId: string
83
- subdeviceType: string
84
- subdeviceName: string
85
- subdeviceIconId?: string
86
- subdeviceSubType?: string
87
- subdeviceVendor?: string
88
- trueId?: string
89
- /** Unix timestamp when subdevice was bound */
90
- bindTime?: number
91
- iconType?: number
92
- /** Additional properties from HTTP API */
93
- [key: string]: any
94
- }
95
-
96
- /**
97
- * Normalized device capabilities map.
98
- *
99
- * Provides a user-friendly capability map that abstracts away Meross namespace strings,
100
- * making it easy for integrators to discover device features without dealing with protocol details.
101
- * This map is derived from device abilities and channel information.
102
- *
103
- * @example
104
- * ```typescript
105
- * if (device.capabilities?.toggle?.supported) {
106
- * console.log(`Device has ${device.capabilities.toggle.channels.length} toggle channels`);
107
- * }
108
- *
109
- * if (device.capabilities?.light?.rgb) {
110
- * await device.light.set({ channel: 0, rgb: [255, 0, 0] });
111
- * }
112
- * ```
113
- */
114
- export interface DeviceCapabilities {
115
- /** Channel information */
116
- channels: {
117
- /** Array of channel IDs (indices) */
118
- ids: number[]
119
- /** Total number of channels */
120
- count: number
121
- }
122
- /** Toggle (on/off) control capability */
123
- toggle?: {
124
- supported: true
125
- channels: number[]
126
- multiChannel: boolean
127
- }
128
- /** Light control capability */
129
- light?: {
130
- supported: true
131
- channels: number[]
132
- rgb: boolean
133
- luminance: boolean
134
- temperature: boolean
135
- }
136
- /** Thermostat control capability */
137
- thermostat?: {
138
- supported: true
139
- channels: number[]
140
- modeB: boolean
141
- schedule?: boolean
142
- windowOpened?: boolean
143
- sensor?: boolean
144
- summerMode?: boolean
145
- holdAction?: boolean
146
- calibration?: boolean
147
- deadZone?: boolean
148
- frost?: boolean
149
- overheat?: boolean
150
- }
151
- /** Roller shutter control capability */
152
- rollerShutter?: {
153
- supported: true
154
- channels: number[]
155
- }
156
- /** Garage door control capability */
157
- garage?: {
158
- supported: true
159
- channels: number[]
160
- }
161
- /** Diffuser control capability */
162
- diffuser?: {
163
- supported: true
164
- channels: number[]
165
- light: boolean
166
- spray: boolean
167
- }
168
- /** Spray control capability */
169
- spray?: {
170
- supported: true
171
- channels: number[]
172
- }
173
- /** Power consumption monitoring capability */
174
- consumption?: {
175
- supported: true
176
- channels: number[]
177
- }
178
- /** Real-time electricity monitoring capability */
179
- electricity?: {
180
- supported: true
181
- channels: number[]
182
- }
183
- /** Timer capability */
184
- timer?: {
185
- supported: true
186
- channels: number[]
187
- }
188
- /** Trigger capability */
189
- trigger?: {
190
- supported: true
191
- channels: number[]
192
- }
193
- /** Presence sensor capability */
194
- presence?: {
195
- supported: true
196
- channels: number[]
197
- presenceEvents: boolean
198
- lux: boolean
199
- distance: boolean
200
- }
201
- /** Sensor capability (for hub sensors) */
202
- sensor?: {
203
- supported: true
204
- channels: number[]
205
- temperature?: boolean
206
- humidity?: boolean
207
- lux?: boolean
208
- waterLeak?: boolean
209
- smoke?: boolean
210
- }
211
- /** Alarm capability */
212
- alarm?: {
213
- supported: true
214
- channels: number[]
215
- }
216
- /** Child lock capability */
217
- childLock?: {
218
- supported: true
219
- channels: number[]
220
- }
221
- /** Screen control capability */
222
- screen?: {
223
- supported: true
224
- channels: number[]
225
- }
226
- /** Runtime statistics capability */
227
- runtime?: {
228
- supported: true
229
- channels: number[]
230
- }
231
- /** Configuration capability */
232
- config?: {
233
- supported: true
234
- channels: number[]
235
- }
236
- /** Do Not Disturb mode capability */
237
- dnd?: {
238
- supported: true
239
- channels: number[]
240
- }
241
- /** Temperature unit setting capability */
242
- tempUnit?: {
243
- supported: true
244
- }
245
- /** Smoke detector configuration capability */
246
- smokeConfig?: {
247
- supported: true
248
- channels: number[]
249
- }
250
- /** Sensor history capability */
251
- sensorHistory?: {
252
- supported: true
253
- channels: number[]
254
- }
255
- /** Digest timer capability */
256
- digestTimer?: {
257
- supported: true
258
- }
259
- /** Digest trigger capability */
260
- digestTrigger?: {
261
- supported: true
262
- }
263
- /** Advanced control capability (batch commands, firmware upgrades) */
264
- control?: {
265
- supported: true
266
- multiple: boolean
267
- upgrade: boolean
268
- }
269
- /** Hub device capability */
270
- hub?: {
271
- supported: true
272
- subDeviceList: boolean
273
- battery: boolean
274
- }
275
- }
276
-
277
- /**
278
- * Channel metadata for a device.
279
- *
280
- * Encapsulates channel information parsed from device initialization data.
281
- * Devices can have multiple channels (e.g., master channel at index 0, sub-channels at 1-n),
282
- * each representing a separate control point or feature.
283
- *
284
- * @example
285
- * ```typescript
286
- * const channels = device.channels;
287
- * channels.forEach(channel => {
288
- * console.log(`Channel ${channel.index}: ${channel.name} (USB: ${channel.isUsb})`);
289
- * });
290
- * ```
291
- */
292
- export class ChannelInfo {
293
- /** Channel index. 0 is master channel, 1-n are sub-channels. */
294
- readonly index: number
295
- readonly name: string | null
296
- readonly isUsb: boolean
297
- readonly isMasterChannel: boolean
298
-
299
- /**
300
- * Creates a new ChannelInfo instance.
301
- *
302
- * @param index - Channel index (0 for master channel, 1-n for sub-channels)
303
- * @param name - Channel name (defaults to 'Main channel' for index 0)
304
- * @param channelType - Channel type (e.g., 'USB')
305
- * @param isMasterChannel - Whether this is the master channel
306
- */
307
- constructor(index: number, name?: string | null, channelType?: string | null, isMasterChannel?: boolean)
308
- }
309
-
310
- /**
311
- * HTTP API device information.
312
- *
313
- * Represents device information retrieved from the Meross HTTP API.
314
- * This class normalizes device data from the API and provides convenient accessors.
315
- * Instances are created using the static `fromDict` factory method.
316
- *
317
- * @example
318
- * ```typescript
319
- * const devices = await httpClient.getDevices();
320
- * const deviceInfo = HttpDeviceInfo.fromDict(devices[0]);
321
- * const mqttHost = deviceInfo.getMqttHost();
322
- * ```
323
- */
324
- export class HttpDeviceInfo {
325
- readonly uuid: string
326
- readonly devName: string
327
- readonly deviceType: string
328
- readonly channels: ChannelData[]
329
- readonly fmwareVersion: string
330
- readonly hdwareVersion: string
331
- readonly domain: string
332
- readonly reservedDomain: string | null
333
- readonly subType: string | null
334
- readonly bindTime: Date | null
335
- readonly skillNumber: string | null
336
- readonly userDevIcon: string | null
337
- readonly iconType: number | null
338
- readonly region: string | null
339
- /** Device icon ID or null */
340
- readonly devIconId: string | null
341
- /** Online status (0=connecting, 1=online, 2=offline, -1=unknown, 3=upgrading) */
342
- readonly onlineStatus: number
343
-
344
- /**
345
- * Creates an HttpDeviceInfo instance from a dictionary object.
346
- *
347
- * Accepts camelCase API response format directly (no normalization needed).
348
- * This is the only way to create instances.
349
- *
350
- * @param jsonDict - Dictionary object from the API response with camelCase keys
351
- * @returns New HttpDeviceInfo instance
352
- */
353
- static fromDict(jsonDict: { [key: string]: any }): HttpDeviceInfo
354
-
355
- /** @private */
356
- private constructor()
357
-
358
- /**
359
- * Converts the instance to a plain object dictionary with camelCase keys.
360
- *
361
- * @returns Plain object with camelCase keys
362
- */
363
- toDict(): {
364
- uuid: string
365
- devName: string
366
- deviceType: string
367
- channels: ChannelData[]
368
- fmwareVersion: string
369
- hdwareVersion: string
370
- domain: string
371
- reservedDomain: string | null
372
- subType: string | null
373
- bindTime: Date | null
374
- skillNumber: string | null
375
- userDevIcon: string | null
376
- iconType: number | null
377
- region: string | null
378
- devIconId: string | null
379
- onlineStatus: number
380
- }
381
-
382
- /**
383
- * Gets the MQTT host for this device.
384
- *
385
- * @returns MQTT broker hostname
386
- */
387
- getMqttHost(): string
388
-
389
- /**
390
- * Gets the MQTT port for this device.
391
- *
392
- * @returns MQTT broker port number
393
- */
394
- getMqttPort(): number
395
- }
396
-
397
- export class HttpSubdeviceInfo {
398
- readonly subDeviceId: string | null
399
- readonly trueId: string | null
400
- readonly subDeviceType: string | null
401
- readonly subDeviceVendor: string | null
402
- readonly subDeviceName: string | null
403
- readonly subDeviceIconId: string | null
404
- /**
405
- * Creates an HttpSubdeviceInfo instance from a dictionary object.
406
- * Accepts camelCase API response format. Generic keys ('id', 'type', 'name') are supported
407
- * as fallbacks for API variations and are normalized to camelCase properties.
408
- * This is the only way to create instances.
409
- */
410
- static fromDict(jsonDict: { [key: string]: any }): HttpSubdeviceInfo
411
- private constructor()
412
- /**
413
- * Converts the instance to a plain object dictionary with camelCase keys.
414
- */
415
- toDict(): {
416
- subDeviceId: string | null
417
- trueId: string | null
418
- subDeviceType: string | null
419
- subDeviceVendor: string | null
420
- subDeviceName: string | null
421
- subDeviceIconId: string | null
422
- }
423
- toString(): string
424
- toJSON(): string
425
- }
426
-
427
- export class HardwareInfo {
428
- readonly version: string | null
429
- readonly uuid: string | null
430
- readonly type: string | null
431
- readonly subType: string | null
432
- readonly macAddress: string | null
433
- readonly chipType: string | null
434
- /**
435
- * Creates a HardwareInfo instance from a dictionary object.
436
- * Accepts camelCase API response format directly (no normalization needed).
437
- * This is the only way to create instances.
438
- */
439
- static fromDict(jsonDict: { [key: string]: any }): HardwareInfo | null
440
- private constructor()
441
- /**
442
- * Converts the instance to a plain object dictionary with camelCase keys.
443
- */
444
- toDict(): {
445
- version: string | null
446
- uuid: string | null
447
- type: string | null
448
- subType: string | null
449
- macAddress: string | null
450
- chipType: string | null
451
- }
452
- }
453
-
454
- export class FirmwareInfo {
455
- readonly wifiMac: string | null
456
- readonly version: string | null
457
- readonly userId: string | null
458
- readonly server: string | null
459
- readonly port: number | null
460
- readonly innerIp: string | null
461
- readonly compileTime: string | null
462
- /**
463
- * Creates a FirmwareInfo instance from a dictionary object.
464
- * Accepts camelCase API response format directly (no normalization needed).
465
- * This is the only way to create instances.
466
- */
467
- static fromDict(jsonDict: { [key: string]: any }): FirmwareInfo | null
468
- private constructor()
469
- /**
470
- * Converts the instance to a plain object dictionary with camelCase keys.
471
- */
472
- toDict(): {
473
- wifiMac: string | null
474
- version: string | null
475
- userId: string | null
476
- server: string | null
477
- port: number | null
478
- innerIp: string | null
479
- compileTime: string | null
480
- }
481
- }
482
-
483
- export class TimeInfo {
484
- readonly timezone: string | null
485
- readonly timestamp: number | null
486
- readonly timeRule: string | null
487
- /**
488
- * Creates a TimeInfo instance from a dictionary object.
489
- * Accepts camelCase API response format directly (no normalization needed).
490
- * This is the only way to create instances.
491
- */
492
- static fromDict(jsonDict: { [key: string]: any }): TimeInfo | null
493
- private constructor()
494
- /**
495
- * Converts the instance to a plain object dictionary with camelCase keys.
496
- */
497
- toDict(): {
498
- timezone: string | null
499
- timestamp: number | null
500
- timeRule: string | null
501
- }
502
- }
503
-
504
- export interface GetControlPowerConsumptionXResponse {
505
- consumptionx: {
506
- date: string
507
- /**
508
- * timestamp, utc.
509
- * has to be multiplied by 1000 to use on new Date(time)
510
- */
511
- time: number
512
- value: number
513
- }[]
514
- }
515
- export interface GetControlElectricityResponse {
516
- electricity: {
517
- channel: number
518
- /**
519
- * current in decimilliAmp. Has to get divided by 10000 to get Amp(s)
520
- */
521
- current: number
522
- /**
523
- * voltage in deciVolt. Has to get divided by 10 to get Volt(s)
524
- */
525
- voltage: number
526
- /**
527
- * power in milliWatt. Has to get divided by 1000 to get Watt(s)
528
- */
529
- power: number
530
- config: {
531
- voltageRatio: number
532
- electricityRatio: number
533
- }
534
- }
535
- }
536
-
537
- /**
538
- * Authentication token data.
539
- *
540
- * Contains all information needed to authenticate with the Meross API.
541
- * Can be saved and reused with MerossHttpClient.fromCredentials().
542
- *
543
- * @example
544
- * ```typescript
545
- * const tokenData = manager.getTokenData();
546
- * // Save tokenData for later use
547
- * const httpClient = MerossHttpClient.fromCredentials({
548
- * token: tokenData.token,
549
- * key: tokenData.key,
550
- * userId: tokenData.userId,
551
- * domain: tokenData.domain,
552
- * mqttDomain: tokenData.mqttDomain
553
- * });
554
- * ```
555
- */
556
- export interface TokenData {
557
- /** Authentication token */
558
- token: string;
559
- /** Encryption key */
560
- key: string;
561
- /** User ID */
562
- userId: string;
563
- /** Hash value */
564
- hash: string;
565
- /** API domain */
566
- domain: string;
567
- /** MQTT domain */
568
- mqttDomain: string;
569
- /** Token issue timestamp (optional) */
570
- issuedOn?: string;
571
- }
572
-
573
- /**
574
- * Transport mode for device communication.
575
- *
576
- * Determines how the library communicates with Meross devices. Each mode
577
- * uses different protocols and network paths, affecting latency, reliability,
578
- * and whether remote access is required.
579
- */
580
6
  export enum TransportMode {
581
- /** MQTT-only communication through Meross cloud broker */
582
7
  MQTT_ONLY = 0,
583
- /** LAN HTTP with MQTT fallback - attempts direct HTTP first, falls back to MQTT */
584
8
  LAN_HTTP_FIRST = 1,
585
- /** LAN HTTP for reads only, MQTT for writes - uses LAN for GET requests, MQTT for SET */
586
9
  LAN_HTTP_FIRST_ONLY_GET = 2
587
10
  }
588
11
 
@@ -592,95 +15,7 @@ declare module 'meross-iot' {
592
15
  OFFLINE: 2;
593
16
  UNKNOWN: -1;
594
17
  UPGRADING: 3;
595
- }
596
-
597
- export const DNDMode: {
598
- DND_DISABLED: 0;
599
- DND_ENABLED: 1;
600
- }
601
-
602
- export const PresenceState: {
603
- ABSENCE: 1;
604
- PRESENCE: 2;
605
- }
606
-
607
- export const SensitivityLevel: {
608
- RESPONSIVE: 3;
609
- ANTI_INTERFERENCE: 1;
610
- BALANCE: 2;
611
- }
612
-
613
- export const WorkMode: {
614
- UNKNOWN: 0;
615
- BIOLOGICAL_DETECTION_ONLY: 1;
616
- SECURITY: 2;
617
- }
618
-
619
- /**
620
- * Configuration options for ManagerMeross cloud manager.
621
- *
622
- * @example
623
- * ```typescript
624
- * const httpClient = await MerossHttpClient.fromUserPassword({
625
- * email: 'user@example.com',
626
- * password: 'password'
627
- * });
628
- *
629
- * const manager = new ManagerMeross({
630
- * httpClient,
631
- * transportMode: TransportMode.LAN_HTTP_FIRST,
632
- * logger: console.log
633
- * });
634
- * ```
635
- */
636
- export interface CloudOptions {
637
- /** HTTP client instance (required - use MerossHttpClient.fromUserPassword()) */
638
- httpClient: MerossHttpClient;
639
- /** Logger function for debug output */
640
- logger?: Logger;
641
- /** Transport mode for device communication */
642
- transportMode?: TransportMode;
643
- /** Request timeout in milliseconds */
644
- timeout?: number,
645
- /** Automatically retry on bad domain errors */
646
- autoRetryOnBadDomain?: boolean,
647
- /** Maximum errors allowed per device before skipping LAN HTTP (default: 1) */
648
- maxErrors?: number,
649
- /** Time window in milliseconds for error budget (default: 60000) */
650
- errorBudgetTimeWindow?: number,
651
- /** Enable statistics tracking (default: false) */
652
- enableStats?: boolean,
653
- /** Maximum number of samples to keep in statistics (default: 1000) */
654
- maxStatsSamples?: number,
655
- /** Number of concurrent requests per device (default: 1) */
656
- requestBatchSize?: number,
657
- /** Delay in milliseconds between batches (default: 200) */
658
- requestBatchDelay?: number,
659
- /** Enable/disable request throttling (default: true) */
660
- enableRequestThrottling?: boolean,
661
- /** Subscription manager options for automatic polling and data provisioning */
662
- subscription?: ManagerSubscriptionOptions
663
- }
664
-
665
- export interface LightData {
666
- channel: number;
667
- capacity: number;
668
- gradual: number;
669
- rgb?: number;
670
- temperature?: number;
671
- luminance?: number;
672
- }
673
-
674
- export interface ThermostatModeData {
675
- channel: number;
676
- heatTemp?: number;
677
- coolTemp?: number;
678
- manualTemp?: number;
679
- ecoTemp?: number;
680
- targetTemp?: number;
681
- mode?: number;
682
- onoff?: number;
683
- }
18
+ };
684
19
 
685
20
  export enum ThermostatMode {
686
21
  HEAT = 0,
@@ -690,119 +25,12 @@ declare module 'meross-iot' {
690
25
  MANUAL = 4
691
26
  }
692
27
 
693
- export enum ThermostatWorkingMode {
694
- HEAT = 1,
695
- COOL = 2
696
- }
697
-
698
- export enum ThermostatModeBState {
699
- HEATING_COOLING = 1,
700
- NOT_HEATING_COOLING = 2
701
- }
702
-
703
- /**
704
- * State update data for ThermostatState
705
- */
706
- export interface ThermostatStateUpdate {
707
- onoff?: number
708
- channel?: number
709
- mode?: number
710
- targetTemp?: number
711
- currentTemp?: number
712
- working?: number
713
- state?: number
714
- warning?: number
715
- min?: number
716
- max?: number
717
- heatTemp?: number
718
- coolTemp?: number
719
- ecoTemp?: number
720
- manualTemp?: number
721
- [key: string]: any
722
- }
723
-
724
- export interface ThermostatState {
725
- readonly isOn?: boolean;
726
- readonly mode?: number;
727
- readonly workingMode?: number;
728
- readonly state?: number;
729
- readonly warning?: boolean;
730
- readonly targetTemperatureCelsius?: number;
731
- readonly currentTemperatureCelsius?: number;
732
- readonly minTemperatureCelsius?: number;
733
- readonly maxTemperatureCelsius?: number;
734
- readonly heatTemperatureCelsius?: number;
735
- readonly coolTemperatureCelsius?: number;
736
- readonly ecoTemperatureCelsius?: number;
737
- readonly manualTemperatureCelsius?: number;
738
- update(state: ThermostatStateUpdate): void;
739
- }
740
-
741
28
  export enum LightMode {
742
29
  MODE_RGB = 1,
743
30
  MODE_TEMPERATURE = 2,
744
31
  MODE_LUMINANCE = 4
745
32
  }
746
33
 
747
- /**
748
- * State update data for LightState
749
- */
750
- export interface LightStateUpdate {
751
- onoff?: number
752
- channel?: number
753
- rgb?: number
754
- luminance?: number
755
- temperature?: number
756
- capacity?: number
757
- [key: string]: any
758
- }
759
-
760
- export interface LightState {
761
- readonly isOn?: boolean;
762
- readonly rgbTuple?: [number, number, number];
763
- readonly rgbInt?: number;
764
- readonly luminance?: number;
765
- readonly temperature?: number;
766
- readonly capacity?: number;
767
- update(state: LightStateUpdate): void;
768
- }
769
-
770
- /**
771
- * Options for setting light color and properties.
772
- *
773
- * Used with MerossDevice.light.set() to control RGB lights.
774
- *
775
- * @example
776
- * ```typescript
777
- * // Set RGB color
778
- * await device.light.set({
779
- * channel: 0,
780
- * rgb: [255, 0, 0], // Red
781
- * luminance: 50,
782
- * on: true
783
- * });
784
- *
785
- * // Set color temperature
786
- * await device.light.set({
787
- * channel: 0,
788
- * temperature: 50,
789
- * luminance: 75
790
- * });
791
- * ```
792
- */
793
- export interface LightColorOptions {
794
- /** Channel number (default: 0) */
795
- channel?: number;
796
- /** Whether to turn the light on */
797
- onoff?: boolean;
798
- /** RGB color - can be array [r,g,b], object {r,g,b}, or integer */
799
- rgb?: [number, number, number] | { r: number; g: number; b: number } | { red: number; green: number; blue: number } | number;
800
- /** Brightness level (1-100) */
801
- luminance?: number;
802
- /** Color temperature (1-100, where 1 is warmest, 100 is coolest) */
803
- temperature?: number;
804
- }
805
-
806
34
  export enum DiffuserLightMode {
807
35
  ROTATING_COLORS = 0,
808
36
  FIXED_RGB = 1,
@@ -821,12 +49,10 @@ declare module 'meross-iot' {
821
49
  INTERMITTENT = 2
822
50
  }
823
51
 
824
- export enum RollerShutterStatus {
825
- UNKNOWN = -1,
826
- IDLE = 0,
827
- OPENING = 1,
828
- CLOSING = 2
829
- }
52
+ export const DNDMode: {
53
+ DND_DISABLED: 0;
54
+ DND_ENABLED: 1;
55
+ };
830
56
 
831
57
  export enum SmokeAlarmStatus {
832
58
  NORMAL = 23,
@@ -851,2797 +77,399 @@ declare module 'meross-iot' {
851
77
  CONTINUOUS_SINGLE_SHOT = 4
852
78
  }
853
79
 
854
- /**
855
- * State update data for DiffuserLightState
856
- */
857
- export interface DiffuserLightStateUpdate {
858
- onoff?: number
859
- channel?: number
860
- mode?: number
861
- rgb?: number
862
- luminance?: number
863
- [key: string]: any
864
- }
865
-
866
- export interface DiffuserLightState {
867
- readonly isOn?: boolean;
868
- readonly mode?: number;
869
- readonly rgbTuple?: [number, number, number];
870
- readonly rgbInt?: number;
871
- readonly luminance?: number;
872
- update(state: DiffuserLightStateUpdate): void;
873
- }
874
-
875
- /**
876
- * State update data for DiffuserSprayState
877
- */
878
- export interface DiffuserSprayStateUpdate {
879
- channel?: number
880
- mode?: number
881
- [key: string]: any
882
- }
883
-
884
- export interface DiffuserSprayState {
885
- readonly mode?: number;
886
- update(state: DiffuserSprayStateUpdate): void;
887
- }
888
-
889
- /**
890
- * State update data for SprayState
891
- */
892
- export interface SprayStateUpdate {
893
- channel?: number
894
- mode?: number
895
- [key: string]: any
896
- }
897
-
898
- export interface SprayState {
899
- readonly mode?: number;
900
- update(state: SprayStateUpdate): void;
901
- }
902
-
903
- /**
904
- * State update data for RollerShutterState
905
- */
906
- export interface RollerShutterStateUpdate {
907
- channel?: number
908
- state?: number
909
- position?: number
910
- [key: string]: any
911
- }
912
-
913
- export interface RollerShutterState {
914
- readonly state?: number;
915
- readonly position?: number;
916
- readonly channel?: number;
917
- update(state: RollerShutterStateUpdate): void;
918
- }
919
-
920
- /**
921
- * State update data for GarageDoorState
922
- */
923
- export interface GarageDoorStateUpdate {
924
- channel?: number
925
- open?: number
926
- [key: string]: any
927
- }
928
-
929
- export interface GarageDoorState {
930
- readonly isOpen?: boolean;
931
- readonly channel?: number;
932
- update(state: GarageDoorStateUpdate): void;
933
- }
934
-
935
- /**
936
- * State update data for TimerState
937
- */
938
- export interface TimerStateUpdate {
939
- id?: string | number
940
- channel?: number
941
- week?: number
942
- time?: number
943
- enable?: number | boolean
944
- alias?: string
945
- type?: number
946
- duration?: number
947
- sunOffset?: number
948
- createTime?: number
949
- extend?: Record<string, any>
950
- [key: string]: any
951
- }
952
-
953
- export interface TimerState {
954
- readonly id?: string | number;
955
- readonly channel?: number;
956
- readonly week?: number;
957
- readonly time?: number;
958
- readonly enable?: boolean;
959
- readonly alias?: string;
960
- readonly type?: number;
961
- readonly duration?: number;
962
- readonly sunOffset?: number;
963
- readonly createTime?: number;
964
- readonly extend?: Record<string, any>;
965
- update(state: TimerStateUpdate): void;
966
- }
967
-
968
- /**
969
- * State update data for TriggerState
970
- */
971
- export interface TriggerStateUpdate {
972
- id?: string | number
973
- channel?: number
974
- alias?: string
975
- enable?: number | boolean
976
- type?: number
977
- createTime?: number
978
- rule?: Record<string, any>
979
- ruleDuration?: number
980
- ruleWeek?: number
981
- [key: string]: any
982
- }
983
-
984
- export interface TriggerState {
985
- readonly id?: string | number;
986
- readonly channel?: number;
987
- readonly alias?: string;
988
- readonly enable?: boolean;
989
- readonly type?: number;
990
- readonly createTime?: number;
991
- readonly rule?: Record<string, any>;
992
- readonly ruleDuration?: number;
993
- readonly ruleWeek?: number;
994
- update(state: TriggerStateUpdate): void;
995
- }
996
-
997
- /**
998
- * State update data for PresenceSensorState
999
- */
1000
- export interface PresenceSensorStateUpdate {
1001
- channel?: number
1002
- presence?: Record<string, any>
1003
- light?: Record<string, any>
1004
- [key: string]: any
1005
- }
1006
-
1007
- export interface PresenceSensorState {
1008
- readonly isPresent?: boolean;
1009
- readonly presenceValue?: number;
1010
- readonly presenceState?: string;
1011
- readonly distanceMeters?: number;
1012
- readonly distanceRaw?: number;
1013
- readonly presenceTimestamp?: Date;
1014
- readonly presenceTimes?: number;
1015
- readonly lightLux?: number;
1016
- readonly lightTimestamp?: Date;
1017
- readonly channel?: number;
1018
- readonly rawPresence?: Record<string, any>;
1019
- readonly rawLight?: Record<string, any>;
1020
- update(state: PresenceSensorStateUpdate): void;
1021
- }
1022
-
1023
- /**
1024
- * State update data for ToggleState
1025
- */
1026
- export interface ToggleStateUpdate {
1027
- channel?: number
1028
- onoff?: number
1029
- lmTime?: number
1030
- entity?: number
1031
- [key: string]: any
1032
- }
1033
-
1034
- export interface ToggleState {
1035
- readonly isOn?: boolean;
1036
- readonly onoff?: number;
1037
- readonly channel?: number;
1038
- readonly lmTime?: number;
1039
- readonly entity?: number;
1040
- update(state: ToggleStateUpdate): void;
1041
- }
1042
-
1043
- export class GenericPushNotification {
1044
- readonly namespace: string;
1045
- readonly originatingDeviceUuid: string;
1046
- readonly rawData: any;
1047
- constructor(namespace: string, originatingDeviceUuid: string, rawData: any);
1048
- }
1049
-
1050
- export class OnlinePushNotification extends GenericPushNotification {
1051
- readonly status?: number;
1052
- constructor(originatingDeviceUuid: string, rawData: any);
1053
- }
1054
-
1055
- export class AlarmPushNotification extends GenericPushNotification {
1056
- readonly value?: number | string | Record<string, any>;
1057
- readonly timestamp?: number;
1058
- readonly channel?: number;
1059
- readonly subdeviceId?: string;
1060
- constructor(originatingDeviceUuid: string, rawData: any);
1061
- }
1062
-
1063
- export class BindPushNotification extends GenericPushNotification {
1064
- readonly time: TimeInfo | null
1065
- readonly hwinfo: HardwareInfo | null
1066
- readonly fwinfo: FirmwareInfo | null
1067
- constructor(originatingDeviceUuid: string, rawData: any);
1068
- }
1069
-
1070
- export class UnbindPushNotification extends GenericPushNotification {
1071
- constructor(originatingDeviceUuid: string, rawData: any);
1072
- }
1073
-
1074
- export class WaterLeakPushNotification extends GenericPushNotification {
1075
- readonly syncedTime?: number | Record<string, any>;
1076
- readonly latestSampleTime?: number;
1077
- readonly latestSampleIsLeak?: number;
1078
- readonly subdeviceId?: string;
1079
- readonly samples?: Array<{ time: number; isLeak: number; [key: string]: any }>;
1080
- constructor(originatingDeviceUuid: string, rawData: any);
1081
- }
1082
-
1083
- /**
1084
- * Hub online data structure
1085
- */
1086
- export interface HubOnlineData {
1087
- subdeviceId: string
1088
- onlineStatus: number
1089
- [key: string]: any
1090
- }
1091
-
1092
- /**
1093
- * Hub toggle data structure
1094
- */
1095
- export interface HubToggleXData {
1096
- subdeviceId: string
1097
- onoff: number
1098
- [key: string]: any
1099
- }
1100
-
1101
- /**
1102
- * Hub battery data structure
1103
- */
1104
- export interface HubBatteryData {
1105
- subdeviceId: string
1106
- battery: number
1107
- [key: string]: any
1108
- }
1109
-
1110
- /**
1111
- * Hub sensor data structure
1112
- */
1113
- export interface HubSensorData {
1114
- subdeviceId: string
1115
- [key: string]: any
1116
- }
1117
-
1118
- export class HubOnlinePushNotification extends GenericPushNotification {
1119
- readonly onlineData: HubOnlineData[];
1120
- constructor(originatingDeviceUuid: string, rawData: any);
1121
- }
1122
-
1123
- export class HubToggleXPushNotification extends GenericPushNotification {
1124
- readonly togglexData: HubToggleXData[];
1125
- constructor(originatingDeviceUuid: string, rawData: any);
1126
- }
1127
-
1128
- export class HubBatteryPushNotification extends GenericPushNotification {
1129
- readonly batteryData: HubBatteryData[];
1130
- constructor(originatingDeviceUuid: string, rawData: any);
1131
- }
1132
-
1133
- export class HubSensorAllPushNotification extends GenericPushNotification {
1134
- readonly allData: HubSensorData[];
1135
- constructor(originatingDeviceUuid: string, rawData: any);
1136
- }
1137
-
1138
- export class HubSensorTempHumPushNotification extends GenericPushNotification {
1139
- readonly tempHumData: HubSensorData[];
1140
- constructor(originatingDeviceUuid: string, rawData: any);
1141
- }
1142
-
1143
- export class HubSensorAlertPushNotification extends GenericPushNotification {
1144
- readonly alertData: HubSensorData[];
1145
- constructor(originatingDeviceUuid: string, rawData: any);
1146
- }
1147
-
1148
- export class HubSensorSmokePushNotification extends GenericPushNotification {
1149
- readonly subdeviceId?: string | number;
1150
- readonly status?: number;
1151
- readonly interConn?: number | Record<string, any>;
1152
- readonly timestamp?: number;
1153
- readonly testEvent?: boolean;
1154
- constructor(originatingDeviceUuid: string, rawData: any);
1155
- }
1156
-
1157
- /**
1158
- * MTS100 thermostat data structure
1159
- */
1160
- export interface HubMts100Data {
1161
- subdeviceId: string
1162
- [key: string]: any
1163
- }
1164
-
1165
- /**
1166
- * Subdevice list data structure
1167
- */
1168
- export interface HubSubdeviceListData {
1169
- subdeviceId: string
1170
- subDeviceType: string
1171
- [key: string]: any
1172
- }
1173
-
1174
- /**
1175
- * Timer data structure
1176
- */
1177
- export interface TimerXData {
1178
- timerId: string
1179
- channel: number
1180
- [key: string]: any
1181
- }
1182
-
1183
- /**
1184
- * Trigger data structure
1185
- */
1186
- export interface TriggerXData {
1187
- triggerId: string
1188
- channel: number
1189
- [key: string]: any
1190
- }
1191
-
1192
- /**
1193
- * Presence study data structure
1194
- */
1195
- export interface PresenceStudyData {
1196
- channel: number
1197
- [key: string]: any
1198
- }
1199
-
1200
- /**
1201
- * Sensor latest data structure
1202
- */
1203
- export interface SensorLatestXData {
1204
- channel: number
1205
- [key: string]: any
1206
- }
1207
-
1208
- /**
1209
- * Diffuser light data structure
1210
- */
1211
- export interface DiffuserLightData {
1212
- channel: number
1213
- onoff: number
1214
- [key: string]: any
1215
- }
1216
-
1217
- /**
1218
- * Diffuser spray data structure
1219
- */
1220
- export interface DiffuserSprayData {
1221
- channel: number
1222
- mode: number
1223
- [key: string]: any
1224
- }
1225
-
1226
- export class HubMts100AllPushNotification extends GenericPushNotification {
1227
- readonly allData: HubMts100Data[];
1228
- constructor(originatingDeviceUuid: string, rawData: any);
1229
- }
1230
-
1231
- export class HubMts100ModePushNotification extends GenericPushNotification {
1232
- readonly modeData: HubMts100Data[];
1233
- constructor(originatingDeviceUuid: string, rawData: any);
1234
- }
1235
-
1236
- export class HubMts100TemperaturePushNotification extends GenericPushNotification {
1237
- readonly temperatureData: HubMts100Data[];
1238
- constructor(originatingDeviceUuid: string, rawData: any);
1239
- }
1240
-
1241
- export class HubSubdeviceListPushNotification extends GenericPushNotification {
1242
- readonly subdeviceListData: HubSubdeviceListData[];
1243
- constructor(originatingDeviceUuid: string, rawData: any);
1244
- }
1245
-
1246
- export class TimerXPushNotification extends GenericPushNotification {
1247
- readonly timerxData: TimerXData[];
1248
- constructor(originatingDeviceUuid: string, rawData: any);
1249
- }
1250
-
1251
- export class TriggerXPushNotification extends GenericPushNotification {
1252
- readonly triggerxData: TriggerXData[];
1253
- constructor(originatingDeviceUuid: string, rawData: any);
1254
- }
1255
-
1256
- export class PresenceStudyPushNotification extends GenericPushNotification {
1257
- readonly studyData: PresenceStudyData[];
1258
- constructor(originatingDeviceUuid: string, rawData: any);
1259
- }
1260
-
1261
- export class ToggleXPushNotification extends GenericPushNotification {
1262
- readonly togglexData: HubToggleXData[];
1263
- constructor(originatingDeviceUuid: string, rawData: any);
1264
- }
1265
-
1266
- export class SensorLatestXPushNotification extends GenericPushNotification {
1267
- readonly latestData: SensorLatestXData[];
1268
- constructor(originatingDeviceUuid: string, rawData: any);
1269
- }
1270
-
1271
- export class DiffuserLightPushNotification extends GenericPushNotification {
1272
- readonly lightData: DiffuserLightData[];
1273
- constructor(originatingDeviceUuid: string, rawData: any);
1274
- }
1275
-
1276
- export class DiffuserSprayPushNotification extends GenericPushNotification {
1277
- readonly sprayData: DiffuserSprayData[];
1278
- constructor(originatingDeviceUuid: string, rawData: any);
1279
- }
1280
-
1281
- export function parsePushNotification(namespace: string, messagePayload: any, deviceUuid: string): GenericPushNotification | null;
1282
-
1283
- export type MessageId = string
1284
- /** @deprecated Use Promise-based methods instead */
1285
- export type Callback<T> = (error: Error | null, data: T) => void
1286
- /** @deprecated Use Promise-based methods instead */
1287
- export type ErrorCallback = (error: Error | null) => void
1288
- export type DeviceInitializedEvent = 'deviceInitialized'
1289
-
1290
- export type DeviceInitializedCallback = (deviceId: string, device: MerossDevice) => void
1291
-
1292
- export type PushNotificationEvent = 'pushNotification'
1293
- export type PushNotificationCallback = (deviceId: string, notification: GenericPushNotification, device: MerossDevice) => void
1294
-
1295
- export type ErrorEvent = 'error'
1296
- export type CloudErrorCallback = (error: Error, deviceId: string | null) => void
1297
-
1298
- /**
1299
- * Filter options for finding devices.
1300
- *
1301
- * Used with DeviceRegistry.find() to filter the device list.
1302
- *
1303
- * @example
1304
- * ```typescript
1305
- * // Find online devices
1306
- * const onlineDevices = manager.devices.find({ onlineStatus: 1 });
1307
- *
1308
- * // Find specific device types
1309
- * const plugs = manager.devices.find({ deviceType: 'mss310' });
1310
- *
1311
- * // Find by custom filter function
1312
- * const customDevices = manager.devices.find({
1313
- * deviceClass: (device) => device.deviceType.startsWith('mss')
1314
- * });
1315
- * ```
1316
- */
1317
- export interface FindDevicesFilters {
1318
- /** Array of device UUIDs to filter by */
1319
- deviceUuids?: string[];
1320
- /** Array of internal device IDs to filter by */
1321
- internalIds?: string[];
1322
- /** Device type to filter by */
1323
- deviceType?: string;
1324
- /** Device name to filter by */
1325
- deviceName?: string;
1326
- /** Online status to filter by (0=connecting, 1=online, 2=offline, -1=unknown, 3=upgrading) */
1327
- onlineStatus?: number;
1328
- /** Device class filter - can be a string, function, or array of filters */
1329
- deviceClass?: string | ((device: MerossDevice) => boolean) | Array<string | ((device: MerossDevice) => boolean)>;
1330
- }
1331
-
1332
- /**
1333
- * Registry for managing Meross devices and subdevices.
1334
- *
1335
- * Maintains indexes for efficient device lookups across base devices and subdevices.
1336
- * Base devices can be looked up by UUID, while internal IDs enable unified lookup
1337
- * for both base devices and subdevices.
1338
- *
1339
- * Internal IDs unify device identification:
1340
- * - Base devices: `#BASE:{uuid}`
1341
- * - Subdevices: `#SUB:{hubUuid}:{subdeviceId}`
1342
- *
1343
- * @example
1344
- * ```typescript
1345
- * // Look up device by UUID
1346
- * const device = manager.devices.get('device-uuid');
1347
- *
1348
- * // Look up subdevice by hub UUID and subdevice ID
1349
- * const subdevice = manager.devices.get({ hubUuid: 'hub-uuid', id: 'subdevice-id' });
1350
- *
1351
- * // Find devices matching filters
1352
- * const lights = manager.devices.find({ deviceClass: 'light' });
1353
- *
1354
- * // Get all devices
1355
- * const allDevices = manager.devices.list();
1356
- * ```
1357
- */
1358
- export class DeviceRegistry {
1359
- /**
1360
- * Generates an internal ID for a device or subdevice.
1361
- *
1362
- * @param uuid - Device UUID (for base devices) or hub UUID (for subdevices)
1363
- * @param isSubdevice - Whether this is a subdevice
1364
- * @param hubUuid - Hub UUID (required if isSubdevice is true)
1365
- * @param subdeviceId - Subdevice ID (required if isSubdevice is true)
1366
- * @returns Internal ID string
1367
- */
1368
- static generateInternalId(uuid: string, isSubdevice?: boolean, hubUuid?: string | null, subdeviceId?: string | null): string
1369
-
1370
- /**
1371
- * Registers a device in the registry.
1372
- *
1373
- * @param device - Device instance to register
1374
- */
1375
- registerDevice(device: MerossDevice | MerossHubDevice | MerossSubDevice): void
1376
-
1377
- /**
1378
- * Removes a device from the registry.
1379
- *
1380
- * @param device - Device instance to remove
1381
- */
1382
- removeDevice(device: MerossDevice | MerossHubDevice | MerossSubDevice): void
1383
-
1384
- /**
1385
- * Unified method to get a device by identifier.
1386
- *
1387
- * Supports both base devices (by UUID string) and subdevices (by object with hubUuid and id).
1388
- * Internally converts the identifier to an internal ID format and performs the lookup.
1389
- *
1390
- * @param identifier - Device identifier
1391
- * @returns Device instance, or null if not found
1392
- * @example
1393
- * // Get base device by UUID
1394
- * const device = registry.get('device-uuid');
1395
- *
1396
- * @example
1397
- * // Get subdevice by hub UUID and subdevice ID
1398
- * const subdevice = registry.get({ hubUuid: 'hub-uuid', id: 'subdevice-id' });
1399
- */
1400
- get(identifier: string | { hubUuid: string; id: string }): MerossDevice | MerossHubDevice | MerossSubDevice | null
1401
-
1402
- /**
1403
- * Gets all registered devices.
1404
- *
1405
- * @returns Array of all registered devices
1406
- */
1407
- list(): Array<MerossDevice | MerossHubDevice | MerossSubDevice>
1408
-
1409
- /**
1410
- * Finds devices matching the specified filters.
1411
- *
1412
- * @param filters - Optional filter criteria
1413
- * @returns Array of matching devices
1414
- */
1415
- find(filters?: FindDevicesFilters): Array<MerossDevice | MerossHubDevice | MerossSubDevice>
1416
-
1417
- /**
1418
- * Clears all devices from the registry.
1419
- */
1420
- clear(): void
1421
-
1422
- /**
1423
- * Gets the total number of devices registered (including subdevices).
1424
- */
1425
- readonly size: number
1426
- }
1427
-
1428
- // Statistics types
1429
- export class HttpRequestSample {
1430
- readonly url: string;
1431
- readonly method: string;
1432
- readonly httpResponseCode: number;
1433
- readonly apiResponseCode: number | null;
1434
- readonly timestamp: number;
1435
- }
1436
-
1437
- export class HttpStat {
1438
- readonly totalCalls: number;
1439
- byHttpResponseCode(): Array<[number, number]>;
1440
- byApiStatusCode(): Array<[string, number]>;
1441
- }
1442
-
1443
- export class HttpStatsResult {
1444
- readonly globalStats: HttpStat;
1445
- statsByUrl(url: string): HttpStat | null;
1446
- deviceStats(): Array<[string, HttpStat]>;
1447
- }
1448
-
1449
- export class HttpStatsCounter {
1450
- constructor(maxSamples?: number);
1451
- notifyHttpRequest(requestUrl: string, method: string, httpResponseCode: number, apiResponseCode: number | null): void;
1452
- getStats(timeWindowMs?: number): HttpStatsResult;
1453
- }
1454
-
1455
- export class ApiCallSample {
1456
- readonly deviceUuid: string;
1457
- readonly namespace: string;
1458
- readonly method: string;
1459
- readonly timestamp: number;
1460
- }
1461
-
1462
- export class ApiStat {
1463
- readonly totalCalls: number;
1464
- byMethodNamespace(): Array<[string, number]>;
1465
- }
1466
-
1467
- export class ApiStatsResult {
1468
- readonly globalStats: ApiStat;
1469
- statsByUuid(deviceUuid: string): ApiStat | null;
1470
- deviceStats(): Array<[string, ApiStat]>;
1471
- }
1472
-
1473
- export class MqttStatsCounter {
1474
- constructor(maxSamples?: number);
1475
- readonly apiCalls: ApiCallSample[];
1476
- readonly delayedCalls: ApiCallSample[];
1477
- readonly droppedCalls: ApiCallSample[];
1478
- notifyApiCall(deviceUuid: string, namespace: string, method: string): void;
1479
- notifyDelayedCall(deviceUuid: string, namespace: string, method: string): void;
1480
- notifyDroppedCall(deviceUuid: string, namespace: string, method: string): void;
1481
- getApiStats(timeWindowMs?: number): ApiStatsResult;
1482
- getDelayedApiStats(timeWindowMs?: number): ApiStatsResult;
1483
- getDroppedApiStats(timeWindowMs?: number): ApiStatsResult;
1484
- }
1485
-
1486
- /**
1487
- * Utility class for timer operations.
1488
- *
1489
- * Provides static methods for working with device timers, including time conversion,
1490
- * day mask generation, and timer creation.
1491
- *
1492
- * @example
1493
- * ```typescript
1494
- * const minutes = TimerUtils.timeToMinutes('14:30');
1495
- * const weekMask = TimerUtils.daysToWeekMask(['monday', 'wednesday', 'friday']);
1496
- * const timer = TimerUtils.createTimer({
1497
- * channel: 0,
1498
- * time: '18:00',
1499
- * days: ['monday', 'tuesday', 'wednesday'],
1500
- * on: true
1501
- * });
1502
- * ```
1503
- */
1504
- export class TimerUtils {
1505
- /**
1506
- * Converts a time string, Date, or minutes to total minutes since midnight.
1507
- *
1508
- * @param time - Time as string ('HH:MM'), Date object, or minutes number
1509
- * @returns Total minutes since midnight
1510
- */
1511
- static timeToMinutes(time: string | Date | number): number;
1512
-
1513
- /**
1514
- * Converts minutes since midnight to time string.
1515
- *
1516
- * @param minutes - Minutes since midnight
1517
- * @returns Time string in 'HH:MM' format
1518
- */
1519
- static minutesToTime(minutes: number): string;
1520
-
1521
- /**
1522
- * Converts an array of days to a week mask bitmask.
1523
- *
1524
- * @param days - Array of day names or numbers
1525
- * @param repeat - Whether to repeat weekly (default: true)
1526
- * @returns Week mask bitmask
1527
- */
1528
- static daysToWeekMask(days: Array<string | number>, repeat?: boolean): number;
1529
-
1530
- /**
1531
- * Generates a unique timer ID.
1532
- *
1533
- * @returns Timer ID string
1534
- */
1535
- static generateTimerId(): string;
1536
-
1537
- /**
1538
- * Creates a timer object with the specified options.
1539
- *
1540
- * @param options - Timer options
1541
- * @returns Timer object ready to be sent to device
1542
- */
1543
- static createTimer(options: {
1544
- channel?: number;
1545
- alias?: string;
1546
- time?: string | Date | number;
1547
- days?: string[] | number[];
1548
- on?: boolean;
1549
- enabled?: boolean;
1550
- type?: number;
1551
- }): any;
1552
- }
1553
-
1554
- /**
1555
- * Utility class for trigger operations.
1556
- *
1557
- * Provides static methods for working with device triggers, including duration
1558
- * conversion and trigger creation.
1559
- *
1560
- * @example
1561
- * ```typescript
1562
- * const seconds = TriggerUtils.durationToSeconds('1h30m');
1563
- * const duration = TriggerUtils.secondsToDuration(5400);
1564
- * const trigger = TriggerUtils.createTrigger({
1565
- * channel: 0,
1566
- * duration: '2h',
1567
- * days: ['monday', 'friday'],
1568
- * enabled: true
1569
- * });
1570
- * ```
1571
- */
1572
- export class TriggerUtils {
1573
- /**
1574
- * Converts a duration string or number to seconds.
1575
- *
1576
- * @param duration - Duration as string ('1h30m') or seconds number
1577
- * @returns Total seconds
1578
- */
1579
- static durationToSeconds(duration: string | number): number;
1580
-
1581
- /**
1582
- * Converts seconds to duration string.
1583
- *
1584
- * @param seconds - Total seconds
1585
- * @returns Duration string (e.g., '1h30m')
1586
- */
1587
- static secondsToDuration(seconds: number): string;
1588
-
1589
- /**
1590
- * Creates a trigger object with the specified options.
1591
- *
1592
- * @param options - Trigger options
1593
- * @returns Trigger object ready to be sent to device
1594
- */
1595
- static createTrigger(options: {
1596
- channel?: number;
1597
- alias?: string;
1598
- duration?: string | number;
1599
- days?: string[] | number[];
1600
- type?: number;
1601
- enabled?: boolean;
1602
- }): any;
1603
- }
1604
-
1605
- export interface DebugUtils {
1606
- getErrorBudget(deviceUuid: string): number;
1607
- resetErrorBudget(deviceUuid: string): void;
1608
- getMqttStats(timeWindowMs?: number): ApiStatsResult | null;
1609
- getHttpStats(timeWindowMs?: number): HttpStatsResult | null;
1610
- getDelayedMqttStats(timeWindowMs?: number): ApiStatsResult | null;
1611
- getDroppedMqttStats(timeWindowMs?: number): ApiStatsResult | null;
1612
- enableStats(maxStatsSamples?: number): void;
1613
- disableStats(): void;
1614
- isStatsEnabled(): boolean;
1615
- }
1616
-
1617
- export function createDebugUtils(manager: ManagerMeross): DebugUtils;
1618
-
1619
- export interface ManagerSubscriptionOptions {
1620
- /** Logger function for debug output */
1621
- logger?: Logger;
1622
- deviceStateInterval?: number;
1623
- electricityInterval?: number;
1624
- consumptionInterval?: number;
1625
- httpDeviceListInterval?: number;
1626
- smartCaching?: boolean;
1627
- cacheMaxAge?: number;
1628
- }
1629
-
1630
- /**
1631
- * Device update event data
1632
- */
1633
- export interface DeviceUpdate {
1634
- source: string
1635
- timestamp: number
1636
- event?: any
1637
- device: MerossDevice
1638
- state: any
1639
- changes: Record<string, any>
1640
- [key: string]: any
1641
- }
1642
-
1643
- /**
1644
- * Device list update event data
1645
- */
1646
- export interface DeviceListUpdate {
1647
- devices: DeviceDefinition[]
1648
- added: DeviceDefinition[]
1649
- removed: DeviceDefinition[]
1650
- changed: DeviceDefinition[]
1651
- timestamp: number
1652
- }
1653
-
1654
- export class ManagerSubscription extends EventEmitter {
1655
- constructor(manager: ManagerMeross, options?: ManagerSubscriptionOptions);
1656
- subscribe(device: MerossDevice, config?: ManagerSubscriptionOptions): void;
1657
- unsubscribe(deviceUuid: string): void;
1658
- subscribeToDeviceList(): void;
1659
- unsubscribeFromDeviceList(): void;
1660
- destroy(): void;
1661
-
1662
- // EventEmitter events
1663
- on(event: `deviceUpdate:${string}`, listener: (update: DeviceUpdate) => void): this;
1664
- on(event: 'deviceListUpdate', listener: (update: DeviceListUpdate) => void): this;
1665
- on(event: 'error', listener: (error: Error, context?: string) => void): this;
1666
- }
1667
-
1668
- /**
1669
- * Main Meross IoT cloud manager.
1670
- *
1671
- * Manages connections to Meross devices via cloud MQTT and local HTTP.
1672
- * Handles device discovery, connection management, and provides access to device instances.
1673
- *
1674
- * @example
1675
- * ```typescript
1676
- * const httpClient = await MerossHttpClient.fromUserPassword({
1677
- * email: 'user@example.com',
1678
- * password: 'password'
1679
- * });
1680
- *
1681
- * const manager = new ManagerMeross({ httpClient });
1682
- * await manager.connect();
1683
- *
1684
- * manager.on('deviceInitialized', (deviceId, device) => {
1685
- * console.log(`Device ${deviceId} initialized: ${device.name}`);
1686
- * });
1687
- *
1688
- * const devices = manager.devices.list();
1689
- * ```
1690
- */
1691
- /**
1692
- * Manages device discovery, initialization, and lifecycle.
1693
- *
1694
- * Handles device discovery from Meross cloud, device enrollment,
1695
- * subdevice management, and device removal. Provides a clean
1696
- * interface for device operations separate from transport concerns.
1697
- *
1698
- * @example
1699
- * ```typescript
1700
- * // Discover devices
1701
- * const devices = await manager.devices.discover({ onlineOnly: true });
1702
- *
1703
- * // Initialize all devices
1704
- * const count = await manager.devices.initialize();
1705
- *
1706
- * // Get a device
1707
- * const device = manager.devices.get('device-uuid');
1708
- *
1709
- * // List all devices
1710
- * const allDevices = manager.devices.list();
1711
- * ```
1712
- */
1713
- export class ManagerDevices {
1714
- /**
1715
- * Gets a device by UUID or subdevice identifier.
1716
- *
1717
- * @param identifier - Device UUID or subdevice identifier
1718
- * @returns Device instance or null if not found
1719
- */
1720
- get(identifier: string | { hubUuid: string; id: string }): MerossDevice | MerossHubDevice | MerossSubDevice | null
1721
-
1722
- /**
1723
- * Lists all registered devices.
1724
- *
1725
- * @returns Array of device instances
1726
- */
1727
- list(): Array<MerossDevice | MerossHubDevice | MerossSubDevice>
1728
-
1729
- /**
1730
- * Finds devices matching the provided filters.
1731
- *
1732
- * @param filters - Filter criteria
1733
- * @returns Array of matching device instances
1734
- */
1735
- find(filters?: FindDevicesFilters): Array<MerossDevice | MerossHubDevice | MerossSubDevice>
1736
-
1737
- /**
1738
- * Discovers available base devices without initializing them.
1739
- *
1740
- * @param options - Optional filter options
1741
- * @returns Promise resolving to array of device info objects
1742
- */
1743
- discover(options?: { deviceTypes?: string[], onlineOnly?: boolean, excludeHubs?: boolean }): Promise<DeviceDefinition[]>
1744
-
1745
- /**
1746
- * Discovers available subdevices without initializing devices.
1747
- *
1748
- * @param options - Optional filter options
1749
- * @returns Promise resolving to array of subdevice info objects
1750
- */
1751
- discoverSubdevices(options?: { hubUuids?: string[], subdeviceType?: string, onlineOnly?: boolean }): Promise<SubdeviceInfo[]>
1752
-
1753
- /**
1754
- * Initializes devices from the Meross cloud.
1755
- *
1756
- * @param options - Optional filter options
1757
- * @returns Promise resolving to the number of devices initialized
1758
- */
1759
- initialize(options?: { uuids?: string[] }): Promise<number>
1760
-
1761
- /**
1762
- * Initializes a single device by UUID or subdevice by identifier.
1763
- *
1764
- * @param identifier - Device identifier
1765
- * @returns Promise resolving to device instance, or null if initialization fails
1766
- */
1767
- initializeDevice(identifier: string | { hubUuid: string, id: string }): Promise<MerossDevice | MerossHubDevice | MerossSubDevice | null>
1768
-
1769
- /**
1770
- * Removes a device from the manager.
1771
- *
1772
- * @param identifier - Device identifier
1773
- * @returns Promise resolving to true if device was removed, false if not found
1774
- */
1775
- remove(identifier: string | { hubUuid: string, id: string }): Promise<boolean>
80
+ export class MerossError extends Error {
81
+ readonly code: string;
82
+ readonly errorCode: number | null;
83
+ readonly isOperational: boolean;
84
+ readonly cause: Error | null;
85
+ toJSON(): Record<string, any>;
1776
86
  }
1777
87
 
1778
- /**
1779
- * Manages MQTT connections and message publishing.
1780
- *
1781
- * Handles MQTT client creation, connection management, message encoding,
1782
- * and message routing. Provides a clean interface for MQTT operations
1783
- * separate from device management.
1784
- *
1785
- * @example
1786
- * ```typescript
1787
- * // Initialize MQTT for a device
1788
- * await manager.mqtt.init(deviceDef);
1789
- *
1790
- * // Encode a message
1791
- * const data = manager.mqtt.encode('GET', 'Appliance.Control.ToggleX', {}, 'device-uuid');
1792
- *
1793
- * // Send a message
1794
- * manager.mqtt.send(device, data);
1795
- * ```
1796
- */
1797
- export class ManagerMqtt {
1798
- /**
1799
- * Initializes MQTT connection for a device.
1800
- *
1801
- * @param dev - Device definition object with uuid and optional domain
1802
- * @returns Promise that resolves when MQTT connection is ready
1803
- */
1804
- init(dev: { uuid: string; domain?: string }): Promise<void>
1805
-
1806
- /**
1807
- * Sends a message to a device via MQTT.
1808
- *
1809
- * @param device - Device instance
1810
- * @param data - Message data object with header and payload
1811
- * @returns True if message was sent successfully, false if MQTT connection not available
1812
- */
1813
- send(device: MerossDevice | MerossHubDevice | MerossSubDevice, data: any): boolean
1814
-
1815
- /**
1816
- * Encodes a message for Meross device communication.
1817
- *
1818
- * @param method - Message method ('GET', 'SET', 'PUSH')
1819
- * @param namespace - Message namespace
1820
- * @param payload - Message payload object
1821
- * @param deviceUuid - Target device UUID
1822
- * @returns Encoded message object with header and payload
1823
- */
1824
- encode(method: string, namespace: string, payload: any, deviceUuid: string): any
1825
-
1826
- /**
1827
- * Disconnects all MQTT connections.
1828
- *
1829
- * @param force - Force disconnect flag
1830
- */
1831
- disconnectAll(force?: boolean): void
1832
- }
88
+ export class MerossAuthError extends MerossError {}
89
+ export class MerossDeviceError extends MerossError {}
90
+ export class MerossApiError extends MerossError {}
91
+ export class MerossNetworkError extends MerossError {}
1833
92
 
1834
- /**
1835
- * Manages LAN HTTP communication with devices.
1836
- *
1837
- * Handles local HTTP communication directly with Meross devices
1838
- * on the local network, bypassing the cloud MQTT broker.
1839
- *
1840
- * @example
1841
- * ```typescript
1842
- * // Send a message via LAN HTTP
1843
- * await manager.http.send(device, '192.168.1.100', data);
1844
- * ```
1845
- */
1846
- export class ManagerHttp {
1847
- /**
1848
- * Sends a message to a device via LAN HTTP.
1849
- *
1850
- * @param device - Device instance
1851
- * @param ip - Device LAN IP address
1852
- * @param payload - Message payload
1853
- * @param timeoutOverride - Optional timeout override in milliseconds
1854
- * @returns Promise that resolves when message is sent
1855
- */
1856
- send(device: MerossDevice | MerossHubDevice | MerossSubDevice, ip: string, payload: any, timeoutOverride?: number): Promise<void>
1857
- }
1858
-
1859
- /**
1860
- * Manages transport mode selection and message routing.
1861
- *
1862
- * Handles transport mode configuration and coordinates between MQTT and HTTP
1863
- * managers to route messages based on the selected transport mode. Provides
1864
- * error budget checking and automatic fallback logic.
1865
- *
1866
- * @example
1867
- * ```typescript
1868
- * // Set default transport mode
1869
- * manager.transport.defaultMode = TransportMode.LAN_HTTP_FIRST;
1870
- *
1871
- * // Request a message with transport mode override
1872
- * await manager.transport.request(device, '192.168.1.100', data, TransportMode.MQTT_ONLY);
1873
- * ```
1874
- */
1875
- export class ManagerTransport {
1876
- /**
1877
- * Gets or sets the default transport mode for device communication.
1878
- */
1879
- get defaultMode(): number
1880
- set defaultMode(value: number)
1881
-
1882
- /**
1883
- * Requests a message to be sent to a device.
1884
- *
1885
- * @param device - Device instance
1886
- * @param ip - Device LAN IP address (null if not available)
1887
- * @param data - Message data object with header and payload
1888
- * @param overrideMode - Optional override transport mode
1889
- * @returns Promise that resolves to true if message was sent successfully
1890
- */
1891
- request(device: MerossDevice | MerossHubDevice | MerossSubDevice, ip: string | null, data: any, overrideMode?: number | null): Promise<boolean>
93
+ export interface TokenData {
94
+ token: string;
95
+ key: string;
96
+ userId: string;
97
+ userEmail?: string;
98
+ domain: string;
99
+ mqttDomain: string;
100
+ issuedOn?: string;
1892
101
  }
1893
102
 
1894
- export class ManagerMeross extends EventEmitter {
1895
- /**
1896
- * Creates a new ManagerMeross instance.
1897
- *
1898
- * @param options - Configuration options
1899
- */
1900
- constructor(options: CloudOptions)
1901
-
1902
- /**
1903
- * Connects to the Meross cloud and initializes devices.
1904
- *
1905
- * @returns Promise resolving to the number of devices initialized
1906
- * @throws {MerossError} If connection fails
1907
- */
1908
- connect(): Promise<number>
1909
-
1910
- /**
1911
- * Authenticates with Meross cloud and discovers devices.
1912
- *
1913
- * Alias for devices.initialize(). Retrieves device list and initializes device connections.
1914
- * The httpClient should already be authenticated when passed to the constructor.
1915
- *
1916
- * @returns Promise resolving to the number of devices discovered
1917
- * @throws {MerossErrorHttpApi} If API request fails
1918
- * @throws {MerossErrorTokenExpired} If authentication token has expired
1919
- */
1920
- login(): Promise<number>
1921
-
1922
- /**
1923
- * Registers a handler for device initialization events.
1924
- *
1925
- * @param name - Event name ('deviceInitialized')
1926
- * @param handler - Callback function
1927
- * @returns This instance for method chaining
1928
- */
1929
- on(name: DeviceInitializedEvent, handler: DeviceInitializedCallback): this
1930
-
1931
- /**
1932
- * Registers a handler for push notification events.
1933
- *
1934
- * @param name - Event name ('pushNotification')
1935
- * @param handler - Callback function
1936
- * @returns This instance for method chaining
1937
- */
1938
- on(name: PushNotificationEvent, handler: PushNotificationCallback): this
1939
-
1940
- /**
1941
- * Registers a handler for error events.
1942
- *
1943
- * @param name - Event name ('error')
1944
- * @param handler - Callback function
1945
- * @returns This instance for method chaining
1946
- */
1947
- on(name: ErrorEvent, handler: CloudErrorCallback): this
1948
-
1949
- /**
1950
- * Logs out and invalidates the current session.
1951
- *
1952
- * @returns Promise that resolves when logout is complete
1953
- */
1954
- logout(): Promise<void>
1955
-
1956
- /**
1957
- * Disconnects all devices.
1958
- *
1959
- * @param force - Whether to force disconnect immediately
1960
- */
1961
- disconnectAll(force: boolean): void
1962
-
1963
- /**
1964
- * Gets the current token data.
1965
- *
1966
- * @returns Token data or null if not authenticated
1967
- */
1968
- getTokenData(): TokenData | null
1969
-
1970
- /** HTTP client instance */
1971
- readonly httpClient: MerossHttpClient
1972
-
1973
- /** Subscription manager instance for automatic polling and data provisioning */
1974
- readonly subscription: ManagerSubscription
1975
-
1976
- /** Device manager instance for device discovery, initialization, and lifecycle */
1977
- readonly devices: ManagerDevices
1978
-
1979
- /** MQTT manager instance for MQTT connection management and message publishing */
1980
- readonly mqtt: ManagerMqtt
1981
-
1982
- /** HTTP manager instance for LAN HTTP communication */
1983
- readonly http: ManagerHttp
1984
-
1985
- /** Transport manager instance for transport mode selection and message routing */
1986
- readonly transport: ManagerTransport
103
+ export interface DeviceDefinition {
104
+ uuid: string;
105
+ onlineStatus: number;
106
+ devName: string;
107
+ deviceType: string;
108
+ domain: string;
109
+ channels: Array<{ channel?: number; [key: string]: any }>;
110
+ [key: string]: any;
1987
111
  }
1988
112
 
1989
-
1990
- /**
1991
- * HTTP client for Meross cloud API.
1992
- *
1993
- * Handles authentication and HTTP API requests to the Meross cloud.
1994
- * Provides factory methods for easy initialization from credentials.
1995
- *
1996
- * @example
1997
- * ```typescript
1998
- * // Login with username/password
1999
- * const httpClient = await MerossHttpClient.fromUserPassword({
2000
- * email: 'user@example.com',
2001
- * password: 'password'
2002
- * });
2003
- *
2004
- * // Or use saved credentials
2005
- * const httpClient = MerossHttpClient.fromCredentials({
2006
- * token: '...',
2007
- * key: '...',
2008
- * userId: '...',
2009
- * domain: '...'
2010
- * });
2011
- *
2012
- * const devices = await httpClient.getDevices();
2013
- * ```
2014
- */
2015
- export class MerossHttpClient {
2016
- /**
2017
- * Creates a new MerossHttpClient instance.
2018
- *
2019
- * @param options - Client configuration options
2020
- */
2021
- constructor(options?: {
2022
- logger?: Logger;
2023
- timeout?: number;
2024
- autoRetryOnBadDomain?: boolean;
2025
- mqttDomain?: string | null;
2026
- enableStats?: boolean;
2027
- maxStatsSamples?: number;
2028
- });
2029
-
2030
- /**
2031
- * Sets the authentication token.
2032
- *
2033
- * @param token - Authentication token
2034
- */
2035
- setToken(token: string): void;
2036
-
2037
- /**
2038
- * Sets the HTTP API domain.
2039
- *
2040
- * @param domain - API domain (e.g., 'us.meross.com')
2041
- */
2042
- setHttpDomain(domain: string): void;
2043
-
2044
- /**
2045
- * Sets the MQTT domain.
2046
- *
2047
- * @param domain - MQTT domain or null to use default
2048
- */
2049
- setMqttDomain(domain: string | null): void;
2050
-
2051
- /** HTTP statistics counter (null if stats not enabled) */
2052
- readonly stats: HttpStatsCounter | null;
2053
-
2054
- /**
2055
- * Logs in with email and password.
2056
- *
2057
- * @param email - User email address
2058
- * @param password - User password
2059
- * @param mfaCode - Optional MFA code if required
2060
- * @returns Promise resolving to login response with token data
2061
- * @throws {MerossErrorMFARequired} If MFA is required
2062
- * @throws {MerossErrorAuthentication} If login fails
2063
- */
2064
- login(email: string, password: string, mfaCode?: string): Promise<{
2065
- token: string;
2066
- key: string;
2067
- userId: string;
2068
- email: string;
2069
- mqttDomain?: string;
2070
- }>;
2071
-
2072
- /**
2073
- * Gets the list of devices for the authenticated user.
2074
- *
2075
- * @returns Promise resolving to array of device definitions
2076
- * @throws {MerossErrorUnauthorized} If not authenticated
2077
- */
2078
- getDevices(): Promise<DeviceDefinition[]>;
2079
-
2080
- /**
2081
- * Gets subdevices for a hub device.
2082
- *
2083
- * @param deviceUuid - Hub device UUID
2084
- * @returns Promise resolving to array of subdevice definitions
2085
- */
2086
- getSubDevices(deviceUuid: string): Promise<any[]>;
2087
-
2088
- /**
2089
- * Logs out and invalidates the current session.
2090
- *
2091
- * @returns Promise that resolves when logout is complete
2092
- */
2093
- logout(): Promise<void>;
2094
-
2095
- /**
2096
- * Factory method: Creates an HTTP client from username/password credentials.
2097
- *
2098
- * This method handles login and returns a configured client instance.
2099
- *
2100
- * @param options - Login options including email and password
2101
- * @returns Promise resolving to configured MerossHttpClient instance
2102
- *
2103
- * @example
2104
- * ```typescript
2105
- * const httpClient = await MerossHttpClient.fromUserPassword({
2106
- * email: 'user@example.com',
2107
- * password: 'password',
2108
- * mfaCode: '123456' // if MFA is enabled
2109
- * });
2110
- * ```
2111
- */
2112
- static fromUserPassword(options: {
2113
- email: string;
2114
- password: string;
2115
- mfaCode?: string;
2116
- logger?: Logger;
2117
- timeout?: number;
2118
- autoRetryOnBadDomain?: boolean;
2119
- enableStats?: boolean;
2120
- maxStatsSamples?: number;
2121
- }): Promise<MerossHttpClient>;
2122
-
2123
- /**
2124
- * Factory method: Creates an HTTP client from saved credentials.
2125
- *
2126
- * Use this when you have previously saved token data from a login.
2127
- *
2128
- * @param credentials - Saved credential data
2129
- * @param options - Optional client configuration
2130
- * @returns Configured MerossHttpClient instance
2131
- *
2132
- * @example
2133
- * ```typescript
2134
- * const httpClient = MerossHttpClient.fromCredentials({
2135
- * token: savedToken,
2136
- * key: savedKey,
2137
- * userId: savedUserId,
2138
- * domain: savedDomain,
2139
- * mqttDomain: savedMqttDomain
2140
- * });
2141
- * ```
2142
- */
2143
- static fromCredentials(credentials: {
2144
- token: string;
2145
- key: string;
2146
- userId: string;
2147
- domain: string;
2148
- mqttDomain?: string;
2149
- }, options?: {
2150
- logger?: Logger;
2151
- timeout?: number;
2152
- autoRetryOnBadDomain?: boolean;
2153
- enableStats?: boolean;
2154
- maxStatsSamples?: number;
2155
- }): MerossHttpClient;
113
+ export interface SubdeviceInfo {
114
+ hubUuid: string;
115
+ hubName: string;
116
+ hubDeviceType: string;
117
+ subdeviceId: string;
118
+ subdeviceType: string;
119
+ subdeviceName: string;
120
+ [key: string]: any;
2156
121
  }
2157
122
 
2158
- /**
2159
- * Toggle feature interface.
2160
- *
2161
- * Provides control over device on/off state.
2162
- */
2163
123
  export interface ToggleFeature {
2164
- /**
2165
- * Sets the toggle state (on/off) for a channel.
2166
- *
2167
- * Automatically detects whether device uses Toggle or ToggleX protocol.
2168
- *
2169
- * @param options - Toggle options
2170
- * @param options.on - True to turn on, false to turn off
2171
- * @param options.channel - Channel to control (default: 0)
2172
- * @returns Promise that resolves when state is set
2173
- */
2174
- set(options: { on: boolean; channel?: number }): Promise<void>
2175
-
2176
- /**
2177
- * Gets the current toggle state for a channel.
2178
- *
2179
- * Uses cached state if fresh (<5 seconds), otherwise fetches from device.
2180
- * This transparent caching reduces unnecessary network requests.
2181
- *
2182
- * @param options - Get options
2183
- * @param options.channel - Channel to get state for (default: 0)
2184
- * @returns Promise that resolves with toggle state or undefined
2185
- */
2186
- get(options?: { channel?: number }): Promise<ToggleState | undefined>
2187
-
2188
- /**
2189
- * Checks if the device is on for the specified channel.
2190
- *
2191
- * Convenience method that reads from cached state. Returns undefined if state not available.
2192
- *
2193
- * @param options - Options
2194
- * @param options.channel - Channel to check (default: 0)
2195
- * @returns True if on, false if off, undefined if not available
2196
- */
2197
- isOn(options?: { channel?: number }): boolean | undefined
124
+ set(options: { on: boolean; channel?: number }): Promise<void>;
125
+ get(options?: { channel?: number }): Promise<any>;
126
+ isOn(options?: { channel?: number }): boolean | undefined;
127
+ getAll(): Map<number, boolean>;
2198
128
  }
2199
129
 
2200
- /**
2201
- * Light feature interface.
2202
- *
2203
- * Provides control over light settings including color, brightness, temperature.
2204
- */
2205
- export interface LightFeature {
2206
- /**
2207
- * Sets the light color, brightness, temperature, and on/off state.
2208
- *
2209
- * Automatically detects device capabilities (RGB, temperature, luminance support).
2210
- * Only sends parameters that the device supports to avoid errors.
2211
- *
2212
- * @param options - Light control options
2213
- * @param options.channel - Channel to control (default: 0)
2214
- * @param options.on - Turn on/off (only used if device doesn't support Toggle/ToggleX)
2215
- * @param options.rgb - RGB color [r, g, b], integer, or {r,g,b} object
2216
- * @param options.luminance - Brightness value (0-100)
2217
- * @param options.temperature - Temperature value (0-100)
2218
- * @param options.gradual - Enable gradual transition (default: true for RGB, false otherwise)
2219
- * @returns Promise that resolves with response or null if no changes needed
2220
- */
2221
- set(options?: {
2222
- channel?: number;
2223
- on?: boolean;
2224
- rgb?: [number, number, number] | { r: number; g: number; b: number } | { red: number; green: number; blue: number } | number;
2225
- luminance?: number;
2226
- temperature?: number;
2227
- gradual?: boolean | number;
2228
- }): Promise<any | null>
2229
-
2230
- /**
2231
- * Gets the current light state for a channel.
2232
- *
2233
- * Uses cached state if fresh (<5 seconds), otherwise fetches from device.
2234
- *
2235
- * @param options - Get options
2236
- * @param options.channel - Channel to get state for (default: 0)
2237
- * @returns Promise that resolves with light state or undefined
2238
- */
2239
- get(options?: { channel?: number }): Promise<LightState | undefined>
2240
-
2241
- /**
2242
- * Checks if the light is on for the specified channel.
2243
- *
2244
- * Convenience method that reads from cached state.
2245
- *
2246
- * @param options - Options
2247
- * @param options.channel - Channel to check (default: 0)
2248
- * @returns True if on, false if off, undefined if not available
2249
- */
2250
- isOn(options?: { channel?: number }): boolean | undefined
2251
-
2252
- /**
2253
- * Gets the light RGB color for the specified channel.
2254
- *
2255
- * Reads from cached state. Returns undefined if device doesn't support RGB or state unavailable.
2256
- *
2257
- * @param options - Options
2258
- * @param options.channel - Channel to get color for (default: 0)
2259
- * @returns RGB tuple [r, g, b] or undefined if not available
2260
- */
2261
- getRgbColor(options?: { channel?: number }): [number, number, number] | undefined
2262
-
2263
- /**
2264
- * Gets the light brightness for the specified channel.
2265
- *
2266
- * Reads from cached state. Returns undefined if device doesn't support brightness control.
2267
- *
2268
- * @param options - Options
2269
- * @param options.channel - Channel to get brightness for (default: 0)
2270
- * @returns Brightness value or undefined if not available
2271
- */
2272
- getBrightness(options?: { channel?: number }): number | undefined
2273
-
2274
- /**
2275
- * Gets the light temperature for the specified channel.
2276
- *
2277
- * @param options - Options
2278
- * @param options.channel - Channel to get temperature for (default: 0)
2279
- * @returns Temperature value or undefined if not available
2280
- */
2281
- getTemperature(options?: { channel?: number }): number | undefined
2282
-
2283
- /**
2284
- * Checks if the light supports RGB mode for the specified channel.
2285
- *
2286
- * @param options - Options
2287
- * @param options.channel - Channel to check (default: 0)
2288
- * @returns True if RGB is supported
2289
- */
2290
- supportsRgb(options?: { channel?: number }): boolean
2291
-
2292
- /**
2293
- * Checks if the light supports luminance mode for the specified channel.
2294
- *
2295
- * @param options - Options
2296
- * @param options.channel - Channel to check (default: 0)
2297
- * @returns True if luminance is supported
2298
- */
2299
- supportsLuminance(options?: { channel?: number }): boolean
2300
-
2301
- /**
2302
- * Checks if the light supports temperature mode for the specified channel.
2303
- *
2304
- * @param options - Options
2305
- * @param options.channel - Channel to check (default: 0)
2306
- * @returns True if temperature is supported
2307
- */
2308
- supportsTemperature(options?: { channel?: number }): boolean
130
+ export interface TimerFeature {
131
+ get(options?: { channel?: number; timerId?: string }): Promise<any>;
132
+ getAll(): Promise<any[]>;
133
+ count(): Promise<number>;
134
+ invalidateCache(options?: { channel?: number }): void;
135
+ set(options?: any): Promise<any>;
136
+ delete(options: { timerId: string; channel?: number }): Promise<any>;
137
+ findTimerByAlias(options: { alias: string; channel?: number }): Promise<any>;
138
+ deleteTimerByAlias(options: { alias: string; channel?: number }): Promise<any>;
139
+ enableTimerByAlias(options: { alias: string; channel?: number }): Promise<any>;
140
+ disableTimerByAlias(options: { alias: string; channel?: number }): Promise<any>;
141
+ deleteAllTimers(options?: { channel?: number }): Promise<any[]>;
142
+ timeToMinutes(time: string | Date | number): number;
143
+ minutesToTime(minutes: number): string;
144
+ daysToWeekMask(days: Array<string | number>, repeat?: boolean): number;
145
+ createTimer(options?: Record<string, any>): Record<string, any>;
2309
146
  }
2310
147
 
2311
- /**
2312
- * System feature interface.
2313
- *
2314
- * Provides access to device system information.
2315
- */
2316
- export interface SystemFeature {
2317
- getAllData(): Promise<any>
2318
- getDebug(): Promise<any>
2319
- getAbilities(): Promise<any>
2320
- getEncryptSuite(): Promise<any>
2321
- getEncryptECDHE(): Promise<any>
2322
- getOnlineStatus(): Promise<any>
2323
- getConfigWifiList(): Promise<any>
2324
- getConfigTrace(): Promise<any>
2325
- getRuntime(): Promise<any>
148
+ export interface TriggerFeature {
149
+ get(options?: { channel?: number }): Promise<any>;
150
+ getAll(): Promise<any[]>;
151
+ count(): Promise<number>;
152
+ invalidateCache(options?: { channel?: number }): void;
153
+ set(options?: any): Promise<any>;
154
+ delete(options: { triggerId: string; channel?: number }): Promise<any>;
155
+ findTriggerByAlias(options: { alias: string; channel?: number }): Promise<any>;
156
+ deleteTriggerByAlias(options: { alias: string; channel?: number }): Promise<any>;
157
+ enableTriggerByAlias(options: { alias: string; channel?: number }): Promise<any>;
158
+ disableTriggerByAlias(options: { alias: string; channel?: number }): Promise<any>;
159
+ deleteAllTriggers(options?: { channel?: number }): Promise<any[]>;
160
+ durationToSeconds(duration: string | number): number;
161
+ secondsToDuration(seconds: number): string;
162
+ createTrigger(options?: Record<string, any>): Record<string, any>;
2326
163
  }
2327
164
 
2328
- /**
2329
- * Encryption feature interface.
2330
- *
2331
- * Provides encryption-related functionality.
2332
- */
2333
- export interface EncryptionFeature {
2334
- supportEncryption(): boolean
2335
- isEncryptionKeySet(): boolean
2336
- setEncryptionKey(uuid: string, mrskey: string, mac: string): void
2337
- encryptMessage(messageData: string | Buffer): string
2338
- decryptMessage(encryptedData: string | Buffer): Buffer
165
+ export interface LightFeature {
166
+ set(options?: { channel?: number; on?: boolean; rgb?: number[] | number | { r: number; g: number; b: number }; luminance?: number; temperature?: number; gradual?: boolean | number }): Promise<any>;
167
+ get(options?: { channel?: number }): Promise<any>;
168
+ isOn(options?: { channel?: number }): boolean | undefined;
169
+ getRgbColor(options?: { channel?: number }): number[] | undefined;
170
+ getBrightness(options?: { channel?: number }): number | undefined;
171
+ getTemperature(options?: { channel?: number }): number | undefined;
172
+ supportsRgb(options?: { channel?: number }): boolean;
173
+ supportsLuminance(options?: { channel?: number }): boolean;
174
+ supportsTemperature(options?: { channel?: number }): boolean;
2339
175
  }
2340
176
 
2341
- /**
2342
- * Thermostat feature interface.
2343
- *
2344
- * Provides control over thermostat mode, temperature settings, and schedules.
2345
- */
2346
177
  export interface ThermostatFeature {
2347
- set(options?: {
2348
- channel?: number;
2349
- mode?: number;
2350
- onoff?: number;
2351
- heatTemperature?: number;
2352
- coolTemperature?: number;
2353
- ecoTemperature?: number;
2354
- manualTemperature?: number;
2355
- partialUpdate?: boolean;
2356
- state?: number;
2357
- windowOpened?: boolean;
2358
- }): Promise<any>
2359
- get(options?: { channel?: number }): Promise<any>
2360
- getSchedule(options?: { channel?: number }): Promise<any>
2361
- getTimer(options?: { channel?: number }): Promise<any>
178
+ set(options?: Record<string, any>): Promise<any>;
179
+ get(options?: { channel?: number }): Promise<any>;
180
+ getSchedule(options?: { channel?: number }): Promise<any>;
181
+ getTimer(options?: { channel?: number }): Promise<any>;
2362
182
  }
2363
183
 
2364
- /**
2365
- * Roller shutter feature interface.
2366
- *
2367
- * Provides control over roller shutter/blind position and movement.
2368
- */
2369
184
  export interface RollerShutterFeature {
2370
- set(options: { channel?: number; position: number }): Promise<any>
2371
- get(options?: { channel?: number }): Promise<RollerShutterState | undefined>
2372
- open(options?: { channel?: number }): Promise<any>
2373
- close(options?: { channel?: number }): Promise<any>
2374
- stop(options?: { channel?: number }): Promise<any>
2375
- getPosition(options?: { channel?: number }): Promise<any>
2376
- getConfig(options?: { channel?: number }): Promise<any>
2377
- setConfig(options: { config: any }): Promise<any>
185
+ set(options: { channel?: number; position: number }): Promise<any>;
186
+ get(options?: { channel?: number }): Promise<any>;
187
+ open(options?: { channel?: number }): Promise<any>;
188
+ close(options?: { channel?: number }): Promise<any>;
189
+ stop(options?: { channel?: number }): Promise<any>;
190
+ getPosition(options?: Record<string, any>): Promise<any>;
191
+ getConfig(options?: Record<string, any>): Promise<any>;
192
+ setConfig(options: { config: any | any[] }): Promise<any>;
2378
193
  }
2379
194
 
2380
- /**
2381
- * Garage door feature interface.
2382
- *
2383
- * Provides control over garage door open/close state and configuration.
2384
- */
2385
195
  export interface GarageFeature {
2386
- set(options: { channel?: number; open: boolean }): Promise<any>
2387
- get(options?: { channel?: number }): Promise<GarageDoorState | undefined>
2388
- isOpen(options?: { channel?: number }): boolean | undefined
2389
- isClosed(options?: { channel?: number }): boolean | undefined
2390
- open(options?: { channel?: number }): Promise<any>
2391
- close(options?: { channel?: number }): Promise<any>
2392
- toggle(options?: { channel?: number }): Promise<any>
2393
- getMultipleConfig(options?: { channel?: number }): Promise<any>
2394
- getConfig(options?: { channel?: number }): Promise<any>
2395
- setConfig(options: {
2396
- configData?: any;
2397
- signalDuration?: number;
2398
- buzzerEnable?: boolean;
2399
- doorOpenDuration?: number;
2400
- doorCloseDuration?: number;
2401
- }): Promise<any>
196
+ set(options: { channel?: number; open: boolean }): Promise<any>;
197
+ get(options?: { channel?: number }): Promise<any>;
198
+ isOpen(options?: { channel?: number }): boolean | undefined;
199
+ isClosed(options?: { channel?: number }): boolean | undefined;
200
+ open(options?: { channel?: number }): Promise<any>;
201
+ close(options?: { channel?: number }): Promise<any>;
202
+ toggle(options?: { channel?: number }): Promise<any>;
203
+ getConfig(options?: Record<string, any>): Promise<any>;
204
+ setConfig(options?: Record<string, any>): Promise<any>;
2402
205
  }
2403
206
 
2404
- /**
2405
- * Diffuser feature interface.
2406
- *
2407
- * Provides control over diffuser light and spray settings.
2408
- */
2409
- export interface DiffuserFeature {
2410
- set(options?: {
2411
- channel?: number;
2412
- type?: 'light' | 'spray';
2413
- on?: boolean;
2414
- rgb?: [number, number, number] | { r: number; g: number; b: number } | number;
2415
- luminance?: number;
2416
- temperature?: number;
2417
- mode?: number;
2418
- gradual?: boolean | number;
2419
- }): Promise<any>
2420
- get(options?: { channel?: number; type?: 'light' | 'spray' }): Promise<any>
2421
- getSensor(options?: { channel?: number }): Promise<any>
2422
- setSensor(options: { channel?: number; sensorData: any }): Promise<any>
2423
- }
2424
-
2425
- /**
2426
- * Spray feature interface.
2427
- *
2428
- * Provides control over spray mode.
2429
- */
2430
- export interface SprayFeature {
2431
- set(options: { channel?: number; mode: SprayMode | number }): Promise<any>
2432
- get(options?: { channel?: number }): Promise<any>
2433
- getMode(options?: { channel?: number }): number | undefined
2434
- getRawMode(options?: { channel?: number }): number | undefined
207
+ export interface ElectricityFeature {
208
+ get(options?: { channel?: number }): Promise<any>;
209
+ getRaw(options?: { channel?: number }): Promise<any>;
2435
210
  }
2436
211
 
2437
- /**
2438
- * Consumption feature interface.
2439
- *
2440
- * Provides access to power consumption data.
2441
- */
2442
212
  export interface ConsumptionFeature {
2443
- get(options?: { channel?: number }): Promise<Array<{date: Date, totalConsumptionKwh: number}>>
2444
- getRaw(options?: { channel?: number }): Promise<any>
2445
- getX(options?: { channel?: number }): Promise<Array<{date: Date, totalConsumptionKwh: number}>>
2446
- getRawX(options?: { channel?: number }): Promise<any>
2447
- getConfig(options?: { channel?: number }): Promise<any>
213
+ get(options?: { channel?: number }): Promise<any>;
214
+ getConfig(): Promise<any>;
2448
215
  }
2449
216
 
2450
- /**
2451
- * Electricity feature interface.
2452
- *
2453
- * Provides access to real-time electricity metrics.
2454
- */
2455
- export interface ElectricityFeature {
2456
- get(options?: { channel?: number }): Promise<{amperage: number, voltage: number, wattage: number, sampleTimestamp: Date}>
2457
- getRaw(options?: { channel?: number }): Promise<any>
217
+ export interface SprayFeature {
218
+ set(options: { channel?: number; mode: number }): Promise<any>;
219
+ get(options?: { channel?: number }): Promise<any>;
220
+ getMode(options?: { channel?: number }): number | null;
2458
221
  }
2459
222
 
2460
- /**
2461
- * Timer feature interface.
2462
- *
2463
- * Provides control over device timers.
2464
- */
2465
- export interface TimerFeature {
2466
- set(options: {
2467
- channel?: number;
2468
- timerId?: string;
2469
- alias?: string;
2470
- time?: string;
2471
- days?: string[];
2472
- on?: boolean;
2473
- enabled?: boolean;
2474
- type?: number;
2475
- timerx?: any;
2476
- }): Promise<any>
2477
- get(options?: { channel?: number; timerId?: string }): Promise<any>
2478
- delete(options: { timerId: string; channel?: number }): Promise<any>
2479
- findByAlias(options: { alias: string; channel?: number }): Promise<any>
2480
- deleteByAlias(options: { alias: string; channel?: number }): Promise<any>
2481
- enableByAlias(options: { alias: string; channel?: number }): Promise<any>
2482
- disableByAlias(options: { alias: string; channel?: number }): Promise<any>
2483
- deleteAll(options?: { channel?: number }): Promise<any>
223
+ export interface DiffuserFeature {
224
+ set(options?: Record<string, any>): Promise<any>;
225
+ get(options?: { channel?: number; type?: 'light' | 'spray' }): Promise<any>;
226
+ getLight(options?: { channel?: number }): Promise<any>;
227
+ getSpray(options?: { channel?: number }): Promise<any>;
228
+ getSensor(options?: Record<string, any>): Promise<any>;
229
+ setSensor(options?: Record<string, any>): Promise<any>;
2484
230
  }
2485
231
 
2486
- /**
2487
- * Trigger feature interface.
2488
- *
2489
- * Provides control over device triggers.
2490
- */
2491
- export interface TriggerFeature {
2492
- set(options: {
2493
- channel?: number;
2494
- triggerId?: string;
2495
- alias?: string;
2496
- duration?: string;
2497
- days?: string[];
2498
- type?: number;
2499
- enabled?: boolean;
2500
- triggerx?: any;
2501
- }): Promise<any>
2502
- get(options?: { channel?: number }): Promise<any>
2503
- delete(options: { triggerId: string; channel?: number }): Promise<any>
2504
- findByAlias(options: { alias: string; channel?: number }): Promise<any>
2505
- deleteByAlias(options: { alias: string; channel?: number }): Promise<any>
2506
- enableByAlias(options: { alias: string; channel?: number }): Promise<any>
2507
- disableByAlias(options: { alias: string; channel?: number }): Promise<any>
2508
- deleteAll(options?: { channel?: number }): Promise<any>
232
+ export interface DeviceCapabilities {
233
+ channels?: {
234
+ ids: number[];
235
+ count: number;
236
+ };
237
+ [key: string]: any;
2509
238
  }
2510
239
 
2511
- /**
2512
- * Presence sensor feature interface.
2513
- *
2514
- * Provides access to presence detection and light sensor data.
2515
- */
2516
- export interface PresenceSensorFeature {
2517
- get(options?: { channel?: number; dataTypes?: string[] }): Promise<PresenceSensorState | undefined>
2518
- getPresence(options?: { channel?: number }): { value: number; isPresent: boolean; state: number; distance: number; distanceRaw: number; timestamp: number; times: number } | null
2519
- isPresent(options?: { channel?: number }): boolean | null
2520
- getLight(options?: { channel?: number }): { value: number; timestamp: number } | null
2521
- getAllSensorReadings(options?: { channel?: number }): { presence: Record<string, any> | null; light: Record<string, any> | null }
2522
- getConfig(options?: { channel?: number }): Promise<any>
2523
- setConfig(options: { configData: any }): Promise<any>
2524
- getStudy(options?: { channel?: number }): Promise<any>
2525
- setStudy(options: { studyData: any }): Promise<any>
240
+ export interface PresenceFeature {
241
+ get(options?: { channel?: number }): Promise<any>;
242
+ getConfig(options?: { channel?: number }): Promise<any>;
243
+ setConfig(options?: Record<string, any>): Promise<any>;
2526
244
  }
2527
245
 
2528
- /**
2529
- * Alarm feature interface.
2530
- *
2531
- * Provides access to alarm events and status.
2532
- */
2533
246
  export interface AlarmFeature {
2534
- set(options: { channel?: number, on: boolean, duration?: number }): Promise<any>
2535
- setConfig(options: { channel?: number, enable: number, volume: number, song: number }): Promise<any>
2536
- get(options?: { channel?: number }): Promise<any>
2537
- getLastEvents(options?: { channel?: number }): Array<{timestamp: number, type: string, data: any}>
247
+ get(options?: { channel?: number }): Promise<any>;
248
+ getLastEvents(): any[];
2538
249
  }
2539
250
 
2540
- /**
2541
- * Child lock feature interface.
2542
- *
2543
- * Provides control over child lock settings.
2544
- */
2545
- export interface ChildLockFeature {
2546
- set(options: { lockData: any }): Promise<any>
2547
- get(): Promise<any>
251
+ export interface RuntimeFeature {
252
+ get(): Promise<any>;
253
+ getCached(): any;
2548
254
  }
2549
255
 
2550
- /**
2551
- * Screen feature interface.
2552
- *
2553
- * Provides control over device screen settings.
2554
- */
2555
256
  export interface ScreenFeature {
2556
- set(options: { screenData: any }): Promise<any>
2557
- get(): Promise<any>
257
+ set(options?: Record<string, any>): Promise<any>;
258
+ get(options?: { channel?: number }): Promise<any>;
2558
259
  }
2559
260
 
2560
- /**
2561
- * Runtime feature interface.
2562
- *
2563
- * Provides access to device runtime information.
2564
- */
2565
- export interface RuntimeFeature {
2566
- get(): Promise<any>
2567
- refreshState(): Promise<void>
261
+ export interface DNDFeature {
262
+ set(options?: { mode?: number }): Promise<any>;
263
+ get(options?: Record<string, any>): Promise<any>;
2568
264
  }
2569
265
 
2570
- /**
2571
- * Config feature interface.
2572
- *
2573
- * Provides access to device configuration.
2574
- */
2575
- export interface ConfigFeature {
2576
- set(options: { configData: any }): Promise<any>
2577
- get(_options?: { channel?: number }): Promise<any>
266
+ export interface ChildLockFeature {
267
+ set(options?: { channel?: number; lock?: number | boolean }): Promise<any>;
268
+ get(options?: { channel?: number }): Promise<any>;
2578
269
  }
2579
270
 
2580
- /**
2581
- * DND (Do Not Disturb) feature interface.
2582
- *
2583
- * Provides control over DND mode.
2584
- */
2585
- export interface DNDFeature {
2586
- set(options: { mode: boolean | number }): Promise<any>
2587
- get(_options?: { channel?: number }): Promise<any>
2588
- getRaw(_options?: { channel?: number }): Promise<any>
271
+ export interface ConfigFeature {
272
+ get(options?: Record<string, any>): Promise<any>;
273
+ set(options?: Record<string, any>): Promise<any>;
2589
274
  }
2590
275
 
2591
- /**
2592
- * Temperature unit feature interface.
2593
- *
2594
- * Provides control over temperature unit settings.
2595
- */
2596
276
  export interface TempUnitFeature {
2597
- set(options: { unit: number }): Promise<any>
2598
- get(): Promise<any>
277
+ set(options?: { channel?: number; unit?: number }): Promise<any>;
278
+ get(options?: { channel?: number }): Promise<any>;
2599
279
  }
2600
280
 
2601
- /**
2602
- * Smoke config feature interface.
2603
- *
2604
- * Provides access to smoke sensor configuration.
2605
- */
2606
281
  export interface SmokeConfigFeature {
2607
- set(options: { channel?: number; subId?: string; configData: any }): Promise<any>
2608
- get(options?: { channel?: number; subId?: string }): Promise<any>
282
+ get(options?: { channel?: number }): Promise<any>;
283
+ set(options?: { channel?: number; status: number }): Promise<any>;
2609
284
  }
2610
285
 
2611
- /**
2612
- * Sensor history feature interface.
2613
- *
2614
- * Provides access to sensor history data.
2615
- */
2616
286
  export interface SensorHistoryFeature {
2617
- get(options: { channel?: number; capacity: number }): Promise<any>
2618
- delete(options: { channel?: number; capacity: number }): Promise<any>
2619
- }
2620
-
2621
- /**
2622
- * Digest timer feature interface.
2623
- *
2624
- * Provides access to timer digest information.
2625
- */
2626
- export interface DigestTimerFeature {
2627
- get(): Promise<any>
287
+ get(options?: { channel?: number }): Promise<any>;
2628
288
  }
2629
289
 
2630
- /**
2631
- * Digest trigger feature interface.
2632
- *
2633
- * Provides access to trigger digest information.
2634
- */
2635
- export interface DigestTriggerFeature {
2636
- get(): Promise<any>
2637
- }
2638
-
2639
- /**
2640
- * Control feature interface.
2641
- *
2642
- * Provides various control functions.
2643
- */
2644
- export interface ControlFeature {
2645
- setMultiple(options: { channel?: number; payload: any }): Promise<any>
2646
- acknowledgeOverTemp(options: { channel?: number }): Promise<any>
2647
- setUpgrade(options: { channel?: number; upgradeData: any }): Promise<any>
2648
- }
2649
-
2650
-
2651
- /**
2652
- * Hub feature interface.
2653
- *
2654
- * Provides functionality for hub devices including sensor management and MTS100 thermostat control.
2655
- */
2656
- export interface HubFeature {
2657
- refreshState(): Promise<void>
2658
- getBattery(): Promise<any>
2659
- /**
2660
- * Controls a hub toggleX subdevice (on/off).
2661
- *
2662
- * @param options - Toggle options
2663
- * @param options.subId - Subdevice ID
2664
- * @param options.on - True to turn on, false to turn off
2665
- */
2666
- setToggle(options: { subId: string; on: boolean }): Promise<any>
2667
- getAllSensors(sensorIds?: string[]): Promise<any>
2668
- getMts100All(options?: { ids?: string[] }): Promise<any>
2669
- getException(): Promise<any>
2670
- getLatestSensorReadings(options?: { sensorIds?: string[]; dataTypes?: string[] }): Promise<any>
290
+ export interface SystemFeature {
291
+ getAllData(): Promise<any>;
292
+ getDebug(): Promise<any>;
293
+ getAbilities(): Promise<any>;
294
+ getEncryptSuite(): Promise<any>;
295
+ getEncryptECDHE(): Promise<any>;
296
+ getOnlineStatus(): Promise<any>;
297
+ getConfigWifiList(): Promise<any>;
298
+ getConfigTrace(): Promise<any>;
299
+ getHardware(): Promise<any>;
300
+ getFirmware(): Promise<any>;
301
+ getTime(): Promise<any>;
302
+ getPosition(): Promise<any>;
303
+ getFactory(): Promise<any>;
304
+ getLedMode(): Promise<any>;
305
+ setLedMode(options: { mode: number }): Promise<any>;
306
+ getMcuFirmware(): Promise<any>;
2671
307
  }
2672
308
 
2673
- /**
2674
- * Represents a Meross device.
2675
- *
2676
- * Provides methods to control and query Meross devices. Devices are automatically
2677
- * initialized when the manager connects. This class extends EventEmitter and emits
2678
- * events for device state changes and connection status.
2679
- *
2680
- * @example
2681
- * ```typescript
2682
- * const device = manager.devices.get('device-uuid');
2683
- *
2684
- * device.on('connected', () => {
2685
- * console.log('Device connected');
2686
- * });
2687
- *
2688
- * device.on('state', (event) => {
2689
- * if (event.type === 'toggle') {
2690
- * console.log('Toggle state changed:', event.value);
2691
- * }
2692
- * });
2693
- *
2694
- * await device.toggle.set({ on: true });
2695
- * ```
2696
- */
2697
309
  export class MerossDevice extends EventEmitter {
2698
- /**
2699
- * Registers a handler for state events.
2700
- *
2701
- * Unified event emitted for all device state changes (toggle, light, thermostat, etc.).
2702
- * Use this instead of feature-specific events for consistent state handling.
2703
- *
2704
- * @param event - Event name ('state')
2705
- * @param listener - Callback function receiving state change event
2706
- * @returns This instance for method chaining
2707
- */
2708
- on(event: 'state', listener: (event: {
2709
- type: string;
2710
- channel: number;
2711
- value: any;
2712
- source: string;
2713
- timestamp: number;
2714
- }) => void): this;
2715
-
2716
- /**
2717
- * Registers a handler for connected events.
2718
- *
2719
- * Emitted when the device successfully connects to MQTT.
2720
- *
2721
- * @param event - Event name ('connected')
2722
- * @param listener - Callback function
2723
- * @returns This instance for method chaining
2724
- */
2725
- on(event: 'connected', listener: () => void): this;
2726
-
2727
- /**
2728
- * Registers a handler for disconnected events.
2729
- *
2730
- * Emitted when the device disconnects from MQTT, either intentionally or due to error.
2731
- *
2732
- * @param event - Event name ('disconnected')
2733
- * @param listener - Callback function receiving optional error message
2734
- * @returns This instance for method chaining
2735
- */
2736
- on(event: 'disconnected', listener: (error?: string) => void): this;
2737
-
2738
- /**
2739
- * Registers a handler for reconnected events.
2740
- *
2741
- * Emitted when the MQTT connection is re-established after a disconnection.
2742
- *
2743
- * @param event - Event name ('reconnected')
2744
- * @param listener - Callback function
2745
- * @returns This instance for method chaining
2746
- */
2747
- on(event: 'reconnected', listener: () => void): this;
2748
-
2749
- /**
2750
- * Registers a handler for error events.
2751
- *
2752
- * Emitted when device operations fail or communication errors occur.
2753
- *
2754
- * @param event - Event name ('error')
2755
- * @param listener - Callback function receiving the error
2756
- * @returns This instance for method chaining
2757
- */
2758
- on(event: 'error', listener: (error: Error) => void): this;
2759
-
2760
- /**
2761
- * Connects the device to MQTT.
2762
- *
2763
- * @deprecated Devices are automatically connected by the manager. This method is kept for backward compatibility.
2764
- */
2765
- connect(): void
2766
-
2767
- /**
2768
- * Disconnects the device from MQTT.
2769
- *
2770
- * @param force - Whether to force immediate disconnect
2771
- * @deprecated Use manager.disconnectAll() instead. This method is kept for backward compatibility.
2772
- */
2773
- disconnect(force: boolean): void
2774
-
2775
- /**
2776
- * Sets a known local IP address for the device.
2777
- *
2778
- * This helps the library use LAN HTTP communication when available.
2779
- *
2780
- * @param ip - Local IP address (e.g., '192.168.1.100')
2781
- */
2782
- setKnownLocalIp(ip: string): void
2783
-
2784
- /**
2785
- * Removes the known local IP address.
2786
- *
2787
- * After removal, library will attempt to discover IP via mDNS or use MQTT only.
2788
- */
2789
- removeKnownLocalIp(): void
2790
-
2791
- /**
2792
- * Checks if the device supports encryption.
2793
- *
2794
- * Some newer devices require encryption for local communication.
2795
- *
2796
- * @returns True if encryption is supported
2797
- */
2798
- supportEncryption(): boolean
2799
-
2800
- /**
2801
- * Checks if an encryption key is set for this device.
2802
- *
2803
- * Encryption key must be set before communicating with encrypted devices.
2804
- *
2805
- * @returns True if encryption key is set
2806
- */
2807
- isEncryptionKeySet(): boolean
2808
-
2809
- /**
2810
- * Sets the encryption key for this device.
2811
- *
2812
- * Required for devices that support encryption. Key is typically obtained from
2813
- * device discovery or Meross app. Without this key, encrypted devices cannot communicate.
2814
- *
2815
- * @param uuid - Device UUID
2816
- * @param mrskey - Encryption key
2817
- * @param mac - MAC address
2818
- */
2819
- setEncryptionKey(uuid: string, mrskey: string, mac: string): void
2820
-
2821
- /**
2822
- * Encrypts a message for this device.
2823
- *
2824
- * @param messageData - Message data to encrypt
2825
- * @returns Encrypted message string
2826
- */
2827
- encryptMessage(messageData: string | Buffer): string
2828
-
2829
- /**
2830
- * Decrypts a message from this device.
2831
- *
2832
- * @param encryptedData - Encrypted message data
2833
- * @returns Decrypted message buffer
2834
- */
2835
- decryptMessage(encryptedData: string | Buffer): Buffer
2836
-
2837
- /**
2838
- * Updates device abilities.
2839
- *
2840
- * @param abilities - Abilities object containing supported features
2841
- */
2842
- updateAbilities(abilities: Record<string, any>): void
2843
-
2844
- /**
2845
- * Updates the device MAC address.
2846
- *
2847
- * @param mac - MAC address string
2848
- */
2849
- updateMacAddress(mac: string): void
2850
-
2851
- readonly macAddress: string | null
2852
- readonly firmwareVersion: string
2853
- readonly hardwareVersion: string
2854
- readonly lanIp: string | null
2855
- readonly mqttHost: string | null
2856
- readonly mqttPort: number | null
2857
- /** Signal strength percentage (1-100) from Appliance.System.Runtime. Available on production firmware. */
2858
- readonly signalStrength: number | null
2859
- /** Device capabilities object containing supported features and namespaces */
2860
- readonly abilities: Record<string, any> | null
2861
- /** Normalized device capabilities map for easy feature discovery without namespace knowledge */
2862
- readonly capabilities: DeviceCapabilities | null
2863
- /** Unix timestamp of last full state refresh */
2864
- readonly lastFullUpdateTimestamp: number | null
2865
- /** Online status: 0=connecting, 1=online, 2=offline, -1=unknown, 3=upgrading */
2866
- readonly onlineStatus: number
2867
- readonly isOnline: boolean
2868
- readonly internalId: string
2869
- readonly channels: ChannelInfo[]
2870
- /** Fallback MQTT domain used if primary domain fails */
2871
- readonly reservedDomain: string | null
2872
- readonly subType: string | null
2873
- readonly bindTime: Date | null
2874
- readonly skillNumber: string | null
2875
- readonly userDevIcon: string | null
2876
- readonly iconType: number | null
2877
- readonly region: string | null
2878
- readonly devIconId: string | null
2879
-
2880
- /**
2881
- * Refreshes device state by querying the device.
2882
- *
2883
- * Forces a fresh state fetch from the device, bypassing cache. Useful when
2884
- * you need to ensure you have the latest state.
2885
- *
2886
- * @param timeout - Optional timeout in milliseconds
2887
- * @returns Promise that resolves when state is refreshed
2888
- */
2889
- refreshState(timeout?: number): Promise<void>
2890
-
2891
- /**
2892
- * Feature objects for device control.
2893
- *
2894
- * Each feature provides methods to control specific device capabilities.
2895
- * Features are only available if the device supports them.
2896
- */
2897
- readonly system: SystemFeature
2898
- readonly encryption: EncryptionFeature
2899
- readonly toggle: ToggleFeature
2900
- readonly light: LightFeature
2901
- readonly thermostat: ThermostatFeature
2902
- readonly rollerShutter: RollerShutterFeature
2903
- readonly garage: GarageFeature
2904
- readonly diffuser: DiffuserFeature
2905
- readonly spray: SprayFeature
2906
- readonly consumption: ConsumptionFeature
2907
- readonly electricity: ElectricityFeature
2908
- readonly timer: TimerFeature
2909
- readonly trigger: TriggerFeature
2910
- readonly presence: PresenceSensorFeature
2911
- readonly alarm: AlarmFeature
2912
- readonly childLock: ChildLockFeature
2913
- readonly screen: ScreenFeature
2914
- readonly runtime: RuntimeFeature
2915
- readonly config: ConfigFeature
2916
- readonly dnd: DNDFeature
2917
- readonly tempUnit: TempUnitFeature
2918
- readonly smokeConfig: SmokeConfigFeature
2919
- readonly sensorHistory: SensorHistoryFeature
2920
- readonly digestTimer: DigestTimerFeature
2921
- readonly digestTrigger: DigestTriggerFeature
2922
- readonly control: ControlFeature
2923
-
2924
- /**
2925
- * Looks up channel information by ID or name.
2926
- *
2927
- * Useful for finding channel details when you only have an index or name.
2928
- *
2929
- * @param channelIdOrName - Channel index or name
2930
- * @returns ChannelInfo instance
2931
- * @throws {MerossErrorNotFound} If channel not found
2932
- */
2933
- lookupChannel(channelIdOrName: number | string): ChannelInfo
2934
-
2935
- /**
2936
- * Updates device state from HTTP device info.
2937
- *
2938
- * Called internally when device information is refreshed from the HTTP API.
2939
- * Updates device metadata and connection information.
2940
- *
2941
- * @param deviceInfo - HTTP device information
2942
- * @returns Promise resolving to this device instance
2943
- */
2944
- updateFromHttpState(deviceInfo: HttpDeviceInfo): Promise<MerossDevice>
2945
-
2946
- /**
2947
- * Publishes a message to the device.
2948
- *
2949
- * Low-level method for sending raw messages. Typically not needed by users;
2950
- * use feature methods (e.g., `toggle.set()`) instead.
2951
- *
2952
- * @param method - Message method ('GET' or 'SET')
2953
- * @param namespace - Namespace for the message
2954
- * @param payload - Message payload
2955
- * @returns Promise resolving to device response
2956
- */
2957
- publishMessage(method: 'GET' | 'SET', namespace: string, payload: any): Promise<any>
2958
- }
2959
-
2960
- export class MerossSubDevice extends MerossDevice {
2961
- /**
2962
- * Registers a handler for subdevice notification events.
2963
- *
2964
- * Emitted when the hub receives a notification specifically for this subdevice.
2965
- *
2966
- * @param event - Event name ('subdeviceNotification')
2967
- * @param listener - Callback function receiving namespace and data
2968
- * @returns This instance for method chaining
2969
- */
2970
- on(event: 'subdeviceNotification', listener: (namespace: string, data: any) => void): this;
2971
- /**
2972
- * Registers a handler for state events.
2973
- *
2974
- * Unified event for all device state changes (toggle, light, thermostat, etc.).
2975
- *
2976
- * @param event - Event name ('state')
2977
- * @param listener - Callback function receiving state change event
2978
- * @returns This instance for method chaining
2979
- */
2980
- on(event: 'state', listener: (event: {
2981
- type: string;
2982
- channel: number;
2983
- value: any;
2984
- source: string;
2985
- timestamp: number;
2986
- }) => void): this;
2987
- /**
2988
- * Registers a handler for connected events.
2989
- *
2990
- * @param event - Event name ('connected')
2991
- * @param listener - Callback function
2992
- * @returns This instance for method chaining
2993
- */
2994
- on(event: 'connected', listener: () => void): this;
2995
- /**
2996
- * Registers a handler for disconnected events.
2997
- *
2998
- * @param event - Event name ('disconnected')
2999
- * @param listener - Callback function receiving optional error
3000
- * @returns This instance for method chaining
3001
- */
3002
- on(event: 'disconnected', listener: (error?: string) => void): this;
3003
- /**
3004
- * Registers a handler for reconnected events.
3005
- *
3006
- * Emitted when the MQTT connection is re-established after a disconnection.
3007
- *
3008
- * @param event - Event name ('reconnected')
3009
- * @param listener - Callback function
3010
- * @returns This instance for method chaining
3011
- */
3012
- on(event: 'reconnected', listener: () => void): this;
3013
- /**
3014
- * Registers a handler for error events.
3015
- *
3016
- * @param event - Event name ('error')
3017
- * @param listener - Callback function receiving the error
3018
- * @returns This instance for method chaining
3019
- */
3020
- on(event: 'error', listener: (error: Error) => void): this;
3021
-
3022
- readonly subdeviceId: string
3023
- readonly hub: MerossHubDevice
3024
- readonly type: string
3025
- readonly name: string
3026
- handleSubdeviceNotification(namespace: string, data: any): Promise<void>
3027
- }
3028
-
3029
- export class HubTempHumSensor extends MerossSubDevice {
3030
- getLastSampledTemperature(): number | null
3031
- getLastSampledHumidity(): number | null
3032
- getLastSampledTime(): Date | null
3033
- getMinSupportedTemperature(): number | null
3034
- getMaxSupportedTemperature(): number | null
3035
- getLux(): number | null
3036
- }
3037
-
3038
- export class HubThermostatValve extends MerossSubDevice {
3039
- /**
3040
- * Note: This class inherits a `toggle` property (ToggleFeature) from MerossDevice.
3041
- * The runtime implementation also has a `toggle()` convenience method, but it's not
3042
- * available in TypeScript due to the property/method conflict. Use `toggle.set()` instead.
3043
- */
3044
- isOn(): boolean
3045
- getMode(): number | undefined
3046
- setMode(mode: number): Promise<void>
3047
- getTargetTemperature(): number | null
3048
- setTargetTemperature(temperature: number): Promise<void>
3049
- getLastSampledTemperature(): number | null
3050
- getMinSupportedTemperature(): number | null
3051
- getMaxSupportedTemperature(): number | null
3052
- isHeating(): boolean
3053
- isWindowOpen(): boolean
3054
- getSupportedPresets(): string[]
3055
- getPresetTemperature(preset: string): number | null
3056
- setPresetTemperature(preset: string, temperature: number): Promise<void>
3057
- getAdjust(): number | null
3058
- setAdjust(temperature: number): Promise<void>
3059
- }
3060
-
3061
- export class HubWaterLeakSensor extends MerossSubDevice {
3062
- isLeaking(): boolean | null
3063
- getLatestSampleTime(): number | null
3064
- getLatestDetectedWaterLeakTs(): number | null
3065
- getLastEvents(): Array<{ leaking: boolean, timestamp: number }>
3066
- }
3067
-
3068
- export class HubSmokeDetector extends MerossSubDevice {
3069
- getSmokeAlarmStatus(): number | null
3070
- getInterConnStatus(): number | null
3071
- getLastStatusUpdate(): number | null
3072
- muteAlarm(muteSmoke?: boolean): Promise<any>
3073
- getTestEvents(): Array<{ type: number, timestamp: number }>
3074
- refreshAlarmStatus(): Promise<any>
3075
- }
3076
-
310
+ readonly uuid: string;
311
+ readonly name: string;
312
+ readonly deviceType: string;
313
+ readonly onlineStatus: number;
314
+ readonly deviceConnected: boolean;
315
+ readonly capabilities: DeviceCapabilities | null;
316
+ getChannelIds(): number[];
317
+ readonly toggle?: ToggleFeature;
318
+ readonly light?: LightFeature;
319
+ readonly thermostat?: ThermostatFeature;
320
+ readonly rollerShutter?: RollerShutterFeature;
321
+ readonly garage?: GarageFeature;
322
+ readonly electricity?: ElectricityFeature;
323
+ readonly consumption?: ConsumptionFeature;
324
+ readonly spray?: SprayFeature;
325
+ readonly diffuser?: DiffuserFeature;
326
+ readonly presence?: PresenceFeature;
327
+ readonly alarm?: AlarmFeature;
328
+ readonly runtime?: RuntimeFeature;
329
+ readonly screen?: ScreenFeature;
330
+ readonly dnd?: DNDFeature;
331
+ readonly childLock?: ChildLockFeature;
332
+ readonly config?: ConfigFeature;
333
+ readonly tempUnit?: TempUnitFeature;
334
+ readonly smokeConfig?: SmokeConfigFeature;
335
+ readonly sensorHistory?: SensorHistoryFeature;
336
+ readonly system?: SystemFeature;
337
+ readonly timer?: TimerFeature;
338
+ readonly trigger?: TriggerFeature;
339
+ readonly [key: string]: any;
340
+ }
341
+
342
+ export class MerossSubDevice extends MerossDevice {}
3077
343
  export class MerossHubDevice extends MerossDevice {
3078
- /**
3079
- * Hub feature for hub-specific functionality.
3080
- */
3081
- readonly hub: HubFeature
3082
-
3083
- getSubdevices(): MerossSubDevice[]
3084
- getSubdevice(subdeviceId: string): MerossSubDevice | null
3085
- registerSubdevice(subdevice: MerossSubDevice): void
3086
- getHubBattery(): Promise<any>
3087
- getHubSubdeviceList(): Promise<any>
3088
- getHubOnline(): Promise<any>
3089
- getHubException(): Promise<any>
3090
- getHubReport(): Promise<any>
3091
- setHubPairSubDev(): Promise<any>
3092
- setHubSubDeviceBeep(subIds: string | string[], onoff: boolean): Promise<any>
3093
- getHubSubDeviceBeep(subIds: string | string[]): Promise<any>
3094
- getHubSubDeviceMotorAdjust(subIds: string | string[]): Promise<any>
3095
- setHubSubDeviceMotorAdjust(adjustData: any): Promise<any>
3096
- getHubSubDeviceVersion(subIds?: string[]): Promise<any>
3097
- getAllSensors(sensorIds: string[] | string): Promise<any>
3098
- getLatestHubSensorReadings(sensorIds: string[] | string, dataTypes?: string[]): Promise<any>
3099
- getTempHumSensor(sensorIds: string[] | string): Promise<any>
3100
- getAlertSensor(sensorIds: string[] | string): Promise<any>
3101
- getSmokeAlarmStatus(sensorIds: string[] | string): Promise<any>
3102
- getWaterLeakSensor(sensorIds: string[] | string): Promise<any>
3103
- getHubSensorAdjust(sensorIds?: string[]): Promise<any>
3104
- setHubSensorAdjust(adjustData: any): Promise<any>
3105
- getHubSensorDoorWindow(sensorIds?: string[]): Promise<any>
3106
- setHubSensorDoorWindow(doorWindowData: any): Promise<any>
3107
- getMts100All(ids: string[] | string): Promise<any>
3108
- setHubToggleX(subId: string, onoff: boolean): Promise<any>
3109
- setHubMts100Mode(subId: string, mode: number): Promise<any>
3110
- setHubMts100Temperature(subId: string, temp: any): Promise<any>
3111
- setHubMts100Adjust(subId: string, adjustData: any): Promise<any>
3112
- getMts100Adjust(ids: string[] | string): Promise<any>
3113
- getMts100SuperCtl(ids: string[] | string): Promise<any>
3114
- getMts100ScheduleB(ids: string[] | string): Promise<any>
3115
- getMts100Config(ids: string[] | string): Promise<any>
3116
- }
3117
-
3118
- /**
3119
- * Base error class for all Meross errors.
3120
- *
3121
- * All library-specific errors extend this class to enable instanceof checks
3122
- * and consistent error handling throughout the library.
3123
- */
3124
- export class MerossError extends Error {
3125
- /** String identifier for the error type */
3126
- code: string
3127
- /** API error code (if available) */
3128
- errorCode: number | null
3129
- /** Whether this is an operational (recoverable) error */
3130
- isOperational: boolean
3131
- /** The underlying error that caused this error (error chaining) */
3132
- cause?: Error | null
3133
- constructor(message: string, errorCode?: number | null, options?: {
3134
- code?: string
3135
- isOperational?: boolean
3136
- cause?: Error | null
3137
- })
3138
- /** Returns a JSON-serializable representation of the error */
3139
- toJSON(): {
3140
- name: string
3141
- code: string
3142
- message: string
3143
- errorCode?: number
3144
- isOperational?: boolean
3145
- }
3146
- }
3147
-
3148
- /**
3149
- * HTTP API error.
3150
- *
3151
- * Thrown when an HTTP request to the Meross API fails or returns an error response.
3152
- */
3153
- export class MerossErrorHttpApi extends MerossError {
3154
- /** HTTP status code (if available) */
3155
- httpStatusCode: number | null
3156
- constructor(message?: string, errorCode?: number | null, httpStatusCode?: number | null, options?: {
3157
- code?: string
3158
- isOperational?: boolean
3159
- cause?: Error | null
3160
- })
3161
- toJSON(): {
3162
- name: string
3163
- code: string
3164
- message: string
3165
- errorCode?: number
3166
- isOperational?: boolean
3167
- httpStatusCode?: number
3168
- }
3169
- }
3170
-
3171
- /**
3172
- * Authentication error.
3173
- *
3174
- * Thrown when authentication fails due to invalid credentials or account issues.
3175
- */
3176
- export class MerossErrorAuthentication extends MerossError {
3177
- constructor(message?: string, errorCode?: number, options?: {
3178
- code?: string
3179
- isOperational?: boolean
3180
- cause?: Error | null
3181
- })
3182
- }
3183
-
3184
- /**
3185
- * MFA required error.
3186
- *
3187
- * Thrown when multi-factor authentication is required but not provided.
3188
- */
3189
- export class MerossErrorMFARequired extends MerossErrorAuthentication {
3190
- constructor(message?: string, options?: {
3191
- code?: string
3192
- isOperational?: boolean
3193
- cause?: Error | null
3194
- })
3195
- }
3196
-
3197
- /**
3198
- * Missing MFA error.
3199
- *
3200
- * Thrown when MFA is required but the code was not provided.
3201
- */
3202
- export class MerossErrorMissingMFA extends MerossErrorMFARequired {
3203
- constructor(message?: string, options?: {
3204
- code?: string
3205
- isOperational?: boolean
3206
- cause?: Error | null
3207
- })
3208
- }
3209
-
3210
- /**
3211
- * Wrong MFA error.
3212
- *
3213
- * Thrown when an incorrect MFA code is provided.
3214
- */
3215
- export class MerossErrorWrongMFA extends MerossErrorAuthentication {
3216
- constructor(message?: string, options?: {
3217
- code?: string
3218
- isOperational?: boolean
3219
- cause?: Error | null
3220
- })
3221
- }
3222
-
3223
- /**
3224
- * Token expired error.
3225
- *
3226
- * Thrown when the authentication token has expired and needs to be refreshed.
3227
- */
3228
- export class MerossErrorTokenExpired extends MerossError {
3229
- constructor(message?: string, errorCode?: number, options?: {
3230
- code?: string
3231
- isOperational?: boolean
3232
- cause?: Error | null
3233
- })
3234
- }
3235
-
3236
- /**
3237
- * Too many tokens error.
3238
- *
3239
- * Thrown when the maximum number of active tokens has been reached.
3240
- */
3241
- export class MerossErrorTooManyTokens extends MerossError {
3242
- constructor(message?: string, options?: {
3243
- code?: string
3244
- isOperational?: boolean
3245
- cause?: Error | null
3246
- })
3247
- }
3248
-
3249
- /**
3250
- * Unauthorized error.
3251
- *
3252
- * Thrown when authentication is required but not provided or invalid.
3253
- */
3254
- export class MerossErrorUnauthorized extends MerossErrorHttpApi {
3255
- constructor(message?: string, errorCode?: number | null, httpStatusCode?: number, options?: {
3256
- code?: string
3257
- isOperational?: boolean
3258
- cause?: Error | null
3259
- })
3260
- }
3261
-
3262
- /**
3263
- * Bad domain error.
3264
- *
3265
- * Thrown when the API or MQTT domain is incorrect or unreachable.
3266
- */
3267
- export class MerossErrorBadDomain extends MerossError {
3268
- /** API domain that failed */
3269
- apiDomain: string | null
3270
- /** MQTT domain that failed */
3271
- mqttDomain: string | null
3272
- constructor(message?: string, apiDomain?: string | null, mqttDomain?: string | null, options?: {
3273
- code?: string
3274
- isOperational?: boolean
3275
- cause?: Error | null
3276
- })
3277
- toJSON(): {
3278
- name: string
3279
- code: string
3280
- message: string
3281
- errorCode?: number
3282
- isOperational?: boolean
3283
- apiDomain?: string
3284
- mqttDomain?: string
3285
- }
3286
- }
3287
-
3288
- /**
3289
- * API limit reached error.
3290
- *
3291
- * Thrown when the API rate limit has been exceeded.
3292
- */
3293
- export class MerossErrorApiLimitReached extends MerossError {
3294
- constructor(message?: string, options?: {
3295
- code?: string
3296
- isOperational?: boolean
3297
- cause?: Error | null
3298
- })
3299
- }
3300
-
3301
- /**
3302
- * Resource access denied error.
3303
- *
3304
- * Thrown when access to a resource is denied due to insufficient permissions.
3305
- */
3306
- export class MerossErrorResourceAccessDenied extends MerossError {
3307
- constructor(message?: string, options?: {
3308
- code?: string
3309
- isOperational?: boolean
3310
- cause?: Error | null
3311
- })
3312
- }
3313
-
3314
- /**
3315
- * Command timeout error.
3316
- *
3317
- * Thrown when a device command doesn't receive a response within the timeout period.
3318
- */
3319
- export class MerossErrorCommandTimeout extends MerossError {
3320
- /** UUID of the device that timed out */
3321
- deviceUuid: string | null
3322
- /** Timeout duration in milliseconds */
3323
- timeout: number | null
3324
- /** Command information */
3325
- command: any
3326
- constructor(message?: string, deviceUuid?: string | null, timeout?: number | null, command?: any, options?: {
3327
- code?: string
3328
- isOperational?: boolean
3329
- cause?: Error | null
3330
- })
3331
- toJSON(): {
3332
- name: string
3333
- code: string
3334
- message: string
3335
- errorCode?: number
3336
- isOperational?: boolean
3337
- deviceUuid?: string
3338
- timeout?: number
3339
- command?: any
3340
- }
3341
- }
3342
-
3343
- /**
3344
- * Command error.
3345
- *
3346
- * Thrown when a device command fails and the device returns an error response.
3347
- */
3348
- export class MerossErrorCommand extends MerossError {
3349
- /** Error payload from device response */
3350
- errorPayload: any
3351
- /** UUID of the device that returned the error */
3352
- deviceUuid: string | null
3353
- constructor(message?: string, errorPayload?: any, deviceUuid?: string | null, options?: {
3354
- code?: string
3355
- isOperational?: boolean
3356
- cause?: Error | null
3357
- })
3358
- toJSON(): {
3359
- name: string
3360
- code: string
3361
- message: string
3362
- errorCode?: number
3363
- isOperational?: boolean
3364
- errorPayload?: any
3365
- deviceUuid?: string
3366
- }
3367
- }
3368
-
3369
- /**
3370
- * MQTT error.
3371
- *
3372
- * Thrown when MQTT connection or communication fails.
3373
- */
3374
- export class MerossErrorMqtt extends MerossError {
3375
- /** MQTT topic related to the error */
3376
- topic: string | null
3377
- /** MQTT message related to the error */
3378
- mqttMessage: any
3379
- constructor(message?: string, topic?: string | null, mqttMessage?: any, options?: {
3380
- code?: string
3381
- isOperational?: boolean
3382
- cause?: Error | null
3383
- })
3384
- toJSON(): {
3385
- name: string
3386
- code: string
3387
- message: string
3388
- errorCode?: number
3389
- isOperational?: boolean
3390
- topic?: string
3391
- mqttMessage?: any
3392
- }
3393
- }
3394
-
3395
- /**
3396
- * Unconnected error.
3397
- *
3398
- * Thrown when attempting to send a command to a device that is not connected.
3399
- */
3400
- export class MerossErrorUnconnected extends MerossError {
3401
- /** UUID of the device that is not connected */
3402
- deviceUuid: string | null
3403
- constructor(message?: string, deviceUuid?: string | null, options?: {
3404
- code?: string
3405
- isOperational?: boolean
3406
- cause?: Error | null
3407
- })
3408
- toJSON(): {
3409
- name: string
3410
- code: string
3411
- message: string
3412
- errorCode?: number
3413
- isOperational?: boolean
3414
- deviceUuid?: string
3415
- }
3416
- }
3417
-
3418
- /**
3419
- * Unknown device type error.
3420
- *
3421
- * Thrown when a device operation is attempted on a device type that doesn't support it.
3422
- */
3423
- export class MerossErrorUnknownDeviceType extends MerossError {
3424
- /** Device type that is unsupported */
3425
- deviceType: string | null
3426
- constructor(message?: string, deviceType?: string | null, options?: {
3427
- code?: string
3428
- isOperational?: boolean
3429
- cause?: Error | null
3430
- })
3431
- toJSON(): {
3432
- name: string
3433
- code: string
3434
- message: string
3435
- errorCode?: number
3436
- isOperational?: boolean
3437
- deviceType?: string
3438
- }
3439
- }
3440
-
3441
- /**
3442
- * Validation error.
3443
- *
3444
- * Thrown when function arguments are invalid, missing required parameters,
3445
- * or have incorrect types/values. Indicates a programming error.
3446
- */
3447
- export class MerossErrorValidation extends MerossError {
3448
- /** The field/parameter that failed validation */
3449
- field: string | null
3450
- constructor(message?: string, field?: string | null, options?: {
3451
- code?: string
3452
- isOperational?: boolean
3453
- cause?: Error | null
3454
- })
3455
- toJSON(): {
3456
- name: string
3457
- code: string
3458
- message: string
3459
- errorCode?: number
3460
- isOperational?: boolean
3461
- field?: string
3462
- }
3463
- }
3464
-
3465
- /**
3466
- * Resource not found error.
3467
- *
3468
- * Thrown when a requested resource (device, channel, trigger, timer, etc.)
3469
- * cannot be found. Indicates the resource doesn't exist or is not accessible.
3470
- */
3471
- export class MerossErrorNotFound extends MerossError {
3472
- /** Type of resource that was not found (e.g., 'device', 'channel') */
3473
- resourceType: string | null
3474
- /** Identifier of the resource that was not found */
3475
- resourceId: string | null
3476
- constructor(message?: string, resourceType?: string | null, resourceId?: string | null, options?: {
3477
- code?: string
3478
- isOperational?: boolean
3479
- cause?: Error | null
3480
- })
3481
- toJSON(): {
3482
- name: string
3483
- code: string
3484
- message: string
3485
- errorCode?: number
3486
- isOperational?: boolean
3487
- resourceType?: string
3488
- resourceId?: string
3489
- }
3490
- }
3491
-
3492
- /**
3493
- * Network/HTTP request timeout error.
3494
- *
3495
- * Thrown when an HTTP or network request times out before receiving a response.
3496
- * Different from CommandTimeoutError which is for device command timeouts.
3497
- */
3498
- export class MerossErrorNetworkTimeout extends MerossError {
3499
- /** Timeout duration in milliseconds */
3500
- timeout: number | null
3501
- /** URL or endpoint that timed out */
3502
- url: string | null
3503
- constructor(message?: string, timeout?: number | null, url?: string | null, options?: {
3504
- code?: string
3505
- isOperational?: boolean
3506
- cause?: Error | null
3507
- })
3508
- toJSON(): {
3509
- name: string
3510
- code: string
3511
- message: string
3512
- errorCode?: number
3513
- isOperational?: boolean
3514
- timeout?: number
3515
- url?: string
3516
- }
3517
- }
3518
-
3519
- /**
3520
- * Parse/serialization error.
3521
- *
3522
- * Thrown when data parsing fails (e.g., JSON parsing, protocol parsing).
3523
- * Indicates data corruption, protocol mismatch, or malformed data.
3524
- */
3525
- export class MerossErrorParse extends MerossError {
3526
- /** The data that failed to parse */
3527
- data: any
3528
- /** The expected format (e.g., 'json', 'xml') */
3529
- format: string | null
3530
- constructor(message?: string, data?: any, format?: string | null, options?: {
3531
- code?: string
3532
- isOperational?: boolean
3533
- cause?: Error | null
3534
- })
3535
- toJSON(): {
3536
- name: string
3537
- code: string
3538
- message: string
3539
- errorCode?: number
3540
- isOperational?: boolean
3541
- format?: string
3542
- }
3543
- }
3544
-
3545
- /**
3546
- * Rate limit error (error code 1028).
3547
- *
3548
- * Thrown when requests are made too frequently. Different from ApiLimitReachedError
3549
- * (1042) which indicates the API top limit has been reached.
3550
- */
3551
- export class MerossErrorRateLimit extends MerossError {
3552
- constructor(message?: string, options?: {
3553
- code?: string
3554
- isOperational?: boolean
3555
- cause?: Error | null
3556
- })
3557
- }
3558
-
3559
- /**
3560
- * Operation locked error (error code 1035).
3561
- *
3562
- * Thrown when an operation is locked and cannot be performed at this time.
3563
- * The operation may become available after a delay or when the lock is released.
3564
- */
3565
- export class MerossErrorOperationLocked extends MerossError {
3566
- constructor(message?: string, options?: {
3567
- code?: string
3568
- isOperational?: boolean
3569
- cause?: Error | null
3570
- })
3571
- }
3572
-
3573
- /**
3574
- * Unsupported operation error (error code 20112).
3575
- *
3576
- * Thrown when an operation is not supported by the device, API, or current
3577
- * configuration. Indicates the requested functionality is not available.
3578
- */
3579
- export class MerossErrorUnsupported extends MerossError {
3580
- /** The operation that is unsupported */
3581
- operation: string | null
3582
- /** Reason why the operation is unsupported */
3583
- reason: string | null
3584
- constructor(message?: string, operation?: string | null, reason?: string | null, options?: {
3585
- code?: string
3586
- isOperational?: boolean
3587
- cause?: Error | null
3588
- })
3589
- toJSON(): {
3590
- name: string
3591
- code: string
3592
- message: string
3593
- errorCode?: number
3594
- isOperational?: boolean
3595
- operation?: string
3596
- reason?: string
3597
- }
344
+ getSubdevices(): MerossSubDevice[];
3598
345
  }
346
+ export class HubTempHumSensor extends MerossSubDevice {}
347
+ export class HubThermostatValve extends MerossSubDevice {}
348
+ export class HubWaterLeakSensor extends MerossSubDevice {}
349
+ export class HubSmokeDetector extends MerossSubDevice {}
3599
350
 
3600
- /**
3601
- * Initialization error.
3602
- *
3603
- * Thrown when device or component initialization fails. This may occur due to
3604
- * network issues, missing dependencies, or configuration problems. May be
3605
- * retryable in some cases.
3606
- */
3607
- export class MerossErrorInitialization extends MerossError {
3608
- /** The component that failed to initialize */
3609
- component: string | null
3610
- /** Reason for initialization failure */
3611
- reason: string | null
3612
- constructor(message?: string, component?: string | null, reason?: string | null, options?: {
3613
- code?: string
3614
- isOperational?: boolean
3615
- cause?: Error | null
3616
- })
3617
- toJSON(): {
3618
- name: string
3619
- code: string
3620
- message: string
3621
- errorCode?: number
3622
- isOperational?: boolean
3623
- component?: string
3624
- reason?: string
3625
- }
351
+ export class ManagerDevices {
352
+ get(identifier: string | { hubUuid: string; id: string }): MerossDevice | MerossHubDevice | MerossSubDevice | null;
353
+ list(): Array<MerossDevice | MerossHubDevice | MerossSubDevice>;
354
+ find(filters?: Record<string, any>): Array<MerossDevice | MerossHubDevice | MerossSubDevice>;
355
+ discover(options?: { deviceTypes?: string[]; onlineOnly?: boolean; excludeHubs?: boolean }): Promise<DeviceDefinition[]>;
356
+ discoverSubdevices(options?: { hubUuids?: string[]; subdeviceType?: string; onlineOnly?: boolean }): Promise<SubdeviceInfo[]>;
357
+ initialize(options?: { uuids?: string[] }): Promise<number>;
358
+ initializeDevice(identifier: string | { hubUuid: string; id: string }): Promise<MerossDevice | MerossHubDevice | MerossSubDevice | null>;
359
+ remove(identifier: string | { hubUuid: string; id: string }): Promise<boolean>;
360
+ }
361
+
362
+ export interface ManagerSubscription extends EventEmitter {
363
+ subscribe(device: MerossDevice, config?: Record<string, any>): void;
364
+ unsubscribe(deviceUuid: string): void;
365
+ subscribeToDeviceList(): void;
366
+ unsubscribeFromDeviceList(): void;
367
+ destroy(): void;
3626
368
  }
3627
369
 
3628
- /**
3629
- * Maps error codes to appropriate error classes.
3630
- *
3631
- * Converts API error codes into specific error class instances based on the
3632
- * error code value and context.
3633
- *
3634
- * @param errorCode - The error code from API response
3635
- * @param context - Additional context (info, deviceUuid, httpStatusCode, etc.)
3636
- * @returns Appropriate error instance
3637
- */
3638
- export function mapErrorCodeToError(errorCode: number, context?: {
3639
- info?: string
3640
- deviceUuid?: string
3641
- httpStatusCode?: number
3642
- apiDomain?: string
3643
- mqttDomain?: string
3644
- }): MerossError
370
+ /** HTTP/MQTT diagnostics counters; enable only when needed to limit overhead. */
371
+ export interface ManagerStatistics {
372
+ enable(maxSamples?: number): void;
373
+ disable(): void;
374
+ isEnabled(): boolean;
375
+ getMqttStats(timeWindowMs?: number): any | null;
376
+ getHttpStats(timeWindowMs?: number): any | null;
377
+ getDelayedMqttStats(timeWindowMs?: number): any | null;
378
+ getDroppedMqttStats(timeWindowMs?: number): any | null;
379
+ }
380
+
381
+ /** Public transport preferences on {@link Meross}. */
382
+ export interface ManagerTransport {
383
+ defaultMode: number;
384
+ readonly errorBudgetMaxErrors: number;
385
+ readonly errorBudgetTimeWindow: number;
386
+ getBudget(deviceUuid: string): number;
387
+ resetBudget(deviceUuid: string): void;
388
+ isOutOfBudget(deviceUuid: string): boolean;
389
+ }
390
+
391
+ export interface ManagerAuth {
392
+ readonly token: string | null;
393
+ readonly key: string | null;
394
+ readonly userId: string | null;
395
+ readonly userEmail: string | null;
396
+ readonly httpDomain: string | null;
397
+ readonly authenticated: boolean;
398
+ readonly mqttDomain: string;
399
+ getTokenData(): TokenData | null;
400
+ logout(): Promise<any>;
401
+ }
402
+
403
+ export interface ManagerMqttConnection {
404
+ client?: { connected?: boolean; reconnecting?: boolean; options?: Record<string, any> };
405
+ deviceList?: string[];
406
+ [key: string]: any;
407
+ }
408
+
409
+ /** MQTT broker clients keyed by domain. */
410
+ export interface ManagerMqtt {
411
+ readonly connections: Record<string, ManagerMqttConnection>;
412
+ readonly clientResponseTopic: string | null;
413
+ readonly mqttDomain: string;
414
+ hasConnection(domain: string): boolean;
415
+ getConnection(domain: string): ManagerMqttConnection | null;
416
+ disconnectAll(force?: boolean): void;
417
+ }
418
+
419
+ export class Meross extends EventEmitter {
420
+ /** Same enum as the named {@link TransportMode} export (attached for `Meross.TransportMode` usage). */
421
+ static TransportMode: typeof TransportMode;
422
+
423
+ static authenticate(options: {
424
+ email?: string;
425
+ password?: string;
426
+ mfaCode?: string;
427
+ token?: string;
428
+ key?: string;
429
+ userId?: string;
430
+ domain?: string;
431
+ mqttDomain?: string;
432
+ logger?: Logger;
433
+ }): Promise<Meross>;
3645
434
 
3646
- export default ManagerMeross
435
+ static connect(options: {
436
+ email?: string;
437
+ password?: string;
438
+ mfaCode?: string;
439
+ token?: string;
440
+ key?: string;
441
+ userId?: string;
442
+ domain?: string;
443
+ mqttDomain?: string;
444
+ logger?: Logger;
445
+ }): Promise<Meross>;
446
+
447
+ /** Prefer {@link Meross.authenticate} or {@link Meross.connect}; the HTTP client is not part of the public API. */
448
+ constructor(options: { httpClient: object });
449
+
450
+ readonly auth: ManagerAuth;
451
+ readonly devices: ManagerDevices;
452
+ readonly mqtt: ManagerMqtt;
453
+ readonly subscription: ManagerSubscription;
454
+ readonly transport: ManagerTransport;
455
+ readonly statistics: ManagerStatistics;
456
+ readonly options: { logger?: Logger | null; [key: string]: any };
457
+ readonly authenticated: boolean;
458
+ readonly token: string | null;
459
+ readonly key: string | null;
460
+ readonly userId: string | null;
461
+ readonly userEmail: string | null;
462
+ readonly httpDomain: string | null;
463
+ readonly mqttDomain: string;
464
+ timeout: number;
465
+ logger: Logger | null;
466
+
467
+ connect(): Promise<number>;
468
+ login(): Promise<number>;
469
+ logout(): Promise<any>;
470
+ disconnectAll(force?: boolean): void;
471
+ getTokenData(): TokenData | null;
472
+ }
473
+
474
+ export default Meross;
3647
475
  }