meross-iot 0.9.1 → 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.
- package/CHANGELOG.md +55 -0
- package/README.md +60 -67
- package/index.d.ts +330 -3502
- package/index.js +11 -112
- package/lib/{controller/features/alarm-feature.js → abilities/alarm.js} +27 -17
- package/lib/{controller/features/child-lock-feature.js → abilities/child-lock.js} +7 -5
- package/lib/{controller/features/config-feature.js → abilities/config.js} +8 -6
- package/lib/{controller/features/consumption-feature.js → abilities/consumption.js} +14 -18
- package/lib/{controller/features/control-feature.js → abilities/control.js} +10 -7
- package/lib/abilities/diffuser.js +192 -0
- package/lib/{controller/features/digest-timer-feature.js → abilities/digest-timer.js} +6 -5
- package/lib/{controller/features/digest-trigger-feature.js → abilities/digest-trigger.js} +6 -5
- package/lib/{controller/features/dnd-feature.js → abilities/dnd.js} +10 -11
- package/lib/{controller/features/electricity-feature.js → abilities/electricity.js} +20 -24
- package/lib/{controller/features/encryption-feature.js → abilities/encryption.js} +7 -8
- package/lib/{controller/features/garage-feature.js → abilities/garage.js} +47 -95
- package/lib/{controller/features/hub-feature.js → abilities/hub.js} +75 -52
- package/lib/{controller/features/light-feature.js → abilities/light.js} +137 -148
- package/lib/{controller/features/presence-sensor-feature.js → abilities/presence.js} +147 -91
- package/lib/abilities/roller-shutter.js +236 -0
- package/lib/{controller/features/runtime-feature.js → abilities/runtime.js} +6 -5
- package/lib/{controller/features/screen-feature.js → abilities/screen.js} +7 -5
- package/lib/{controller/features/sensor-history-feature.js → abilities/sensor-history.js} +7 -5
- package/lib/{controller/features/smoke-config-feature.js → abilities/smoke-config.js} +7 -5
- package/lib/abilities/spray.js +122 -0
- package/lib/{controller/features/system-feature.js → abilities/system.js} +59 -25
- package/lib/{controller/features/temp-unit-feature.js → abilities/temp-unit.js} +9 -7
- package/lib/{controller/features/thermostat-feature.js → abilities/thermostat.js} +220 -258
- package/lib/{controller/features/timer-feature.js → abilities/timer.js} +137 -24
- package/lib/abilities/toggle.js +149 -0
- package/lib/{controller/features/trigger-feature.js → abilities/trigger.js} +127 -34
- package/lib/{http-api.js → api/client.js} +55 -123
- package/lib/{model → api}/constants.js +4 -0
- package/lib/{model/http → api}/device.js +12 -12
- package/lib/{model/http → api}/error-codes.js +1 -1
- package/lib/{model/http → api}/subdevice.js +10 -10
- package/lib/{model/channel-info.js → device/channel.js} +4 -0
- package/lib/device/device.js +1618 -0
- package/lib/{device-factory.js → device/factory.js} +121 -120
- package/lib/{controller/hub-device.js → device/hubdevice.js} +17 -44
- package/lib/{device-registry.js → device/registry.js} +4 -44
- package/lib/{controller → device}/subdevice.js +97 -150
- package/lib/dispatcher.js +257 -0
- package/lib/exception.js +211 -0
- package/lib/meross.js +426 -0
- package/lib/{model/push → push}/factory.js +14 -10
- package/lib/{model/push → push}/generic.js +24 -1
- package/lib/{model/push → push}/index.js +2 -2
- package/lib/{model/states → states}/diffuser-light-state.js +1 -1
- package/lib/{model/states → states}/index.js +1 -1
- package/lib/{model/states → states}/light-state.js +1 -1
- package/lib/utilities/cache.js +51 -0
- package/lib/utilities/conversion.js +3 -3
- package/lib/utilities/heartbeat.js +1 -1
- package/lib/utilities/options.js +25 -5
- package/lib/utilities/request-queue.js +2 -2
- package/lib/utilities/state-ordering.js +57 -0
- package/lib/utilities/timer.js +14 -18
- package/lib/utilities/trigger.js +15 -17
- package/manager/auth.js +157 -0
- package/manager/base.js +18 -0
- package/{lib/managers → manager}/devices.js +179 -177
- package/{lib/managers → manager}/http.js +46 -62
- package/{lib/managers → manager}/mqtt.js +153 -112
- package/manager/registry.js +26 -0
- package/manager/statistics.js +114 -0
- package/{lib/managers → manager}/subscription.js +28 -248
- package/manager/transport.js +260 -0
- package/package.json +4 -2
- package/lib/controller/device.js +0 -1482
- package/lib/controller/features/diffuser-feature.js +0 -287
- package/lib/controller/features/roller-shutter-feature.js +0 -332
- package/lib/controller/features/spray-feature.js +0 -181
- package/lib/controller/features/toggle-feature.js +0 -188
- package/lib/error-budget.js +0 -138
- package/lib/manager.js +0 -510
- package/lib/managers/statistics.js +0 -158
- package/lib/managers/transport.js +0 -217
- package/lib/model/exception.js +0 -786
- package/lib/model/http/exception.js +0 -204
- package/lib/utilities/debug.js +0 -153
- /package/lib/{model/enums.js → enums.js} +0 -0
- /package/lib/{model/push → push}/alarm.js +0 -0
- /package/lib/{model/push → push}/bind.js +0 -0
- /package/lib/{model/push → push}/common.js +0 -0
- /package/lib/{model/push → push}/diffuser-light.js +0 -0
- /package/lib/{model/push → push}/diffuser-spray.js +0 -0
- /package/lib/{model/push → push}/hub-battery.js +0 -0
- /package/lib/{model/push → push}/hub-mts100-all.js +0 -0
- /package/lib/{model/push → push}/hub-mts100-mode.js +0 -0
- /package/lib/{model/push → push}/hub-mts100-temperature.js +0 -0
- /package/lib/{model/push → push}/hub-online.js +0 -0
- /package/lib/{model/push → push}/hub-sensor-alert.js +0 -0
- /package/lib/{model/push → push}/hub-sensor-all.js +0 -0
- /package/lib/{model/push → push}/hub-sensor-smoke.js +0 -0
- /package/lib/{model/push → push}/hub-sensor-temphum.js +0 -0
- /package/lib/{model/push → push}/hub-subdevicelist.js +0 -0
- /package/lib/{model/push → push}/hub-togglex.js +0 -0
- /package/lib/{model/push → push}/online.js +0 -0
- /package/lib/{model/push → push}/presence-study.js +0 -0
- /package/lib/{model/push → push}/sensor-latestx.js +0 -0
- /package/lib/{model/push → push}/timerx.js +0 -0
- /package/lib/{model/push → push}/togglex.js +0 -0
- /package/lib/{model/push → push}/triggerx.js +0 -0
- /package/lib/{model/push → push}/unbind.js +0 -0
- /package/lib/{model/push → push}/water-leak.js +0 -0
- /package/lib/{model/states → states}/diffuser-spray-state.js +0 -0
- /package/lib/{model/states → states}/garage-door-state.js +0 -0
- /package/lib/{model/states → states}/presence-sensor-state.js +0 -0
- /package/lib/{model/states → states}/roller-shutter-state.js +0 -0
- /package/lib/{model/states → states}/spray-state.js +0 -0
- /package/lib/{model/states → states}/thermostat-state.js +0 -0
- /package/lib/{model/states → states}/timer-state.js +0 -0
- /package/lib/{model/states → states}/toggle-state.js +0 -0
- /package/lib/{model/states → states}/trigger-state.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,61 @@ 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.10.0] - 2026-05-19
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- `Meross.authenticate()` — authenticate and return a manager without connecting to the cloud or initializing devices
|
|
12
|
+
- `Meross.connect()` — static entry point that authenticates and connects in one step
|
|
13
|
+
- Multi-channel helpers on toggle, timer, and trigger abilities: `getAll()` aggregates state across all device channels; timer and trigger also expose `count()`
|
|
14
|
+
- `getDeviceChannelIds()` utility for consistent channel enumeration from capabilities or device metadata
|
|
15
|
+
- Namespace dispatcher with header-timestamp ordering gate for SETACK, GETACK, and PUSH state updates
|
|
16
|
+
- Shared cache helpers (`readCache`, `getCachedOrFetch`) used by ability `get()` methods
|
|
17
|
+
- Unit test suite (198 tests) covering abilities, dispatcher, push notifications, authentication, and public module surface
|
|
18
|
+
- `manager.mqtt.connections` — exposes active MQTT connection map for diagnostics
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
- **BREAKING**: Renamed `ManagerMeross` to `Meross` (default export)
|
|
22
|
+
- `const Meross = require('meross-iot')` replaces `const ManagerMeross = require('meross-iot')`
|
|
23
|
+
- Direct construction requires an authenticated HTTP client; use `Meross.authenticate()` or `Meross.connect()` as entry points
|
|
24
|
+
- **BREAKING**: Removed public `MerossHttpClient` export
|
|
25
|
+
- Use `Meross.authenticate()` for credential exchange and token reuse via `meross.getTokenData()`
|
|
26
|
+
- **BREAKING**: Consolidated error classes into a smaller hierarchy with string `code` discriminators
|
|
27
|
+
- Exported: `MerossError`, `MerossAuthError`, `MerossDeviceError`, `MerossApiError`, `MerossNetworkError`
|
|
28
|
+
- Removed granular exports such as `MerossErrorAuthentication`, `MerossErrorTokenExpired`, `MerossErrorCommandTimeout`, `MerossErrorValidation`, etc.
|
|
29
|
+
- Catch category errors with `instanceof` and inspect `error.code` for specific handling (e.g. `TOKEN_EXPIRED`, `VALIDATION_ERROR`, `COMMAND_TIMEOUT`)
|
|
30
|
+
- Removed public `mapErrorCodeToError` export
|
|
31
|
+
- **BREAKING**: Renamed `device.getUnifiedState()` to `device.getState()`
|
|
32
|
+
- State is now derived from dispatcher namespace descriptors rather than hand-maintained aggregation
|
|
33
|
+
- **BREAKING**: Unified device initialization events
|
|
34
|
+
- Device emits `ready` (replacing `deviceInitialized`); manager emits `deviceReady` when a device finishes bootstrap
|
|
35
|
+
- `device.ready()` promise API unchanged
|
|
36
|
+
- **BREAKING**: Device abilities are initialized conditionally based on supported namespaces
|
|
37
|
+
- Unsupported features are absent (`undefined`) rather than present with stub methods
|
|
38
|
+
- **BREAKING**: Transport and statistics are accessed exclusively via sub-managers
|
|
39
|
+
- Use `meross.transport` for mode selection, error budgets, and request queuing
|
|
40
|
+
- Use `meross.statistics` for HTTP/MQTT stats (`enable()`, `getHttpStats()`, `getMqttStats()`)
|
|
41
|
+
- **BREAKING**: Trimmed public module exports to documented API surface
|
|
42
|
+
- Removed exports for state classes, push notification classes, `TimerUtils`, `TriggerUtils`, `createDebugUtils`, `ManagerSubscription`, and `MerossHttpClient`
|
|
43
|
+
- Removed `ThermostatWorkingMode` and `ThermostatModeBState` from package root exports (still available internally)
|
|
44
|
+
- **BREAKING**: Internal package layout restructured (no import-path stability for deep requires)
|
|
45
|
+
- `lib/controller/features/` → `lib/abilities/`
|
|
46
|
+
- `lib/managers/` → `manager/`
|
|
47
|
+
- `lib/controller/` → `lib/device/`
|
|
48
|
+
- `lib/http-api.js` → `lib/api/client.js`
|
|
49
|
+
- Subdevice state updates now pass through the same ordering gate as base devices, preventing stale hub sensor payloads from overwriting fresher per-namespace data
|
|
50
|
+
- Rewrote TypeScript definitions to match the simplified public API
|
|
51
|
+
- Updated all examples for the new connect/authenticate flow and ability-based device control
|
|
52
|
+
|
|
53
|
+
### Fixed
|
|
54
|
+
- Rewrote `publishMessage` without an async Promise executor
|
|
55
|
+
- HTTP API status errors are routed through `mapErrorCodeToError` consistently
|
|
56
|
+
- Exposed `manager.mqtt.connections` and aligned `disconnectAll()` routing through the mqtt getter
|
|
57
|
+
|
|
58
|
+
### Removed
|
|
59
|
+
- Standalone `lib/error-budget.js` (error budget logic lives on `ManagerTransport`)
|
|
60
|
+
- `lib/utilities/debug.js` and `createDebugUtils` export
|
|
61
|
+
- Internal ability `_update*` test hooks; state is exercised through dispatcher shims in tests
|
|
62
|
+
|
|
8
63
|
## [0.9.1] - 2026-01-22
|
|
9
64
|
|
|
10
65
|
### Fixed
|
package/README.md
CHANGED
|
@@ -26,65 +26,42 @@ 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.10.0
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
## Usage & Documentation
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
Runnable examples live in the GitHub repo under [`packages/meross-iot/example/`](https://github.com/Doekse/merossiot/tree/main/packages/meross-iot/example). See [example/README.md](https://github.com/Doekse/merossiot/blob/main/packages/meross-iot/example/README.md) for the full table (not included in the npm tarball).
|
|
35
35
|
|
|
36
36
|
If you are really impatient to use this library, refer to the following snippet of code that looks for a device and turns it on/off.
|
|
37
37
|
|
|
38
38
|
```javascript
|
|
39
|
-
const
|
|
39
|
+
const Meross = require('meross-iot');
|
|
40
40
|
|
|
41
41
|
(async () => {
|
|
42
|
-
|
|
43
|
-
const httpClient = await MerossHttpClient.fromUserPassword({
|
|
42
|
+
const meross = await Meross.connect({
|
|
44
43
|
email: 'your@email.com',
|
|
45
|
-
password: 'yourpassword'
|
|
44
|
+
password: 'yourpassword',
|
|
46
45
|
});
|
|
47
46
|
|
|
48
|
-
// Create manager with HTTP client
|
|
49
|
-
const meross = new ManagerMeross({
|
|
50
|
-
httpClient: httpClient
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// Listen for device events
|
|
54
|
-
meross.on('deviceInitialized', (deviceId, device) => {
|
|
55
|
-
console.log(`Device found: ${device.name} (${device.deviceType})`);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
// Connect and discover devices
|
|
59
|
-
await meross.connect();
|
|
60
|
-
|
|
61
|
-
// Find a device and control it
|
|
62
47
|
const devices = meross.devices.list();
|
|
63
48
|
if (devices.length > 0) {
|
|
64
49
|
const device = devices[0];
|
|
65
|
-
|
|
66
|
-
// Example: Toggle a switch
|
|
67
50
|
if (device.toggle) {
|
|
68
|
-
await device.toggle.set({ channel: 0, on: true });
|
|
51
|
+
await device.toggle.set({ channel: 0, on: true });
|
|
69
52
|
}
|
|
70
53
|
}
|
|
71
54
|
})();
|
|
72
55
|
```
|
|
73
56
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
- **`
|
|
77
|
-
- **`
|
|
78
|
-
- **`
|
|
79
|
-
- **`
|
|
80
|
-
- **`
|
|
81
|
-
- **`
|
|
82
|
-
- **`hub-devices.js`** - Working with hub devices and subdevices
|
|
83
|
-
- **`transport-modes.js`** - Understanding different transport modes
|
|
84
|
-
- **`multiple-accounts.js`** - Using multiple Meross accounts simultaneously
|
|
85
|
-
- **`factory-pattern-usage.js`** - Recommended factory pattern for creating HTTP clients and managers
|
|
86
|
-
- **`timer-usage.js`** - Creating and managing device timers
|
|
87
|
-
- **`selective-initialization.js`** - Selectively initializing devices and subdevices
|
|
57
|
+
Clone the repo or browse GitHub for runnable scripts. Highlights:
|
|
58
|
+
|
|
59
|
+
- **`basic-usage.js`** — `Meross.connect()` and list devices
|
|
60
|
+
- **`authenticate.js`** — `Meross.authenticate()` then selective `connect()`
|
|
61
|
+
- **`device-control.js`** — Feature objects: `toggle`, `light`, `electricity`, `system`
|
|
62
|
+
- **`device-discovery.js`** — `discover` / `discoverSubdevices` and `initializeDevice`
|
|
63
|
+
- **`subscription-manager.js`** — `meross.subscription` polling and list updates
|
|
64
|
+
- **`token-reuse.js`** — Persist `getTokenData()` between runs
|
|
88
65
|
|
|
89
66
|
## Adding and Removing Devices
|
|
90
67
|
|
|
@@ -92,21 +69,21 @@ You can dynamically add and remove devices from the manager after initialization
|
|
|
92
69
|
|
|
93
70
|
```javascript
|
|
94
71
|
// Add a single device
|
|
95
|
-
const device = await
|
|
72
|
+
const device = await meross.devices.initializeDevice('device-uuid');
|
|
96
73
|
|
|
97
74
|
// Add a subdevice (hub will be auto-initialized if needed)
|
|
98
|
-
const subdevice = await
|
|
99
|
-
hubUuid: 'hub-uuid',
|
|
100
|
-
id: 'subdevice-id'
|
|
75
|
+
const subdevice = await meross.devices.initializeDevice({
|
|
76
|
+
hubUuid: 'hub-uuid',
|
|
77
|
+
id: 'subdevice-id'
|
|
101
78
|
});
|
|
102
79
|
|
|
103
80
|
// Remove a device
|
|
104
|
-
const removed = await
|
|
81
|
+
const removed = await meross.devices.remove('device-uuid');
|
|
105
82
|
|
|
106
83
|
// Remove a subdevice
|
|
107
|
-
const removed = await
|
|
108
|
-
hubUuid: 'hub-uuid',
|
|
109
|
-
id: 'subdevice-id'
|
|
84
|
+
const removed = await meross.devices.remove({
|
|
85
|
+
hubUuid: 'hub-uuid',
|
|
86
|
+
id: 'subdevice-id'
|
|
110
87
|
});
|
|
111
88
|
```
|
|
112
89
|
|
|
@@ -114,32 +91,29 @@ When removing a hub device, all its subdevices are automatically removed as well
|
|
|
114
91
|
|
|
115
92
|
## API Organization
|
|
116
93
|
|
|
117
|
-
The library follows a modular architecture with specialized managers
|
|
94
|
+
The library follows a modular architecture with specialized managers on the connected `Meross` instance:
|
|
118
95
|
|
|
119
|
-
- **`
|
|
120
|
-
- **`
|
|
121
|
-
- **`
|
|
122
|
-
- **`
|
|
123
|
-
- **`
|
|
96
|
+
- **`meross.devices`** — device discovery, initialization, and lifecycle management
|
|
97
|
+
- **`meross.mqtt`** — MQTT connection management and message publishing
|
|
98
|
+
- **`meross.http`** — LAN HTTP communication with devices
|
|
99
|
+
- **`meross.transport`** — transport mode selection and message routing
|
|
100
|
+
- **`meross.subscription`** — automatic polling and unified update streams
|
|
101
|
+
- **`meross.statistics`** — optional HTTP/MQTT request diagnostics
|
|
124
102
|
|
|
125
|
-
|
|
103
|
+
Most apps use feature objects on devices (`device.toggle.set()`, etc.). Lower-level managers (`mqtt`, `http`, `transport`) remain available for advanced use:
|
|
126
104
|
|
|
127
105
|
```javascript
|
|
128
|
-
// Discover devices without initializing
|
|
129
|
-
const availableDevices = await
|
|
106
|
+
// Discover devices without initializing (after Meross.authenticate)
|
|
107
|
+
const availableDevices = await meross.devices.discover({ onlineOnly: true });
|
|
130
108
|
|
|
131
|
-
// Initialize devices
|
|
132
|
-
const count = await
|
|
109
|
+
// Initialize all or selected devices
|
|
110
|
+
const count = await meross.devices.initialize();
|
|
133
111
|
|
|
134
|
-
//
|
|
135
|
-
|
|
136
|
-
manager.mqtt.send(device, data);
|
|
112
|
+
// Prefer feature API for everyday control
|
|
113
|
+
await device.toggle.set({ channel: 0, on: true });
|
|
137
114
|
|
|
138
|
-
//
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
// Use transport manager for automatic routing
|
|
142
|
-
await manager.transport.request(device, '192.168.1.100', data);
|
|
115
|
+
// Transport mode (MQTT vs LAN-first)
|
|
116
|
+
meross.transport.defaultMode = Meross.TransportMode.LAN_HTTP_FIRST;
|
|
143
117
|
```
|
|
144
118
|
|
|
145
119
|
## Supported Devices
|
|
@@ -177,14 +151,33 @@ Please create an issue on GitHub and include:
|
|
|
177
151
|
|
|
178
152
|
## Changelog
|
|
179
153
|
|
|
154
|
+
See **[CHANGELOG.md](CHANGELOG.md)** for the full release history.
|
|
155
|
+
|
|
156
|
+
### [0.10.0] - 2026-05-19
|
|
157
|
+
|
|
158
|
+
Major API simplification release. Highlights:
|
|
159
|
+
|
|
160
|
+
#### Added
|
|
161
|
+
- `Meross.authenticate()` and `Meross.connect()` static entry points
|
|
162
|
+
- Multi-channel `getAll()` on toggle, timer, and trigger abilities
|
|
163
|
+
- Namespace dispatcher with header-timestamp ordering for state updates
|
|
164
|
+
- Unit test suite (198 tests)
|
|
165
|
+
|
|
166
|
+
#### Changed
|
|
167
|
+
- **BREAKING**: `ManagerMeross` → `Meross`; removed public `MerossHttpClient` export
|
|
168
|
+
- **BREAKING**: Consolidated error classes (`MerossAuthError`, `MerossDeviceError`, etc.) with string `code` discriminators
|
|
169
|
+
- **BREAKING**: `device.getUnifiedState()` → `device.getState()`; `deviceInitialized` → `ready` / `deviceReady`
|
|
170
|
+
- **BREAKING**: Conditional ability initialization; trimmed public module exports
|
|
171
|
+
- Internal layout: `lib/abilities/`, `manager/`, `lib/device/`
|
|
172
|
+
|
|
173
|
+
<details>
|
|
174
|
+
<summary>Older releases</summary>
|
|
175
|
+
|
|
180
176
|
### [0.9.1] - 2026-01-22
|
|
181
177
|
|
|
182
178
|
#### Fixed
|
|
183
179
|
- Improve heartbeat offline detection by using response silence (≥ heartbeat interval) instead of treating individual command errors/timeouts as offline signals
|
|
184
180
|
|
|
185
|
-
<details>
|
|
186
|
-
<summary>Older</summary>
|
|
187
|
-
|
|
188
181
|
### [0.9.0] - 2026-01-22
|
|
189
182
|
|
|
190
183
|
#### Added
|