diff options
| -rw-r--r-- | README.md | 162 | ||||
| -rw-r--r-- | jest.config.js (renamed from packages/airmx/jest.config.js) | 0 | ||||
| -rw-r--r-- | package.json | 39 | ||||
| -rw-r--r-- | packages/airmx/LICENSE | 21 | ||||
| -rw-r--r-- | packages/airmx/README.md | 161 | ||||
| -rw-r--r-- | packages/airmx/package.json | 38 | ||||
| -rw-r--r-- | src/airmx.test.ts (renamed from packages/airmx/src/airmx.test.ts) | 0 | ||||
| -rw-r--r-- | src/airmx.ts (renamed from packages/airmx/src/airmx.ts) | 0 | ||||
| -rw-r--r-- | src/eagle.test.ts (renamed from packages/airmx/src/eagle.test.ts) | 0 | ||||
| -rw-r--r-- | src/eagle.ts (renamed from packages/airmx/src/eagle.ts) | 0 | ||||
| -rw-r--r-- | src/index.ts (renamed from packages/airmx/src/index.ts) | 0 | ||||
| -rw-r--r-- | src/messages.ts (renamed from packages/airmx/src/messages.ts) | 0 | ||||
| -rw-r--r-- | src/snow.ts (renamed from packages/airmx/src/snow.ts) | 0 | ||||
| -rw-r--r-- | src/types.ts (renamed from packages/airmx/src/types.ts) | 0 | ||||
| -rw-r--r-- | src/util.ts (renamed from packages/airmx/src/util.ts) | 0 | ||||
| -rw-r--r-- | tsconfig.json (renamed from packages/airmx/tsconfig.json) | 0 |
16 files changed, 194 insertions, 227 deletions
@@ -1 +1,161 @@ -# AIRMX +# Control AIRMX Pro with JavaScript + +The package utilizes the MQTT protocol to communicate with your AIRMX devices. +Once connected to the server, it constantly monitors the status updates from +your machines. Additionally, it provides a set of useful APIs to facilitate +smooth control of your devices. + +## Installation + +The package can be installed via NPM: + +```bash +npm i airmx +``` + +## Usage + +First of all, we need to initialize an AIRMX client before we can monitor or +control our machines: + +```typescript +import mqtt from 'mqtt' + +const airmx = new Airmx({ + mqtt: mqtt.connect('mqtt://<YOUR-MQTT-SERVER>'), + devices: [ + { id: <YOUR-DEVICE-ID>, key: '<YOUR-DEVICE-KEY>' } + ] +}) +``` + +You can register a handler when an AIRMX Pro sends us its latest status. + +```typescript +airmx.onEagleUpdate((status: EagleStatus) => { + console.log(`🎈 AIRMX: ${status.deviceId} ${status.power ? 'on' : 'off'}`) +}) +``` + +Sending commands directly to your machines is simple with the control API. +Just provide the device ID and control data. + +```typescript +airmx.control(1, { + power: 1, // 1 indicates on + mode: 0, // 0 indicates manual control + cadr: 47, // CADR accepts a number range from 0 - 100 + denoise: 0, // 0 indicates off + heatStatus: 0 // 0 indicates off +}) +``` + +Dealing with the control API's fixed data structure can be tedious. That's +why we built a semantic and fluent API for easier device control. Its method +names are so intuitive, you'll instantly grasp their function. + +```typescript +// Turn on the machine +airmx.device(1).on() + +// Turn off the machine +airmx.device(1).off() + +// Turn on heat mode +airmx.device(1).heatOn() + +// Turn off heat mode +airmx.device(1).heatOff() + +// Turn on noise cancelling mode +airmx.device(1).denoiseOn() + +// Turn off noise cancelling mode +airmx.device(1).denoiseOff() + +// Adjust the CADR value (fan speed) +airmx.device(1).cadr(47) +``` + +The library replicates the built-in modes available in the official mobile +applications: + +- **AI Mode:** Automatically adjusts CADR (Clean Air Delivery Rate) based + on data from a paired air monitor. +- **Silent Mode:** Reduces fan speed to minimize noise output. +- **Turbo Mode:** Maximizes the device's purification capability, operating + at 100% fan speed for rapid air cleaning. + +```typescript +airmx.device(1).ai() +airmx.device(1).slient() +airmx.device(1).turbo() +``` + +Whenever a device sends an update or you request its current state, you'll +get an EagleStatus object with all the latest information. + +```typescript +airmx.device(1).status() +``` + +## AIRMX Pro Status Reference + +```typescript +// Determine the device's power status +// +// Data type: boolean + +status.isOn() +status.isOff() + +// Determine if the machine is set to silent mode +// +// Data type: boolean + +status.isSilentMode() + +// Determine if noise cancelling is enabled +// +// Data type: boolean + +status.isDenoiseOn() +status.isDenoiseOff() + +// Determine if AUX heat is enabled +// +// Data type: boolean + +status.isHeaterOn() +status.isHeaterOff() + +// The current Clean Air Delivery Rate +// +// Data type: number (0 - 100) + +status.cadr + +// The filter identifications +// +// Data type: string + +status.g4Id +status.carbonId +status.hepaId + +// The usage percentage for the filters +// +// Data type: number +// Value range: 0 - 100 +// +// 0 indicates the filter is brand new +// 100 indicates the filter is run out, and should be replaced + +status.g4Percent +status.carbonPercent +status.hepaPercent +``` + +## License + +This package is released under [the MIT license](LICENSE). diff --git a/packages/airmx/jest.config.js b/jest.config.js index fbde747..fbde747 100644 --- a/packages/airmx/jest.config.js +++ b/jest.config.js diff --git a/package.json b/package.json index 4568912..d77e5fd 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,39 @@ { - "private": true, + "name": "airmx", + "version": "0.0.1", + "description": "Control AIRMX Pro with JavaScript.", + "type": "module", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "files": [ + "dist" + ], "scripts": { + "build": "tsc", + "test": "jest", + "test:watch": "jest --watch --verbose", "format": "prettier --write --cache ." }, - "devDependencies": { - "prettier": "3.6.2" + "repository": { + "type": "git", + "url": "git+https://github.com/openairmx/airmx.git" + }, + "keywords": [ + "airmx", + "mqtt" + ], + "author": "Li Zhineng <[email protected]>", + "license": "MIT", + "bugs": { + "url": "https://github.com/openairmx/airmx/issues" }, - "workspaces": [ - "packages/airmx" - ] + "homepage": "https://github.com/openairmx/airmx#readme", + "peerDependencies": { + "mqtt": "^5.0.0" + }, + "devDependencies": { + "@types/jest": "^29.5.14", + "mqtt": "^5.0.0", + "ts-jest": "^29.2.5" + } } diff --git a/packages/airmx/LICENSE b/packages/airmx/LICENSE deleted file mode 100644 index b72df28..0000000 --- a/packages/airmx/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2024 Li Zhineng - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/airmx/README.md b/packages/airmx/README.md deleted file mode 100644 index c5cce11..0000000 --- a/packages/airmx/README.md +++ /dev/null @@ -1,161 +0,0 @@ -# Control AIRMX Pro with JavaScript - -The package utilizes the MQTT protocol to communicate with your AIRMX devices. -Once connected to the server, it constantly monitors the status updates from -your machines. Additionally, it provides a set of useful APIs to facilitate -smooth control of your devices. - -## Installation - -The package can be installed via NPM: - -```bash -npm i airmx -``` - -## Usage - -First of all, we need to initialize an AIRMX client before we can monitor or -control our machines: - -```typescript -import mqtt from 'mqtt' - -const airmx = new Airmx({ - mqtt: mqtt.connect('mqtt://<YOUR-MQTT-SERVER>'), - devices: [ - { id: <YOUR-DEVICE-ID>, key: '<YOUR-DEVICE-KEY>' } - ] -}) -``` - -You can register a handler when an AIRMX Pro sends us its latest status. - -```typescript -airmx.onEagleUpdate((status: EagleStatus) => { - console.log(`🎈 AIRMX: ${status.deviceId} ${status.power ? 'on' : 'off'}`) -}) -``` - -Sending commands directly to your machines is simple with the control API. -Just provide the device ID and control data. - -```typescript -airmx.control(1, { - power: 1, // 1 indicates on - mode: 0, // 0 indicates manual control - cadr: 47, // CADR accepts a number range from 0 - 100 - denoise: 0, // 0 indicates off - heatStatus: 0 // 0 indicates off -}) -``` - -Dealing with the control API's fixed data structure can be tedious. That's -why we built a semantic and fluent API for easier device control. Its method -names are so intuitive, you'll instantly grasp their function. - -```typescript -// Turn on the machine -airmx.device(1).on() - -// Turn off the machine -airmx.device(1).off() - -// Turn on heat mode -airmx.device(1).heatOn() - -// Turn off heat mode -airmx.device(1).heatOff() - -// Turn on noise cancelling mode -airmx.device(1).denoiseOn() - -// Turn off noise cancelling mode -airmx.device(1).denoiseOff() - -// Adjust the CADR value (fan speed) -airmx.device(1).cadr(47) -``` - -The library replicates the built-in modes available in the official mobile -applications: - -- **AI Mode:** Automatically adjusts CADR (Clean Air Delivery Rate) based - on data from a paired air monitor. -- **Silent Mode:** Reduces fan speed to minimize noise output. -- **Turbo Mode:** Maximizes the device's purification capability, operating - at 100% fan speed for rapid air cleaning. - -```typescript -airmx.device(1).ai() -airmx.device(1).slient() -airmx.device(1).turbo() -``` - -Whenever a device sends an update or you request its current state, you'll -get an EagleStatus object with all the latest information. - -```typescript -airmx.device(1).status() -``` - -## AIRMX Pro Status Reference - -```typescript -// Determine the device's power status -// -// Data type: boolean - -status.isOn() -status.isOff() - -// Determine if the machine is set to silent mode -// -// Data type: boolean - -status.isSilentMode() - -// Determine if noise cancelling is enabled -// -// Data type: boolean - -status.isDenoiseOn() -status.isDenoiseOff() - -// Determine if AUX heat is enabled -// -// Data type: boolean - -status.isHeaterOn() -status.isHeaterOff() - -// The current Clean Air Delivery Rate -// -// Data type: number (0 - 100) - -status.cadr - -// The filter identifications -// -// Data type: string - -status.g4Id -status.carbonId -status.hepaId - -// The usage percentage for the filters -// -// Data type: number -// Value range: 0 - 100 -// -// 0 indicates the filter is brand new -// 100 indicates the filter is run out, and should be replaced - -status.g4Percent -status.carbonPercent -status.hepaPercent -``` - -## License - -This package is released under [the MIT license](LICENSE). diff --git a/packages/airmx/package.json b/packages/airmx/package.json deleted file mode 100644 index 9125dac..0000000 --- a/packages/airmx/package.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "name": "airmx", - "version": "0.0.1", - "description": "Control AIRMX Pro with JavaScript.", - "type": "module", - "main": "dist/index.js", - "types": "dist/index.d.ts", - "files": [ - "dist" - ], - "scripts": { - "build": "tsc", - "test": "jest", - "test:watch": "jest --watch --verbose" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/openairmx/airmx.git" - }, - "keywords": [ - "airmx", - "mqtt" - ], - "author": "Li Zhineng <[email protected]>", - "license": "MIT", - "bugs": { - "url": "https://github.com/openairmx/airmx/issues" - }, - "homepage": "https://github.com/openairmx/airmx#readme", - "peerDependencies": { - "mqtt": "^5.0.0" - }, - "devDependencies": { - "@types/jest": "^29.5.14", - "mqtt": "^5.0.0", - "ts-jest": "^29.2.5" - } -} diff --git a/packages/airmx/src/airmx.test.ts b/src/airmx.test.ts index aee5bbe..aee5bbe 100644 --- a/packages/airmx/src/airmx.test.ts +++ b/src/airmx.test.ts diff --git a/packages/airmx/src/airmx.ts b/src/airmx.ts index a507260..a507260 100644 --- a/packages/airmx/src/airmx.ts +++ b/src/airmx.ts diff --git a/packages/airmx/src/eagle.test.ts b/src/eagle.test.ts index 2af1bd4..2af1bd4 100644 --- a/packages/airmx/src/eagle.test.ts +++ b/src/eagle.test.ts diff --git a/packages/airmx/src/eagle.ts b/src/eagle.ts index dbe74cc..dbe74cc 100644 --- a/packages/airmx/src/eagle.ts +++ b/src/eagle.ts diff --git a/packages/airmx/src/index.ts b/src/index.ts index 1002c35..1002c35 100644 --- a/packages/airmx/src/index.ts +++ b/src/index.ts diff --git a/packages/airmx/src/messages.ts b/src/messages.ts index 66c63d1..66c63d1 100644 --- a/packages/airmx/src/messages.ts +++ b/src/messages.ts diff --git a/packages/airmx/src/snow.ts b/src/snow.ts index a5a0c05..a5a0c05 100644 --- a/packages/airmx/src/snow.ts +++ b/src/snow.ts diff --git a/packages/airmx/src/types.ts b/src/types.ts index 32ca95b..32ca95b 100644 --- a/packages/airmx/src/types.ts +++ b/src/types.ts diff --git a/packages/airmx/src/util.ts b/src/util.ts index b5cbd4b..b5cbd4b 100644 --- a/packages/airmx/src/util.ts +++ b/src/util.ts diff --git a/packages/airmx/tsconfig.json b/tsconfig.json index 74ccc18..74ccc18 100644 --- a/packages/airmx/tsconfig.json +++ b/tsconfig.json |
