meross-iot 0.3.1 → 0.5.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.
- package/CHANGELOG.md +61 -0
- package/README.md +124 -6
- package/index.d.ts +676 -60
- package/index.js +25 -17
- package/lib/controller/device.js +116 -137
- package/lib/controller/features/config-feature.js +3 -2
- package/lib/controller/features/diffuser-feature.js +10 -9
- package/lib/controller/features/dnd-feature.js +6 -6
- package/lib/controller/features/encryption-feature.js +6 -7
- package/lib/controller/features/garage-feature.js +6 -5
- package/lib/controller/features/light-feature.js +18 -17
- package/lib/controller/features/presence-sensor-feature.js +1 -1
- package/lib/controller/features/roller-shutter-feature.js +6 -5
- package/lib/controller/features/runtime-feature.js +2 -2
- package/lib/controller/features/spray-feature.js +5 -4
- package/lib/controller/features/system-feature.js +7 -7
- package/lib/controller/features/thermostat-feature.js +21 -23
- package/lib/controller/features/timer-feature.js +11 -10
- package/lib/controller/features/toggle-feature.js +13 -13
- package/lib/controller/features/trigger-feature.js +11 -10
- package/lib/controller/hub-device.js +3 -3
- package/lib/controller/subdevice.js +9 -13
- package/lib/device-registry.js +332 -0
- package/lib/http-api.js +31 -38
- package/lib/manager.js +258 -1339
- package/lib/managers/devices.js +1092 -0
- package/lib/managers/http.js +322 -0
- package/lib/managers/mqtt.js +498 -0
- package/lib/managers/statistics.js +158 -0
- package/lib/{subscription.js → managers/subscription.js} +6 -5
- package/lib/managers/transport.js +217 -0
- package/lib/model/exception.js +483 -60
- package/lib/model/http/device.js +62 -103
- package/lib/model/http/exception.js +90 -37
- package/lib/model/http/subdevice.js +40 -45
- package/lib/model/push/alarm.js +3 -4
- package/lib/model/push/bind.js +2 -2
- package/lib/model/push/common.js +55 -128
- package/lib/model/push/hub-sensor-smoke.js +2 -3
- package/lib/model/push/water-leak.js +2 -3
- package/lib/utilities/conversion.js +2 -2
- package/lib/utilities/debug.js +6 -18
- package/lib/utilities/options.js +4 -2
- package/lib/utilities/request-queue.js +3 -1
- package/lib/utilities/timer.js +13 -8
- package/lib/utilities/trigger.js +9 -6
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,67 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.5.0] - 2026-01-19
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- **BREAKING**: Standardized error handling with MerossError* naming convention
|
|
12
|
+
- Renamed all error classes to use `MerossError*` prefix for consistency
|
|
13
|
+
- `AuthenticationError` → `MerossErrorAuthentication`
|
|
14
|
+
- `ConnectionError` → `MerossErrorConnection`
|
|
15
|
+
- `DeviceError` → `MerossErrorDevice`
|
|
16
|
+
- `HttpError` → `MerossErrorHttp`
|
|
17
|
+
- `MqttError` → `MerossErrorMqtt`
|
|
18
|
+
- `NetworkError` → `MerossErrorNetwork`
|
|
19
|
+
- `ProtocolError` → `MerossErrorProtocol`
|
|
20
|
+
- `TimeoutError` → `MerossErrorTimeout`
|
|
21
|
+
- `TokenError` → `MerossErrorToken`
|
|
22
|
+
- `ValidationError` → `MerossErrorValidation`
|
|
23
|
+
- All error classes now include `code`, `isOperational`, and `cause` properties
|
|
24
|
+
- Added `toJSON()` method to all error classes for serialization
|
|
25
|
+
- Updated TypeScript definitions to match new error structure
|
|
26
|
+
- Updated error-handling example to use new error class names
|
|
27
|
+
- **BREAKING**: Split ManagerMeross into separate lazy-loaded manager modules
|
|
28
|
+
- Manager methods are now accessed via manager properties instead of direct methods:
|
|
29
|
+
- `manager.devices` - device discovery and initialization (ManagerDevices)
|
|
30
|
+
- `manager.mqtt` - MQTT connection management (ManagerMqtt)
|
|
31
|
+
- `manager.http` - LAN HTTP communication (ManagerHttp)
|
|
32
|
+
- `manager.transport` - transport mode selection and routing (ManagerTransport)
|
|
33
|
+
- `manager.statistics` - statistics tracking (ManagerStatistics)
|
|
34
|
+
- `manager.subscription` - device update subscriptions (ManagerSubscription)
|
|
35
|
+
- Extracted DeviceRegistry to standalone module
|
|
36
|
+
- Moved subscription manager to `managers/` directory
|
|
37
|
+
- Updated all examples and TypeScript definitions for new API
|
|
38
|
+
|
|
39
|
+
### Added
|
|
40
|
+
- Enhanced error context through error chaining via `cause` property
|
|
41
|
+
- Error serialization support via `toJSON()` method on all error classes
|
|
42
|
+
- Lazy-loaded manager modules for better code organization and performance
|
|
43
|
+
|
|
44
|
+
## [0.4.0] - 2026-01-16
|
|
45
|
+
|
|
46
|
+
### Changed
|
|
47
|
+
- **BREAKING**: Renamed `getDevices()` to `initializeDevices()` in `ManagerMeross`
|
|
48
|
+
- The method name better reflects that it performs full device discovery, initialization, and connection setup, not just retrieval
|
|
49
|
+
- Updated `login()` and `connect()` to use `initializeDevices()`
|
|
50
|
+
- Updated all examples and TypeScript definitions
|
|
51
|
+
- **BREAKING**: Simplified device API by establishing single source of truth
|
|
52
|
+
- Removed `deviceDef` parameter from `deviceInitialized` event - now just `(deviceId, device)`
|
|
53
|
+
- Removed `cachedHttpInfo` property; all properties are now directly accessible on `MerossDevice`
|
|
54
|
+
- Converted simple getters to direct properties (`macAddress`, `lanIp`, `mqttHost`, etc.)
|
|
55
|
+
- Updated all feature files to use public properties (`abilities`, `lastFullUpdateTimestamp`)
|
|
56
|
+
- Removed unnecessary defensive fallback patterns (`device.dev?.uuid` → `device.uuid`)
|
|
57
|
+
- Fixed subdevice property consistency
|
|
58
|
+
- **BREAKING**: Removed snake_case handling, standardized on camelCase
|
|
59
|
+
- Removed snake_case property mappings from `HttpDeviceInfo`, `HttpSubdeviceInfo`, `HardwareInfo`, `FirmwareInfo`, and `TimeInfo`
|
|
60
|
+
- Updated filter parameters to camelCase (`deviceUuids`, `deviceType`, `onlineStatus`, etc.)
|
|
61
|
+
- Changed `subdevice_id` getter to `subdeviceId` in push notification classes
|
|
62
|
+
- Updated `TokenData` interface: `issued_on` → `issuedOn`
|
|
63
|
+
- All JSDoc comments now reflect direct camelCase acceptance
|
|
64
|
+
|
|
65
|
+
### Updated
|
|
66
|
+
- Updated all examples to use camelCase consistently
|
|
67
|
+
- Updated all examples to use `initializeDevices()` instead of `getDevices()`
|
|
68
|
+
|
|
8
69
|
## [0.3.1] - 2026-01-15
|
|
9
70
|
|
|
10
71
|
### Fixed
|
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ The library can control devices locally via HTTP or via cloud MQTT server.
|
|
|
26
26
|
npm install meross-iot@alpha
|
|
27
27
|
|
|
28
28
|
# Or install specific version
|
|
29
|
-
npm install meross-iot@0.
|
|
29
|
+
npm install meross-iot@0.5.0
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
## Usage & Documentation
|
|
@@ -51,8 +51,8 @@ const { ManagerMeross, MerossHttpClient } = require('meross-iot');
|
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
// Listen for device events
|
|
54
|
-
meross.on('deviceInitialized', (deviceId,
|
|
55
|
-
console.log(`Device found: ${
|
|
54
|
+
meross.on('deviceInitialized', (deviceId, device) => {
|
|
55
|
+
console.log(`Device found: ${device.name} (${device.deviceType})`);
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
// Connect and discover devices
|
|
@@ -84,6 +84,63 @@ The `example/` directory contains focused examples for different use cases:
|
|
|
84
84
|
- **`multiple-accounts.js`** - Using multiple Meross accounts simultaneously
|
|
85
85
|
- **`factory-pattern-usage.js`** - Recommended factory pattern for creating HTTP clients and managers
|
|
86
86
|
- **`timer-usage.js`** - Creating and managing device timers
|
|
87
|
+
- **`selective-initialization.js`** - Selectively initializing devices and subdevices
|
|
88
|
+
|
|
89
|
+
## Adding and Removing Devices
|
|
90
|
+
|
|
91
|
+
You can dynamically add and remove devices from the manager after initialization:
|
|
92
|
+
|
|
93
|
+
```javascript
|
|
94
|
+
// Add a single device
|
|
95
|
+
const device = await manager.devices.initializeDevice('device-uuid');
|
|
96
|
+
|
|
97
|
+
// Add a subdevice (hub will be auto-initialized if needed)
|
|
98
|
+
const subdevice = await manager.devices.initializeDevice({
|
|
99
|
+
hubUuid: 'hub-uuid',
|
|
100
|
+
id: 'subdevice-id'
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// Remove a device
|
|
104
|
+
const removed = await manager.devices.remove('device-uuid');
|
|
105
|
+
|
|
106
|
+
// Remove a subdevice
|
|
107
|
+
const removed = await manager.devices.remove({
|
|
108
|
+
hubUuid: 'hub-uuid',
|
|
109
|
+
id: 'subdevice-id'
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
When removing a hub device, all its subdevices are automatically removed as well.
|
|
114
|
+
|
|
115
|
+
## API Organization
|
|
116
|
+
|
|
117
|
+
The library follows a modular architecture with specialized managers for different concerns:
|
|
118
|
+
|
|
119
|
+
- **`manager.devices`** - Device discovery, initialization, and lifecycle management
|
|
120
|
+
- **`manager.mqtt`** - MQTT connection management and message publishing
|
|
121
|
+
- **`manager.http`** - LAN HTTP communication with devices
|
|
122
|
+
- **`manager.transport`** - Transport mode selection and message routing
|
|
123
|
+
- **`manager.subscription`** - Automatic polling and unified update streams
|
|
124
|
+
|
|
125
|
+
This organization makes the API more discoverable and easier to use. For example:
|
|
126
|
+
|
|
127
|
+
```javascript
|
|
128
|
+
// Discover devices without initializing
|
|
129
|
+
const availableDevices = await manager.devices.discover({ onlineOnly: true });
|
|
130
|
+
|
|
131
|
+
// Initialize devices
|
|
132
|
+
const count = await manager.devices.initialize();
|
|
133
|
+
|
|
134
|
+
// Encode and send a message via MQTT
|
|
135
|
+
const data = manager.mqtt.encode('GET', 'Appliance.Control.ToggleX', {}, device.uuid);
|
|
136
|
+
manager.mqtt.send(device, data);
|
|
137
|
+
|
|
138
|
+
// Send a message via LAN HTTP
|
|
139
|
+
await manager.http.send(device, '192.168.1.100', data);
|
|
140
|
+
|
|
141
|
+
// Use transport manager for automatic routing
|
|
142
|
+
await manager.transport.request(device, '192.168.1.100', data);
|
|
143
|
+
```
|
|
87
144
|
|
|
88
145
|
## Supported Devices
|
|
89
146
|
|
|
@@ -120,14 +177,75 @@ Please create an issue on GitHub and include:
|
|
|
120
177
|
|
|
121
178
|
## Changelog
|
|
122
179
|
|
|
123
|
-
### [0.
|
|
180
|
+
### [0.5.0] - 2026-01-19
|
|
124
181
|
|
|
125
|
-
####
|
|
126
|
-
-
|
|
182
|
+
#### Changed
|
|
183
|
+
- **BREAKING**: Standardized error handling with MerossError* naming convention
|
|
184
|
+
- Renamed all error classes to use `MerossError*` prefix for consistency
|
|
185
|
+
- `AuthenticationError` → `MerossErrorAuthentication`
|
|
186
|
+
- `ConnectionError` → `MerossErrorConnection`
|
|
187
|
+
- `DeviceError` → `MerossErrorDevice`
|
|
188
|
+
- `HttpError` → `MerossErrorHttp`
|
|
189
|
+
- `MqttError` → `MerossErrorMqtt`
|
|
190
|
+
- `NetworkError` → `MerossErrorNetwork`
|
|
191
|
+
- `ProtocolError` → `MerossErrorProtocol`
|
|
192
|
+
- `TimeoutError` → `MerossErrorTimeout`
|
|
193
|
+
- `TokenError` → `MerossErrorToken`
|
|
194
|
+
- `ValidationError` → `MerossErrorValidation`
|
|
195
|
+
- All error classes now include `code`, `isOperational`, and `cause` properties
|
|
196
|
+
- Added `toJSON()` method to all error classes for serialization
|
|
197
|
+
- Updated TypeScript definitions to match new error structure
|
|
198
|
+
- Updated error-handling example to use new error class names
|
|
199
|
+
- **BREAKING**: Split ManagerMeross into separate lazy-loaded manager modules
|
|
200
|
+
- Manager methods are now accessed via manager properties instead of direct methods:
|
|
201
|
+
- `manager.devices` - device discovery and initialization (ManagerDevices)
|
|
202
|
+
- `manager.mqtt` - MQTT connection management (ManagerMqtt)
|
|
203
|
+
- `manager.http` - LAN HTTP communication (ManagerHttp)
|
|
204
|
+
- `manager.transport` - transport mode selection and routing (ManagerTransport)
|
|
205
|
+
- `manager.statistics` - statistics tracking (ManagerStatistics)
|
|
206
|
+
- `manager.subscription` - device update subscriptions (ManagerSubscription)
|
|
207
|
+
- Extracted DeviceRegistry to standalone module
|
|
208
|
+
- Moved subscription manager to `managers/` directory
|
|
209
|
+
- Updated all examples and TypeScript definitions for new API
|
|
210
|
+
|
|
211
|
+
#### Added
|
|
212
|
+
- Enhanced error context through error chaining via `cause` property
|
|
213
|
+
- Error serialization support via `toJSON()` method on all error classes
|
|
214
|
+
- Lazy-loaded manager modules for better code organization and performance
|
|
127
215
|
|
|
128
216
|
<details>
|
|
129
217
|
<summary>Older</summary>
|
|
130
218
|
|
|
219
|
+
### [0.4.0] - 2026-01-16
|
|
220
|
+
|
|
221
|
+
#### Changed
|
|
222
|
+
- **BREAKING**: Renamed `getDevices()` to `initializeDevices()` in `ManagerMeross`
|
|
223
|
+
- The method name better reflects that it performs full device discovery, initialization, and connection setup, not just retrieval
|
|
224
|
+
- Updated `login()` and `connect()` to use `initializeDevices()`
|
|
225
|
+
- Updated all examples and TypeScript definitions
|
|
226
|
+
- **BREAKING**: Simplified device API by establishing single source of truth
|
|
227
|
+
- Removed `deviceDef` parameter from `deviceInitialized` event - now just `(deviceId, device)`
|
|
228
|
+
- Removed `cachedHttpInfo` property; all properties are now directly accessible on `MerossDevice`
|
|
229
|
+
- Converted simple getters to direct properties (`macAddress`, `lanIp`, `mqttHost`, etc.)
|
|
230
|
+
- Updated all feature files to use public properties (`abilities`, `lastFullUpdateTimestamp`)
|
|
231
|
+
- Removed unnecessary defensive fallback patterns (`device.dev?.uuid` → `device.uuid`)
|
|
232
|
+
- Fixed subdevice property consistency
|
|
233
|
+
- **BREAKING**: Removed snake_case handling, standardized on camelCase
|
|
234
|
+
- Removed snake_case property mappings from `HttpDeviceInfo`, `HttpSubdeviceInfo`, `HardwareInfo`, `FirmwareInfo`, and `TimeInfo`
|
|
235
|
+
- Updated filter parameters to camelCase (`deviceUuids`, `deviceType`, `onlineStatus`, etc.)
|
|
236
|
+
- Changed `subdevice_id` getter to `subdeviceId` in push notification classes
|
|
237
|
+
- Updated `TokenData` interface: `issued_on` → `issuedOn`
|
|
238
|
+
- All JSDoc comments now reflect direct camelCase acceptance
|
|
239
|
+
|
|
240
|
+
#### Updated
|
|
241
|
+
- Updated all examples to use camelCase consistently
|
|
242
|
+
- Updated all examples to use `initializeDevices()` instead of `getDevices()`
|
|
243
|
+
|
|
244
|
+
### [0.3.1] - 2026-01-15
|
|
245
|
+
|
|
246
|
+
#### Fixed
|
|
247
|
+
- Fixed `ManagerSubscription` constructor bug: now properly calls `super()` before accessing `this` to correctly initialize EventEmitter parent class
|
|
248
|
+
|
|
131
249
|
### [0.3.0] - 2026-01-15
|
|
132
250
|
|
|
133
251
|
#### Changed
|