meross-iot 0.1.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 (99) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/LICENSE +21 -0
  3. package/README.md +153 -0
  4. package/index.d.ts +2344 -0
  5. package/index.js +131 -0
  6. package/lib/controller/device.js +1317 -0
  7. package/lib/controller/features/alarm-feature.js +89 -0
  8. package/lib/controller/features/child-lock-feature.js +61 -0
  9. package/lib/controller/features/config-feature.js +54 -0
  10. package/lib/controller/features/consumption-feature.js +210 -0
  11. package/lib/controller/features/control-feature.js +62 -0
  12. package/lib/controller/features/diffuser-feature.js +411 -0
  13. package/lib/controller/features/digest-timer-feature.js +22 -0
  14. package/lib/controller/features/digest-trigger-feature.js +22 -0
  15. package/lib/controller/features/dnd-feature.js +79 -0
  16. package/lib/controller/features/electricity-feature.js +144 -0
  17. package/lib/controller/features/encryption-feature.js +259 -0
  18. package/lib/controller/features/garage-feature.js +337 -0
  19. package/lib/controller/features/hub-feature.js +687 -0
  20. package/lib/controller/features/light-feature.js +408 -0
  21. package/lib/controller/features/presence-sensor-feature.js +297 -0
  22. package/lib/controller/features/roller-shutter-feature.js +456 -0
  23. package/lib/controller/features/runtime-feature.js +74 -0
  24. package/lib/controller/features/screen-feature.js +67 -0
  25. package/lib/controller/features/sensor-history-feature.js +47 -0
  26. package/lib/controller/features/smoke-config-feature.js +50 -0
  27. package/lib/controller/features/spray-feature.js +166 -0
  28. package/lib/controller/features/system-feature.js +269 -0
  29. package/lib/controller/features/temp-unit-feature.js +55 -0
  30. package/lib/controller/features/thermostat-feature.js +804 -0
  31. package/lib/controller/features/timer-feature.js +507 -0
  32. package/lib/controller/features/toggle-feature.js +223 -0
  33. package/lib/controller/features/trigger-feature.js +333 -0
  34. package/lib/controller/hub-device.js +185 -0
  35. package/lib/controller/subdevice.js +1537 -0
  36. package/lib/device-factory.js +463 -0
  37. package/lib/error-budget.js +138 -0
  38. package/lib/http-api.js +766 -0
  39. package/lib/manager.js +1609 -0
  40. package/lib/model/channel-info.js +79 -0
  41. package/lib/model/constants.js +119 -0
  42. package/lib/model/enums.js +819 -0
  43. package/lib/model/exception.js +363 -0
  44. package/lib/model/http/device.js +215 -0
  45. package/lib/model/http/error-codes.js +121 -0
  46. package/lib/model/http/exception.js +151 -0
  47. package/lib/model/http/subdevice.js +133 -0
  48. package/lib/model/push/alarm.js +112 -0
  49. package/lib/model/push/bind.js +97 -0
  50. package/lib/model/push/common.js +282 -0
  51. package/lib/model/push/diffuser-light.js +100 -0
  52. package/lib/model/push/diffuser-spray.js +83 -0
  53. package/lib/model/push/factory.js +229 -0
  54. package/lib/model/push/generic.js +115 -0
  55. package/lib/model/push/hub-battery.js +59 -0
  56. package/lib/model/push/hub-mts100-all.js +64 -0
  57. package/lib/model/push/hub-mts100-mode.js +59 -0
  58. package/lib/model/push/hub-mts100-temperature.js +62 -0
  59. package/lib/model/push/hub-online.js +59 -0
  60. package/lib/model/push/hub-sensor-alert.js +61 -0
  61. package/lib/model/push/hub-sensor-all.js +59 -0
  62. package/lib/model/push/hub-sensor-smoke.js +110 -0
  63. package/lib/model/push/hub-sensor-temphum.js +62 -0
  64. package/lib/model/push/hub-subdevicelist.js +50 -0
  65. package/lib/model/push/hub-togglex.js +60 -0
  66. package/lib/model/push/index.js +81 -0
  67. package/lib/model/push/online.js +53 -0
  68. package/lib/model/push/presence-study.js +61 -0
  69. package/lib/model/push/sensor-latestx.js +106 -0
  70. package/lib/model/push/timerx.js +63 -0
  71. package/lib/model/push/togglex.js +78 -0
  72. package/lib/model/push/triggerx.js +62 -0
  73. package/lib/model/push/unbind.js +34 -0
  74. package/lib/model/push/water-leak.js +107 -0
  75. package/lib/model/states/diffuser-light-state.js +119 -0
  76. package/lib/model/states/diffuser-spray-state.js +58 -0
  77. package/lib/model/states/garage-door-state.js +71 -0
  78. package/lib/model/states/index.js +38 -0
  79. package/lib/model/states/light-state.js +134 -0
  80. package/lib/model/states/presence-sensor-state.js +239 -0
  81. package/lib/model/states/roller-shutter-state.js +82 -0
  82. package/lib/model/states/spray-state.js +58 -0
  83. package/lib/model/states/thermostat-state.js +297 -0
  84. package/lib/model/states/timer-state.js +192 -0
  85. package/lib/model/states/toggle-state.js +105 -0
  86. package/lib/model/states/trigger-state.js +155 -0
  87. package/lib/subscription.js +587 -0
  88. package/lib/utilities/conversion.js +62 -0
  89. package/lib/utilities/debug.js +165 -0
  90. package/lib/utilities/mqtt.js +152 -0
  91. package/lib/utilities/network.js +53 -0
  92. package/lib/utilities/options.js +64 -0
  93. package/lib/utilities/request-queue.js +161 -0
  94. package/lib/utilities/ssid.js +37 -0
  95. package/lib/utilities/state-changes.js +66 -0
  96. package/lib/utilities/stats.js +687 -0
  97. package/lib/utilities/timer.js +310 -0
  98. package/lib/utilities/trigger.js +286 -0
  99. package/package.json +73 -0
