@switchbot/homebridge-switchbot 1.8.3-beta.0 → 1.10.1-beta.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/.eslintrc +14 -45
- package/.github/ISSUE_TEMPLATE/bug-report.yml +3 -3
- package/.github/ISSUE_TEMPLATE/feature-request.yml +2 -2
- package/.github/ISSUE_TEMPLATE/support-request.yml +3 -3
- package/.github/labeler.yml +1 -1
- package/.github/workflows/codeql-analysis.yml +29 -29
- package/.github/workflows/nodejs-beta.yml +1 -1
- package/.github/workflows/prerelease-beta.js +1 -1
- package/.github/workflows/stale.yml +1 -1
- package/.prettierrc +9 -0
- package/.vscode/extensions.json +2 -4
- package/.vscode/settings.json +14 -2
- package/CHANGELOG.md +16 -0
- package/README.md +100 -99
- package/SECURITY.md +2 -2
- package/config.schema.json +17 -0
- package/dist/devices/bots.d.ts +35 -32
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +168 -210
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.d.ts +35 -35
- package/dist/devices/colorbulb.d.ts.map +1 -1
- package/dist/devices/colorbulb.js +83 -108
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.d.ts +27 -25
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +110 -131
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +29 -27
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +147 -182
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.d.ts +31 -31
- package/dist/devices/humidifiers.d.ts.map +1 -1
- package/dist/devices/humidifiers.js +154 -181
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/meters.d.ts +29 -28
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +98 -120
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +24 -23
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +97 -113
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.d.ts +16 -16
- package/dist/devices/plugs.d.ts.map +1 -1
- package/dist/devices/plugs.js +48 -71
- package/dist/devices/plugs.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -22
- package/dist/index.js.map +1 -1
- package/dist/irdevices/airconditioners.d.ts +7 -4
- package/dist/irdevices/airconditioners.d.ts.map +1 -1
- package/dist/irdevices/airconditioners.js +72 -93
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.d.ts +3 -3
- package/dist/irdevices/airpurifiers.d.ts.map +1 -1
- package/dist/irdevices/airpurifiers.js +32 -51
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.d.ts +3 -3
- package/dist/irdevices/cameras.d.ts.map +1 -1
- package/dist/irdevices/cameras.js +19 -26
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.d.ts +3 -3
- package/dist/irdevices/fans.d.ts.map +1 -1
- package/dist/irdevices/fans.js +35 -44
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.d.ts +3 -3
- package/dist/irdevices/lights.d.ts.map +1 -1
- package/dist/irdevices/lights.js +25 -32
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.d.ts +3 -3
- package/dist/irdevices/others.d.ts.map +1 -1
- package/dist/irdevices/others.js +21 -29
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.d.ts +3 -3
- package/dist/irdevices/tvs.d.ts.map +1 -1
- package/dist/irdevices/tvs.js +66 -89
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts +3 -3
- package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.js +18 -24
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.d.ts +3 -3
- package/dist/irdevices/waterheaters.d.ts.map +1 -1
- package/dist/irdevices/waterheaters.js +19 -26
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/dist/platform.d.ts +10 -10
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +163 -233
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +3 -1
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +4 -4
- package/dist/settings.js.map +1 -1
- package/homebridge-ui/public/index.html +231 -245
- package/homebridge-ui/server.js +2 -4
- package/nodemon.json +2 -4
- package/package.json +17 -12
- package/src/devices/bots.ts +411 -854
- package/src/devices/colorbulb.ts +187 -408
- package/src/devices/contact.ts +210 -376
- package/src/devices/curtains.ts +288 -563
- package/src/devices/humidifiers.ts +291 -537
- package/src/devices/meters.ts +189 -331
- package/src/devices/motion.ts +188 -322
- package/src/devices/plugs.ts +88 -160
- package/src/index.ts +5 -5
- package/src/irdevices/airconditioners.ts +139 -318
- package/src/irdevices/airpurifiers.ts +71 -170
- package/src/irdevices/cameras.ts +44 -103
- package/src/irdevices/fans.ts +70 -165
- package/src/irdevices/lights.ts +49 -104
- package/src/irdevices/others.ts +55 -131
- package/src/irdevices/tvs.ts +114 -247
- package/src/irdevices/vacuumcleaners.ts +44 -104
- package/src/irdevices/waterheaters.ts +49 -121
- package/src/platform.ts +341 -753
- package/src/settings.ts +8 -11
- package/tsconfig.json +5 -14
- package/.github/PULL_REQUEST_TEMPLATE/pull_requests.md +0 -27
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AxiosResponse } from
|
|
2
|
-
import { SwitchBotPlatform } from
|
|
3
|
-
import { irDevicesConfig, DeviceURL, irdevice, payload } from
|
|
4
|
-
import { CharacteristicValue, PlatformAccessory, Service } from
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
import { SwitchBotPlatform } from '../platform';
|
|
3
|
+
import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
|
|
4
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -38,11 +38,7 @@ export class AirPurifier {
|
|
|
38
38
|
// Config
|
|
39
39
|
deviceLogging!: string;
|
|
40
40
|
|
|
41
|
-
constructor(
|
|
42
|
-
private readonly platform: SwitchBotPlatform,
|
|
43
|
-
private accessory: PlatformAccessory,
|
|
44
|
-
public device: irdevice & irDevicesConfig,
|
|
45
|
-
) {
|
|
41
|
+
constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
|
|
46
42
|
// default placeholders
|
|
47
43
|
this.logs(device);
|
|
48
44
|
this.config(device);
|
|
@@ -60,18 +56,13 @@ export class AirPurifier {
|
|
|
60
56
|
// set accessory information
|
|
61
57
|
accessory
|
|
62
58
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
63
|
-
.setCharacteristic(this.platform.Characteristic.Manufacturer,
|
|
59
|
+
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
64
60
|
.setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
|
|
65
|
-
.setCharacteristic(
|
|
66
|
-
this.platform.Characteristic.SerialNumber,
|
|
67
|
-
device.deviceId!,
|
|
68
|
-
);
|
|
61
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
|
|
69
62
|
|
|
70
63
|
// get the Television service if it exists, otherwise create a new Television service
|
|
71
64
|
// you can create multiple services for each accessory
|
|
72
|
-
(this.service =
|
|
73
|
-
accessory.getService(this.platform.Service.AirPurifier) ||
|
|
74
|
-
accessory.addService(this.platform.Service.AirPurifier)),
|
|
65
|
+
(this.service = accessory.getService(this.platform.Service.AirPurifier) || accessory.addService(this.platform.Service.AirPurifier)),
|
|
75
66
|
`${accessory.displayName} Air Purifier`;
|
|
76
67
|
|
|
77
68
|
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
@@ -80,31 +71,20 @@ export class AirPurifier {
|
|
|
80
71
|
|
|
81
72
|
// set the service name, this is what is displayed as the default name on the Home app
|
|
82
73
|
// in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
|
|
83
|
-
this.service.setCharacteristic(
|
|
84
|
-
this.platform.Characteristic.Name,
|
|
85
|
-
accessory.displayName,
|
|
86
|
-
);
|
|
74
|
+
this.service.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
87
75
|
|
|
88
76
|
// handle on / off events using the Active characteristic
|
|
89
|
-
this.service
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return this.CurrentAirPurifierStateGet();
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
this.service
|
|
100
|
-
.getCharacteristic(this.platform.Characteristic.TargetAirPurifierState)
|
|
101
|
-
.onSet(this.TargetAirPurifierStateSet.bind(this));
|
|
77
|
+
this.service.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
|
|
78
|
+
|
|
79
|
+
this.service.getCharacteristic(this.platform.Characteristic.CurrentAirPurifierState).onGet(() => {
|
|
80
|
+
return this.CurrentAirPurifierStateGet();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
this.service.getCharacteristic(this.platform.Characteristic.TargetAirPurifierState).onSet(this.TargetAirPurifierStateSet.bind(this));
|
|
102
84
|
}
|
|
103
85
|
|
|
104
86
|
private ActiveSet(value: CharacteristicValue) {
|
|
105
|
-
this.debugLog(
|
|
106
|
-
`Air Purifier: ${this.accessory.displayName} Set Active: ${value}`,
|
|
107
|
-
);
|
|
87
|
+
this.debugLog(`Air Purifier: ${this.accessory.displayName} Set Active: ${value}`);
|
|
108
88
|
if (value === this.platform.Characteristic.Active.INACTIVE) {
|
|
109
89
|
this.pushAirPurifierOffChanges();
|
|
110
90
|
} else {
|
|
@@ -117,44 +97,23 @@ export class AirPurifier {
|
|
|
117
97
|
|
|
118
98
|
private updateHomeKitCharacteristics() {
|
|
119
99
|
if (this.Active === undefined) {
|
|
120
|
-
this.debugLog(
|
|
121
|
-
`Air Purifier: ${this.accessory.displayName} Active: ${this.Active}`,
|
|
122
|
-
);
|
|
100
|
+
this.debugLog(`Air Purifier: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
123
101
|
} else {
|
|
124
|
-
this.service?.updateCharacteristic(
|
|
125
|
-
|
|
126
|
-
this.Active,
|
|
127
|
-
);
|
|
128
|
-
this.debugLog(
|
|
129
|
-
`Air Purifier: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`,
|
|
130
|
-
);
|
|
102
|
+
this.service?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
|
|
103
|
+
this.debugLog(`Air Purifier: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
|
|
131
104
|
}
|
|
132
105
|
if (this.CurrentAirPurifierState === undefined) {
|
|
133
|
-
this.debugLog(
|
|
134
|
-
`Air Purifier: ${this.accessory.displayName} CurrentAirPurifierState: ${this.CurrentAirPurifierState}`,
|
|
135
|
-
);
|
|
106
|
+
this.debugLog(`Air Purifier: ${this.accessory.displayName} CurrentAirPurifierState: ${this.CurrentAirPurifierState}`);
|
|
136
107
|
} else {
|
|
137
|
-
this.service?.updateCharacteristic(
|
|
138
|
-
|
|
139
|
-
this.CurrentAirPurifierState,
|
|
140
|
-
);
|
|
141
|
-
this.debugLog(
|
|
142
|
-
`Air Purifier: ${this.accessory.displayName}` +
|
|
143
|
-
` updateCharacteristic CurrentAirPurifierState: ${this.CurrentAirPurifierState}`,
|
|
144
|
-
);
|
|
108
|
+
this.service?.updateCharacteristic(this.platform.Characteristic.CurrentAirPurifierState, this.CurrentAirPurifierState);
|
|
109
|
+
this.debugLog(`Air Purifier: ${this.accessory.displayName}` + ` updateCharacteristic CurrentAirPurifierState: ${this.CurrentAirPurifierState}`);
|
|
145
110
|
}
|
|
146
111
|
if (this.CurrentHeaterCoolerState === undefined) {
|
|
147
|
-
this.debugLog(
|
|
148
|
-
`Air Purifier: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
149
|
-
);
|
|
112
|
+
this.debugLog(`Air Purifier: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
150
113
|
} else {
|
|
151
|
-
this.service?.updateCharacteristic(
|
|
152
|
-
this.platform.Characteristic.CurrentHeaterCoolerState,
|
|
153
|
-
this.CurrentHeaterCoolerState,
|
|
154
|
-
);
|
|
114
|
+
this.service?.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
|
|
155
115
|
this.debugLog(
|
|
156
|
-
`Air Purifier: ${this.accessory.displayName}` +
|
|
157
|
-
` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
116
|
+
`Air Purifier: ${this.accessory.displayName}` + ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
158
117
|
);
|
|
159
118
|
}
|
|
160
119
|
}
|
|
@@ -177,11 +136,9 @@ export class AirPurifier {
|
|
|
177
136
|
|
|
178
137
|
private CurrentAirPurifierStateGet() {
|
|
179
138
|
if (this.Active === 1) {
|
|
180
|
-
this.CurrentAirPurifierState =
|
|
181
|
-
this.platform.Characteristic.CurrentAirPurifierState.PURIFYING_AIR;
|
|
139
|
+
this.CurrentAirPurifierState = this.platform.Characteristic.CurrentAirPurifierState.PURIFYING_AIR;
|
|
182
140
|
} else {
|
|
183
|
-
this.CurrentAirPurifierState =
|
|
184
|
-
this.platform.Characteristic.CurrentAirPurifierState.INACTIVE;
|
|
141
|
+
this.CurrentAirPurifierState = this.platform.Characteristic.CurrentAirPurifierState.INACTIVE;
|
|
185
142
|
}
|
|
186
143
|
return this.CurrentAirPurifierState;
|
|
187
144
|
}
|
|
@@ -200,9 +157,9 @@ export class AirPurifier {
|
|
|
200
157
|
async pushAirPurifierOnChanges() {
|
|
201
158
|
if (this.Active !== 1) {
|
|
202
159
|
const payload = {
|
|
203
|
-
commandType:
|
|
204
|
-
parameter:
|
|
205
|
-
command:
|
|
160
|
+
commandType: 'command',
|
|
161
|
+
parameter: 'default',
|
|
162
|
+
command: 'turnOn',
|
|
206
163
|
} as payload;
|
|
207
164
|
await this.pushChanges(payload);
|
|
208
165
|
}
|
|
@@ -211,9 +168,9 @@ export class AirPurifier {
|
|
|
211
168
|
async pushAirPurifierOffChanges() {
|
|
212
169
|
if (this.Active !== 0) {
|
|
213
170
|
const payload = {
|
|
214
|
-
commandType:
|
|
215
|
-
parameter:
|
|
216
|
-
command:
|
|
171
|
+
commandType: 'command',
|
|
172
|
+
parameter: 'default',
|
|
173
|
+
command: 'turnOff',
|
|
217
174
|
} as payload;
|
|
218
175
|
await this.pushChanges(payload);
|
|
219
176
|
}
|
|
@@ -222,41 +179,34 @@ export class AirPurifier {
|
|
|
222
179
|
async pushAirConditionerStatusChanges() {
|
|
223
180
|
if (!this.Busy) {
|
|
224
181
|
this.Busy = true;
|
|
225
|
-
this.CurrentHeaterCoolerState =
|
|
226
|
-
this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
|
|
182
|
+
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
|
|
227
183
|
}
|
|
228
184
|
clearTimeout(this.Timeout);
|
|
229
185
|
|
|
230
186
|
// Make a new Timeout set to go off in 1000ms (1 second)
|
|
231
|
-
this.Timeout = setTimeout(
|
|
232
|
-
this.pushAirConditionerDetailsChanges.bind(this),
|
|
233
|
-
1500,
|
|
234
|
-
);
|
|
187
|
+
this.Timeout = setTimeout(this.pushAirConditionerDetailsChanges.bind(this), 1500);
|
|
235
188
|
}
|
|
236
189
|
|
|
237
190
|
async pushAirConditionerDetailsChanges() {
|
|
238
191
|
const payload = {
|
|
239
|
-
commandType:
|
|
240
|
-
command:
|
|
192
|
+
commandType: 'command',
|
|
193
|
+
command: 'setAll',
|
|
241
194
|
} as payload;
|
|
242
195
|
|
|
243
196
|
this.CurrentAPTemp = this.CurrentTemperature || 24;
|
|
244
197
|
this.CurrentAPMode = this.CurrentMode || 1;
|
|
245
198
|
this.CurrentAPFanSpeed = this.CurrentFanSpeed || 1;
|
|
246
|
-
this.APActive = this.Active === 1 ?
|
|
199
|
+
this.APActive = this.Active === 1 ? 'on' : 'off';
|
|
247
200
|
payload.parameter = `${this.CurrentAPTemp},${this.CurrentAPMode},${this.CurrentAPFanSpeed},${this.APActive}`;
|
|
248
201
|
|
|
249
202
|
if (this.Active === 1) {
|
|
250
203
|
if ((this.CurrentTemperature || 24) < (this.LastTemperature || 30)) {
|
|
251
|
-
this.CurrentHeaterCoolerState =
|
|
252
|
-
this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
204
|
+
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
253
205
|
} else {
|
|
254
|
-
this.CurrentHeaterCoolerState =
|
|
255
|
-
this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
206
|
+
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
256
207
|
}
|
|
257
208
|
} else {
|
|
258
|
-
this.CurrentHeaterCoolerState =
|
|
259
|
-
this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
209
|
+
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
260
210
|
}
|
|
261
211
|
|
|
262
212
|
await this.pushChanges(payload);
|
|
@@ -270,32 +220,21 @@ export class AirPurifier {
|
|
|
270
220
|
);
|
|
271
221
|
|
|
272
222
|
// Make the API request
|
|
273
|
-
const push = await this.platform.axios.post(
|
|
274
|
-
|
|
275
|
-
payload,
|
|
276
|
-
);
|
|
277
|
-
this.debugLog(
|
|
278
|
-
`Air Purifier: ${this.accessory.displayName} pushChanges: ${push.data}`,
|
|
279
|
-
);
|
|
223
|
+
const push = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
|
|
224
|
+
this.debugLog(`Air Purifier: ${this.accessory.displayName} pushChanges: ${push.data}`);
|
|
280
225
|
this.statusCode(push);
|
|
281
226
|
this.updateHomeKitCharacteristics();
|
|
282
227
|
this.CurrentTemperatureCached = this.CurrentTemperature;
|
|
283
228
|
this.accessory.context.CurrentTemperature = this.CurrentTemperatureCached;
|
|
284
229
|
} catch (e: any) {
|
|
285
|
-
this.errorLog(
|
|
286
|
-
|
|
287
|
-
);
|
|
288
|
-
if (this.deviceLogging === "debug") {
|
|
230
|
+
this.errorLog(`Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
|
|
231
|
+
if (this.deviceLogging === 'debug') {
|
|
289
232
|
this.errorLog(
|
|
290
|
-
`Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
|
|
291
|
-
` Error Message: ${JSON.stringify(e.message)}`,
|
|
233
|
+
`Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
|
|
292
234
|
);
|
|
293
235
|
}
|
|
294
236
|
if (this.platform.debugMode) {
|
|
295
|
-
this.errorLog(
|
|
296
|
-
`Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
|
|
297
|
-
` Error: ${JSON.stringify(e)}`,
|
|
298
|
-
);
|
|
237
|
+
this.errorLog(`Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
|
|
299
238
|
}
|
|
300
239
|
this.apiError(e);
|
|
301
240
|
}
|
|
@@ -304,63 +243,38 @@ export class AirPurifier {
|
|
|
304
243
|
private statusCode(push: AxiosResponse<{ statusCode: number }>) {
|
|
305
244
|
switch (push.data.statusCode) {
|
|
306
245
|
case 151:
|
|
307
|
-
this.errorLog(
|
|
308
|
-
`Air Purifier: ${this.accessory.displayName} Command not supported by this device type.`,
|
|
309
|
-
);
|
|
246
|
+
this.errorLog(`Air Purifier: ${this.accessory.displayName} Command not supported by this device type.`);
|
|
310
247
|
break;
|
|
311
248
|
case 152:
|
|
312
|
-
this.errorLog(
|
|
313
|
-
`Air Purifier: ${this.accessory.displayName} Device not found.`,
|
|
314
|
-
);
|
|
249
|
+
this.errorLog(`Air Purifier: ${this.accessory.displayName} Device not found.`);
|
|
315
250
|
break;
|
|
316
251
|
case 160:
|
|
317
|
-
this.errorLog(
|
|
318
|
-
`Air Purifier: ${this.accessory.displayName} Command is not supported.`,
|
|
319
|
-
);
|
|
252
|
+
this.errorLog(`Air Purifier: ${this.accessory.displayName} Command is not supported.`);
|
|
320
253
|
break;
|
|
321
254
|
case 161:
|
|
322
|
-
this.errorLog(
|
|
323
|
-
`Air Purifier: ${this.accessory.displayName} Device is offline.`,
|
|
324
|
-
);
|
|
255
|
+
this.errorLog(`Air Purifier: ${this.accessory.displayName} Device is offline.`);
|
|
325
256
|
break;
|
|
326
257
|
case 171:
|
|
327
|
-
this.errorLog(
|
|
328
|
-
`Air Purifier: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`,
|
|
329
|
-
);
|
|
258
|
+
this.errorLog(`Air Purifier: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
330
259
|
break;
|
|
331
260
|
case 190:
|
|
332
261
|
this.errorLog(
|
|
333
262
|
`Air Purifier: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
|
|
334
|
-
` with server, Or command: ${JSON.stringify(
|
|
335
|
-
push.data,
|
|
336
|
-
)} format is invalid`,
|
|
263
|
+
` with server, Or command: ${JSON.stringify(push.data)} format is invalid`,
|
|
337
264
|
);
|
|
338
265
|
break;
|
|
339
266
|
case 100:
|
|
340
|
-
this.debugLog(
|
|
341
|
-
`Air Purifier: ${this.accessory.displayName} Command successfully sent.`,
|
|
342
|
-
);
|
|
267
|
+
this.debugLog(`Air Purifier: ${this.accessory.displayName} Command successfully sent.`);
|
|
343
268
|
break;
|
|
344
269
|
default:
|
|
345
|
-
this.debugLog(
|
|
346
|
-
`Air Purifier: ${this.accessory.displayName} Unknown statusCode.`,
|
|
347
|
-
);
|
|
270
|
+
this.debugLog(`Air Purifier: ${this.accessory.displayName} Unknown statusCode.`);
|
|
348
271
|
}
|
|
349
272
|
}
|
|
350
273
|
|
|
351
274
|
public apiError(e: any) {
|
|
352
|
-
this.service.updateCharacteristic(
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
);
|
|
356
|
-
this.service.updateCharacteristic(
|
|
357
|
-
this.platform.Characteristic.CurrentAirPurifierState,
|
|
358
|
-
e,
|
|
359
|
-
);
|
|
360
|
-
this.service.updateCharacteristic(
|
|
361
|
-
this.platform.Characteristic.TargetAirPurifierState,
|
|
362
|
-
e,
|
|
363
|
-
);
|
|
275
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, e);
|
|
276
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CurrentAirPurifierState, e);
|
|
277
|
+
this.service.updateCharacteristic(this.platform.Characteristic.TargetAirPurifierState, e);
|
|
364
278
|
this.service.updateCharacteristic(this.platform.Characteristic.Active, e);
|
|
365
279
|
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
366
280
|
}
|
|
@@ -371,39 +285,26 @@ export class AirPurifier {
|
|
|
371
285
|
config = device.irpur;
|
|
372
286
|
}
|
|
373
287
|
if (device.logging !== undefined) {
|
|
374
|
-
config[
|
|
288
|
+
config['logging'] = device.logging;
|
|
375
289
|
}
|
|
376
290
|
if (Object.entries(config).length !== 0) {
|
|
377
|
-
this.warnLog(
|
|
378
|
-
`Air Purifier: ${this.accessory.displayName} Config: ${JSON.stringify(
|
|
379
|
-
config,
|
|
380
|
-
)}`,
|
|
381
|
-
);
|
|
291
|
+
this.warnLog(`Air Purifier: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
382
292
|
}
|
|
383
293
|
}
|
|
384
294
|
|
|
385
295
|
logs(device: irdevice & irDevicesConfig) {
|
|
386
296
|
if (this.platform.debugMode) {
|
|
387
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
388
|
-
this.debugLog(
|
|
389
|
-
`Air Purifier: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`,
|
|
390
|
-
);
|
|
297
|
+
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
298
|
+
this.debugLog(`Air Purifier: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
391
299
|
} else if (device.logging) {
|
|
392
300
|
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
393
|
-
this.debugLog(
|
|
394
|
-
`Air Purifier: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`,
|
|
395
|
-
);
|
|
301
|
+
this.debugLog(`Air Purifier: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
396
302
|
} else if (this.platform.config.options?.logging) {
|
|
397
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
398
|
-
|
|
399
|
-
this.debugLog(
|
|
400
|
-
`Air Purifier: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`,
|
|
401
|
-
);
|
|
303
|
+
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
304
|
+
this.debugLog(`Air Purifier: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
402
305
|
} else {
|
|
403
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
404
|
-
this.debugLog(
|
|
405
|
-
`Air Purifier: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`,
|
|
406
|
-
);
|
|
306
|
+
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
307
|
+
this.debugLog(`Air Purifier: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
407
308
|
}
|
|
408
309
|
}
|
|
409
310
|
|
|
@@ -430,8 +331,8 @@ export class AirPurifier {
|
|
|
430
331
|
|
|
431
332
|
debugLog(...log: any[]) {
|
|
432
333
|
if (this.enablingDeviceLogging()) {
|
|
433
|
-
if (this.deviceLogging ===
|
|
434
|
-
this.platform.log.info(
|
|
334
|
+
if (this.deviceLogging === 'debug') {
|
|
335
|
+
this.platform.log.info('[DEBUG]', String(...log));
|
|
435
336
|
} else {
|
|
436
337
|
this.platform.log.debug(String(...log));
|
|
437
338
|
}
|
|
@@ -439,6 +340,6 @@ export class AirPurifier {
|
|
|
439
340
|
}
|
|
440
341
|
|
|
441
342
|
enablingDeviceLogging(): boolean {
|
|
442
|
-
return this.deviceLogging
|
|
343
|
+
return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
|
|
443
344
|
}
|
|
444
345
|
}
|