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
package/CHANGELOG.md ADDED
@@ -0,0 +1,30 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0] - 2026-01-10
11
+
12
+ ### Added
13
+ - Initial release of MerossIot Node.js library
14
+ - Meross Cloud authentication and token management
15
+ - Device discovery and enumeration
16
+ - MQTT cloud server connection support
17
+ - HTTP local device control support
18
+ - Support for various device types (switches, lights, sensors, etc.)
19
+ - Hub device and subdevice support
20
+ - Event handling for device updates and state changes
21
+ - Error handling with comprehensive error types
22
+ - Statistics tracking for API calls
23
+ - Command-line interface (CLI) for testing and debugging
24
+ - TypeScript type definitions
25
+ - Examples in the `example/` directory
26
+
27
+ ### Known Issues
28
+ - This is an initial, pre-stable release. Please expect bugs.
29
+ - Some edge cases may not be fully handled yet.
30
+
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Abe Haverkamp
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,153 @@
1
+ # MerossIot
2
+
3
+ ![npm version (alpha)](https://img.shields.io/npm/v/meross-iot/alpha)
4
+ ![GitHub release](https://img.shields.io/github/v/release/Doekse/merossiot?include_prerelease)
5
+ ![npm downloads](https://img.shields.io/npm/dm/meross-iot)
6
+ ![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)
7
+ ![Node.js](https://img.shields.io/badge/node-%3E%3D18-brightgreen.svg)
8
+ ![alpha](https://img.shields.io/badge/status-alpha-red.svg)
9
+
10
+ A Node.js library for controlling Meross cloud devices. This library allows you to login into Meross cloud server, read registered devices, and open connections to the MQTT cloud server to get device data.
11
+
12
+ This code tries to closely mirror the [MerossIot Python project](https://github.com/albertogeniola/MerossIot) to provide a similar API and functionality for Node.js. This library was created for use in creating a Meross integration for the [Homey](https://homey.app) smart home platform.
13
+
14
+ The library can control devices locally via HTTP or via cloud MQTT server.
15
+
16
+ ## Requirements
17
+
18
+ - Node.js >= 18
19
+
20
+ ## Installation
21
+
22
+ **⚠️ Pre-release**: This is currently an unstable pre-release. Use with caution.
23
+
24
+ ```bash
25
+ # Install alpha version
26
+ npm install meross-iot@alpha
27
+
28
+ # Or install specific version
29
+ npm install meross-iot@0.1.0
30
+ ```
31
+
32
+ ## Usage & Documentation
33
+
34
+ Refer to the [example/README.md](example/README.md) for detailed usage instructions, or simply have a look at the `/example` directory.
35
+
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
+
38
+ ```javascript
39
+ const { MerossManager, MerossHttpClient } = require('meross-iot');
40
+
41
+ (async () => {
42
+ // Create HTTP client using factory method
43
+ const httpClient = await MerossHttpClient.fromUserPassword({
44
+ email: 'your@email.com',
45
+ password: 'yourpassword'
46
+ });
47
+
48
+ // Create manager with HTTP client
49
+ const meross = new MerossManager({
50
+ httpClient: httpClient
51
+ });
52
+
53
+ // Listen for device events
54
+ meross.on('deviceInitialized', (deviceId, deviceDef, device) => {
55
+ console.log(`Device found: ${deviceDef.devName} (${deviceDef.deviceType})`);
56
+ });
57
+
58
+ // Connect and discover devices
59
+ await meross.connect();
60
+
61
+ // Find a device and control it
62
+ const devices = meross.getAllDevices();
63
+ if (devices.length > 0) {
64
+ const device = devices[0];
65
+
66
+ // Example: Toggle a switch
67
+ if (device.abilities && device.abilities['Appliance.Control.ToggleX']) {
68
+ await device.setToggleX({ channel: 0, onoff: true }); // Turn on channel 0
69
+ }
70
+ }
71
+ })();
72
+ ```
73
+
74
+ The `example/` directory contains focused examples for different use cases:
75
+ - **`basic-usage.js`** - Simple connection and device discovery
76
+ - **`device-control.js`** - Controlling switches, lights, and monitoring devices
77
+ - **`event-handling.js`** - Handling events from devices and the manager
78
+ - **`token-reuse.js`** - Saving and reusing authentication tokens
79
+ - **`statistics.js`** - Enabling and viewing API call statistics
80
+ - **`error-handling.js`** - Comprehensive error handling and MFA
81
+ - **`hub-devices.js`** - Working with hub devices and subdevices
82
+ - **`transport-modes.js`** - Understanding different transport modes
83
+ - **`multiple-accounts.js`** - Using multiple Meross accounts simultaneously
84
+ - **`factory-pattern-usage.js`** - Recommended factory pattern for creating HTTP clients and managers
85
+ - **`timer-usage.js`** - Creating and managing device timers
86
+
87
+ ## Supported Devices
88
+
89
+ This library should support al wifi based devices Meross currently has on the market. I've tested the code with the following devices:
90
+
91
+ - MSS315 Smart Wi-Fi Plug Mini
92
+ - MSP844 Smart Fast Charging Power Strip
93
+ - MS130H Smart Temperature and Humidity Sensor Kit
94
+ - MS600 Smart Presence Sensor
95
+ - MOP320MA Smart Outdoor Plug with Energy Monitor
96
+ - MSS815MA Smart in-Wall Switch
97
+ - MSS715MA Smart DIY Switch with Energy Monitor
98
+ - MTS215MA Smart Thermostat
99
+ - MA151H Smart Smoke Alarm
100
+ - MSH450 Smart Hub
101
+ - MSH400HK Smart Hub
102
+ - MSH300HK Smart Hub
103
+ - MSL120HK Smart LED Light Bulb Pro
104
+ - MSL100HK Smart LED Light Bulb
105
+ - MS400H Smart Water Leak Sensor
106
+
107
+
108
+ ## Unsupported Device?
109
+
110
+ If your device is not supported or you're experiencing issues with a specific device, you may ask the developers to add specific support for that device. To do so, you will need to "sniff" low-level communication between your Meross App and the specific device. Such data can help the developers to add support for that device.
111
+
112
+ Please create an issue on GitHub and include:
113
+ - Device model name/number
114
+ - Device type
115
+ - Any error messages or unexpected behavior
116
+ - Sniffed device data (if available)
117
+
118
+ [Create an issue →](https://github.com/Doekse/merossiot/issues)
119
+
120
+ ## Changelog
121
+
122
+ ### [0.1.0] - 2026-01-10
123
+
124
+ #### Added
125
+ - Initial release of MerossIot Node.js library
126
+ - Meross Cloud authentication and token management
127
+ - Device discovery and enumeration
128
+ - MQTT cloud server connection support
129
+ - HTTP local device control support
130
+ - Support for various device types (switches, lights, sensors, etc.)
131
+ - Hub device and subdevice support
132
+ - Event handling for device updates and state changes
133
+ - Error handling with comprehensive error types
134
+ - Statistics tracking for API calls
135
+ - Command-line interface (CLI) for testing and debugging
136
+ - TypeScript type definitions
137
+ - Examples in the `example/` directory
138
+
139
+ #### Known Issues
140
+ - This is an initial, pre-stable release. Please expect bugs.
141
+ - Some edge cases may not be fully handled yet.
142
+
143
+ <details>
144
+ <summary>Older</summary>
145
+
146
+ <!-- Older changelog entries will appear here -->
147
+
148
+ </details>
149
+
150
+ ## Disclaimer
151
+
152
+ **All product and company names or logos are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them or any associated subsidiaries! This personal project is maintained in spare time and has no business goal.**
153
+ **MEROSS is a trademark of Chengdu Meross Technology Co., Ltd.**