@@ -0,0 +1,79 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Channel metadata for a device.
5
+ *
6
+ * Encapsulates channel information parsed from device initialization data. Devices
7
+ * can have multiple channels (e.g., master channel at index 0, sub-channels at 1-n),
8
+ * each representing a separate control point or feature. The master channel typically
9
+ * controls the primary device functions.
10
+ *
11
+ * @class
12
+ * @example
13
+ * const channels = device.channels;
14
+ * channels.forEach(channel => {
15
+ * console.log(`Channel ${channel.index}: ${channel.name} (USB: ${channel.isUsb})`);
16
+ * });
17
+ */
18
+ class ChannelInfo {
19
+ /**
20
+ * Creates a new ChannelInfo instance.
21
+ *
22
+ * @param {number} index - Channel index (0 for master channel, 1-n for sub-channels)
23
+ * @param {string} [name] - Channel name (defaults to 'Main channel' for index 0)
24
+ * @param {string} [channelType] - Channel type (e.g., 'USB')
25
+ * @param {boolean} [isMasterChannel=false] - Whether this is the master channel
26
+ */
27
+ constructor(index, name = null, channelType = null, isMasterChannel = false) {
28
+ this._index = index;
29
+ this._name = name;
30
+ this._type = channelType;
31
+ this._master = isMasterChannel;
32
+ }
33
+
34
+ /**
35
+ * Gets the channel index.
36
+ *
37
+ * The index identifies which channel this represents. Index 0 is reserved for
38
+ * the master channel, while indices 1-n represent sub-channels or additional
39
+ * control points.
40
+ *
41
+ * @returns {number} Channel index (0 for master, 1-n for sub-channels)
42
+ */
43
+ get index() {
44
+ return this._index;
45
+ }
46
+
47
+ /**
48
+ * Gets the channel name.
49
+ *
50
+ * @returns {string|null} Channel name or null if not set
51
+ */
52
+ get name() {
53
+ return this._name;
54
+ }
55
+
56
+ /**
57
+ * Gets whether this channel is a USB channel.
58
+ *
59
+ * @returns {boolean} True if channel type is 'USB', false otherwise
60
+ */
61
+ get isUsb() {
62
+ return this._type === 'USB';
63
+ }
64
+
65
+ /**
66
+ * Gets whether this is the master channel.
67
+ *
68
+ * The master channel (typically at index 0) represents the primary device control
69
+ * point. Commands sent without a channel specification default to the master channel.
70
+ *
71
+ * @returns {boolean} True if this is the master channel, false otherwise
72
+ */
73
+ get isMasterChannel() {
74
+ return this._master;
75
+ }
76
+ }
77
+
78
+ module.exports = ChannelInfo;
79
+
@@ -0,0 +1,119 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Secret key for Meross API request signing.
5
+ *
6
+ * Used by the Meross API protocol to sign authentication requests. This value
7
+ * is required by the API and changing it will break communication.
8
+ *
9
+ * @constant {string}
10
+ * @private
11
+ */
12
+ const SECRET = '23x17ahWarFH6w29';
13
+
14
+ /**
15
+ * Meross HTTP API domain.
16
+ *
17
+ * Base domain for cloud API endpoints. Used for authentication and device
18
+ * management operations that require HTTP requests rather than MQTT.
19
+ *
20
+ * @constant {string}
21
+ */
22
+ const MEROSS_DOMAIN = 'iotx.meross.com';
23
+
24
+ /**
25
+ * Meross MQTT broker domain for EU region.
26
+ *
27
+ * Separate from the HTTP API domain to support real-time bidirectional
28
+ * communication with devices. MQTT is used for device commands and state
29
+ * updates, while HTTP is used for account management and device enumeration.
30
+ *
31
+ * @constant {string}
32
+ */
33
+ const MEROSS_MQTT_DOMAIN = 'eu-iotx.meross.com';
34
+
35
+ /**
36
+ * Authentication endpoint path.
37
+ *
38
+ * Used to obtain access tokens required for subsequent API calls. Tokens
39
+ * authenticate the client session and must be included in all API requests.
40
+ *
41
+ * @constant {string}
42
+ */
43
+ const LOGIN_URL = '/v1/Auth/signIn';
44
+
45
+ /**
46
+ * Logout endpoint path.
47
+ *
48
+ * Used to invalidate the current session's authentication token on the server,
49
+ * preventing further API access with the same token.
50
+ *
51
+ * @constant {string}
52
+ */
53
+ const LOGOUT_URL = '/v1/Profile/logout';
54
+
55
+ /**
56
+ * Device enumeration endpoint path.
57
+ *
58
+ * Used to retrieve all devices associated with the authenticated account.
59
+ * Returns device metadata including UUIDs, names, and capabilities needed
60
+ * for device initialization.
61
+ *
62
+ * @constant {string}
63
+ */
64
+ const DEV_LIST = '/v1/Device/devList';
65
+
66
+ /**
67
+ * Subdevice enumeration endpoint path.
68
+ *
69
+ * Used to retrieve subdevices (sensors, valves, etc.) connected to hub devices.
70
+ * Subdevices are not returned by the standard device list endpoint because they
71
+ * are managed through their parent hub device rather than directly.
72
+ *
73
+ * @constant {string}
74
+ */
75
+ const SUBDEV_LIST = '/v1/Hub/getSubDevices';
76
+
77
+ /**
78
+ * User activity logging endpoint path.
79
+ *
80
+ * Used to log client information to Meross servers for analytics and telemetry.
81
+ * Called automatically after successful login to provide usage statistics.
82
+ *
83
+ * @constant {string}
84
+ */
85
+ const LOG_URL = '/v1/log/user';
86
+
87
+ /**
88
+ * Default MQTT broker hostname.
89
+ *
90
+ * Used as fallback when device-specific domain information is not available
91
+ * from the device enumeration response.
92
+ *
93
+ * @constant {string}
94
+ */
95
+ const DEFAULT_MQTT_HOST = 'mqtt.meross.com';
96
+
97
+ /**
98
+ * Default MQTT broker port.
99
+ *
100
+ * Used as fallback when device-specific port information is not available
101
+ * from the device enumeration response.
102
+ *
103
+ * @constant {number}
104
+ */
105
+ const DEFAULT_MQTT_PORT = 443;
106
+
107
+ module.exports = {
108
+ SECRET,
109
+ MEROSS_DOMAIN,
110
+ MEROSS_MQTT_DOMAIN,
111
+ LOGIN_URL,
112
+ LOGOUT_URL,
113
+ LOG_URL,
114
+ DEV_LIST,
115
+ SUBDEV_LIST,
116
+ DEFAULT_MQTT_HOST,
117
+ DEFAULT_MQTT_PORT
118
+ };
119
+