summaryrefslogtreecommitdiff
path: root/README.md
blob: d8804159ad492fb94fdd3599db461e594dd58a9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# Control AIRMX Pro 1S with Javascript

This package uses the MQTT protocol to communicate with your AIRMX machine.
However, some prerequisites must be met for this communication to work.
Because the AIRMX machine doesn't have built-in support for extending
connections, we need to intercept network packets to obtain the machine ID
and access token. Furthermore, network firewall rules are required to redirect
packets from the AIRMX machine to our computing platform.

## Installation

The package can be installed via NPM:

```bash
npm i @lizhineng/airmx
```

## Usage

### Setup

First of all, we need to initialize an AIRMX client before we can
communicate with our machine:

```typescript
const airmx = new Airmx({
    mqtt: {
        // MQTT server configuration
    },
    machines: [
        {
            machineId: 1234, // Your machine ID
            token: '<YOUR-ACCESS-TOKEN>', // The access token
        }
    ]
})
```

If you only need to monitor your machines and don't intend to control them,
you can skip the entire "machines" setting.

### Control

The package exposes a list of APIs to control the machine effortlessly.

Turn the machine on:

```typescript
airmx.on()
```

Turn the machine off:

```typescript
airmx.off()
```

Control the fan speed:

```typescript
airmx.setFanByCidr(cidr: number)
airmx.setFanByPercentage(percentage: number)
airmx.setAutoFan()
```

Control the AUX heat:

```typescript
airmx.setAuxHeat(heat: boolean)
```

Control the denose function:

```typescript
airmx.setDenoise(denose: boolean)
```

### Monitor

Get the running status of the machine through the status properties:

```typescript
// Determine if the machine power is on
//
// Data type: boolean

airmx.status.on

// Determine if the machine power is off
//
// Data type: boolean

airmx.status.off

// Determine if the machine power is on
//
// Data type: boolean
//
// true: The machine is on
// false: The machine is off

airmx.status.power

// The value of Clean Air Delivery Rate (CADR)
//
// Data type: number

airmx.status.cidr

// The percentage value of the fan speed
//
// Data type: number

airmx.status.fan_percentage 

// Determine if the fan speed is automatically controlled by the machine
//
// Data type: boolean

airmx.status.auto_fan

// Determine whether the AUX heat function is turned on
//
// Data type: boolean

airmx.status.aux_heat

// The percentage to replace the G4 filter
//
// 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

airmx.status.filters.g4

// The percentage to replace the carbon filter
//
// 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

airmx.status.filters.carbon

// The percentage to replace the HEPA filter
//
// 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

airmx.status.filters.hepa
```

## License

This package is released under the MIT License.