@switchbot/homebridge-switchbot 1.8.2 → 1.8.3-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 +1 -1
- package/.vscode/extensions.json +5 -0
- package/.vscode/settings.json +15 -0
- package/dist/devices/bots.d.ts +34 -35
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +241 -184
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.d.ts +50 -50
- package/dist/devices/colorbulb.d.ts.map +1 -1
- package/dist/devices/colorbulb.js +145 -131
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.d.ts +27 -29
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +138 -115
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +29 -31
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +211 -176
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.d.ts +33 -33
- package/dist/devices/humidifiers.d.ts.map +1 -1
- package/dist/devices/humidifiers.js +214 -189
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/meters.d.ts +30 -31
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +124 -100
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +25 -26
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +120 -102
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.d.ts +23 -23
- package/dist/devices/plugs.d.ts.map +1 -1
- package/dist/devices/plugs.js +81 -63
- 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 +22 -3
- package/dist/index.js.map +1 -1
- package/dist/irdevices/airconditioners.d.ts +6 -6
- package/dist/irdevices/airconditioners.d.ts.map +1 -1
- package/dist/irdevices/airconditioners.js +105 -79
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.d.ts +5 -5
- package/dist/irdevices/airpurifiers.d.ts.map +1 -1
- package/dist/irdevices/airpurifiers.js +56 -42
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.d.ts +5 -5
- package/dist/irdevices/cameras.d.ts.map +1 -1
- package/dist/irdevices/cameras.js +31 -27
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.d.ts +5 -5
- package/dist/irdevices/fans.d.ts.map +1 -1
- package/dist/irdevices/fans.js +45 -38
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.d.ts +5 -5
- package/dist/irdevices/lights.d.ts.map +1 -1
- package/dist/irdevices/lights.js +37 -33
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.d.ts +5 -5
- package/dist/irdevices/others.d.ts.map +1 -1
- package/dist/irdevices/others.js +34 -29
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.d.ts +5 -5
- package/dist/irdevices/tvs.d.ts.map +1 -1
- package/dist/irdevices/tvs.js +91 -76
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts +5 -5
- package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.js +31 -27
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.d.ts +5 -5
- package/dist/irdevices/waterheaters.d.ts.map +1 -1
- package/dist/irdevices/waterheaters.js +31 -27
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/dist/platform.d.ts +12 -12
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +241 -172
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +1 -1
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +4 -4
- package/dist/settings.js.map +1 -1
- package/package.json +72 -71
- package/src/devices/bots.ts +927 -442
- package/src/devices/colorbulb.ts +473 -246
- package/src/devices/contact.ts +381 -208
- package/src/devices/curtains.ts +613 -321
- package/src/devices/humidifiers.ts +594 -323
- package/src/devices/meters.ts +331 -186
- package/src/devices/motion.ts +327 -184
- package/src/devices/plugs.ts +175 -107
- package/src/index.ts +5 -5
- package/src/irdevices/airconditioners.ts +360 -149
- package/src/irdevices/airpurifiers.ts +178 -80
- package/src/irdevices/cameras.ts +109 -51
- package/src/irdevices/fans.ts +174 -77
- package/src/irdevices/lights.ts +110 -57
- package/src/irdevices/others.ts +137 -62
- package/src/irdevices/tvs.ts +249 -124
- package/src/irdevices/vacuumcleaners.ts +112 -52
- package/src/irdevices/waterheaters.ts +115 -53
- package/src/platform.ts +768 -357
- package/src/settings.ts +17 -23
|
@@ -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
|
|
@@ -72,15 +72,19 @@ export class AirConditioner {
|
|
|
72
72
|
// set accessory information
|
|
73
73
|
accessory
|
|
74
74
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
75
|
-
.setCharacteristic(this.platform.Characteristic.Manufacturer,
|
|
75
|
+
.setCharacteristic(this.platform.Characteristic.Manufacturer, "SwitchBot")
|
|
76
76
|
.setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
|
|
77
|
-
.setCharacteristic(
|
|
77
|
+
.setCharacteristic(
|
|
78
|
+
this.platform.Characteristic.SerialNumber,
|
|
79
|
+
device.deviceId!,
|
|
80
|
+
);
|
|
78
81
|
|
|
79
82
|
// get the Television service if it exists, otherwise create a new Television service
|
|
80
83
|
// you can create multiple services for each accessory
|
|
81
84
|
(this.service =
|
|
82
85
|
accessory.getService(this.platform.Service.HeaterCooler) ||
|
|
83
|
-
accessory.addService(this.platform.Service.HeaterCooler)),
|
|
86
|
+
accessory.addService(this.platform.Service.HeaterCooler)),
|
|
87
|
+
`${accessory.displayName} Air Conditioner`;
|
|
84
88
|
|
|
85
89
|
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
86
90
|
// when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
|
|
@@ -88,10 +92,15 @@ export class AirConditioner {
|
|
|
88
92
|
|
|
89
93
|
// set the service name, this is what is displayed as the default name on the Home app
|
|
90
94
|
// in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
|
|
91
|
-
this.service.setCharacteristic(
|
|
95
|
+
this.service.setCharacteristic(
|
|
96
|
+
this.platform.Characteristic.Name,
|
|
97
|
+
accessory.displayName,
|
|
98
|
+
);
|
|
92
99
|
|
|
93
100
|
// handle on / off events using the Active characteristic
|
|
94
|
-
this.service
|
|
101
|
+
this.service
|
|
102
|
+
.getCharacteristic(this.platform.Characteristic.Active)
|
|
103
|
+
.onSet(this.ActiveSet.bind(this));
|
|
95
104
|
|
|
96
105
|
this.service
|
|
97
106
|
.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
|
|
@@ -107,13 +116,21 @@ export class AirConditioner {
|
|
|
107
116
|
if (this.hide_automode) {
|
|
108
117
|
this.TargetHeaterCoolerState = 1 || 2;
|
|
109
118
|
this.ValidValues = [1, 2];
|
|
110
|
-
this.debugLog(
|
|
111
|
-
|
|
119
|
+
this.debugLog(
|
|
120
|
+
`Air Conditioner: ${
|
|
121
|
+
this.accessory.displayName
|
|
122
|
+
} ValidValues: ${JSON.stringify(this.ValidValues)},` +
|
|
123
|
+
` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
|
|
124
|
+
);
|
|
112
125
|
} else {
|
|
113
126
|
this.TargetHeaterCoolerState = 0 || 1 || 2;
|
|
114
127
|
this.ValidValues = [0, 1, 2];
|
|
115
|
-
this.debugLog(
|
|
116
|
-
|
|
128
|
+
this.debugLog(
|
|
129
|
+
`Air Conditioner: ${
|
|
130
|
+
this.accessory.displayName
|
|
131
|
+
} ValidValues: ${JSON.stringify(this.ValidValues)},` +
|
|
132
|
+
` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
|
|
133
|
+
);
|
|
117
134
|
}
|
|
118
135
|
this.service
|
|
119
136
|
.getCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState)
|
|
@@ -125,13 +142,16 @@ export class AirConditioner {
|
|
|
125
142
|
})
|
|
126
143
|
.onSet(this.TargetHeaterCoolerStateSet.bind(this));
|
|
127
144
|
|
|
128
|
-
this.service
|
|
145
|
+
this.service
|
|
146
|
+
.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState)
|
|
129
147
|
.onGet(async () => {
|
|
130
148
|
return this.CurrentHeaterCoolerStateGet();
|
|
131
149
|
});
|
|
132
150
|
|
|
133
151
|
this.service
|
|
134
|
-
.getCharacteristic(
|
|
152
|
+
.getCharacteristic(
|
|
153
|
+
this.platform.Characteristic.HeatingThresholdTemperature,
|
|
154
|
+
)
|
|
135
155
|
.setProps({
|
|
136
156
|
minValue: 16,
|
|
137
157
|
maxValue: 30,
|
|
@@ -143,7 +163,9 @@ export class AirConditioner {
|
|
|
143
163
|
.onSet(this.HeatingThresholdTemperatureSet.bind(this));
|
|
144
164
|
|
|
145
165
|
this.service
|
|
146
|
-
.getCharacteristic(
|
|
166
|
+
.getCharacteristic(
|
|
167
|
+
this.platform.Characteristic.CoolingThresholdTemperature,
|
|
168
|
+
)
|
|
147
169
|
.setProps({
|
|
148
170
|
minValue: 16,
|
|
149
171
|
maxValue: 30,
|
|
@@ -189,9 +211,9 @@ export class AirConditioner {
|
|
|
189
211
|
|
|
190
212
|
async pushAirConditionerOffChanges() {
|
|
191
213
|
const payload = {
|
|
192
|
-
commandType:
|
|
193
|
-
parameter:
|
|
194
|
-
command:
|
|
214
|
+
commandType: "command",
|
|
215
|
+
parameter: "default",
|
|
216
|
+
command: "turnOff",
|
|
195
217
|
} as any;
|
|
196
218
|
await this.pushChanges(payload);
|
|
197
219
|
}
|
|
@@ -199,18 +221,22 @@ export class AirConditioner {
|
|
|
199
221
|
async pushAirConditionerStatusChanges() {
|
|
200
222
|
if (!this.Busy) {
|
|
201
223
|
this.Busy = true;
|
|
202
|
-
this.CurrentHeaterCoolerState =
|
|
224
|
+
this.CurrentHeaterCoolerState =
|
|
225
|
+
this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
|
|
203
226
|
}
|
|
204
227
|
clearTimeout(this.Timeout);
|
|
205
228
|
|
|
206
229
|
// Make a new Timeout set to go off in 1000ms (1 second)
|
|
207
|
-
this.Timeout = setTimeout(
|
|
230
|
+
this.Timeout = setTimeout(
|
|
231
|
+
this.pushAirConditionerDetailsChanges.bind(this),
|
|
232
|
+
1500,
|
|
233
|
+
);
|
|
208
234
|
}
|
|
209
235
|
|
|
210
236
|
async pushAirConditionerDetailsChanges() {
|
|
211
237
|
const payload = {
|
|
212
|
-
commandType:
|
|
213
|
-
command:
|
|
238
|
+
commandType: "command",
|
|
239
|
+
command: "setAll",
|
|
214
240
|
} as any;
|
|
215
241
|
|
|
216
242
|
this.CurrentTemperatureUndefined();
|
|
@@ -221,27 +247,31 @@ export class AirConditioner {
|
|
|
221
247
|
this.CurrentFanSpeed = 1;
|
|
222
248
|
}
|
|
223
249
|
if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
224
|
-
this.state =
|
|
250
|
+
this.state = "on";
|
|
225
251
|
} else {
|
|
226
|
-
this.state =
|
|
252
|
+
this.state = "off";
|
|
227
253
|
}
|
|
228
254
|
if (this.CurrentMode === 1) {
|
|
229
255
|
this.CurrentTemperature = 25;
|
|
230
|
-
this.debugLog(
|
|
231
|
-
|
|
256
|
+
this.debugLog(
|
|
257
|
+
`Air Conditioner: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},` +
|
|
258
|
+
` CurrentTemperature: ${this.CurrentTemperature}`,
|
|
259
|
+
);
|
|
232
260
|
}
|
|
233
261
|
payload.parameter = `${this.CurrentTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
|
|
234
262
|
|
|
235
|
-
|
|
236
263
|
if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
237
264
|
this.CurrentTemperatureUndefined();
|
|
238
265
|
if (this.CurrentTemperature < this.CurrentTemperatureCached) {
|
|
239
|
-
this.CurrentHeaterCoolerState =
|
|
266
|
+
this.CurrentHeaterCoolerState =
|
|
267
|
+
this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
240
268
|
} else if (this.CurrentTemperature > this.CurrentTemperatureCached) {
|
|
241
|
-
this.CurrentHeaterCoolerState =
|
|
269
|
+
this.CurrentHeaterCoolerState =
|
|
270
|
+
this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
242
271
|
}
|
|
243
272
|
} else {
|
|
244
|
-
this.CurrentHeaterCoolerState =
|
|
273
|
+
this.CurrentHeaterCoolerState =
|
|
274
|
+
this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
245
275
|
}
|
|
246
276
|
|
|
247
277
|
await this.pushChanges(payload);
|
|
@@ -249,122 +279,224 @@ export class AirConditioner {
|
|
|
249
279
|
|
|
250
280
|
public async pushChanges(payload: payload) {
|
|
251
281
|
try {
|
|
252
|
-
this.infoLog(
|
|
253
|
-
|
|
282
|
+
this.infoLog(
|
|
283
|
+
`Air Conditioner: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
|
|
284
|
+
` parameter: [${payload.parameter}], commandType: ${payload.commandType}`,
|
|
285
|
+
);
|
|
254
286
|
|
|
255
287
|
// Make the API request
|
|
256
|
-
const push: any = await this.platform.axios.post(
|
|
257
|
-
|
|
288
|
+
const push: any = await this.platform.axios.post(
|
|
289
|
+
`${DeviceURL}/${this.device.deviceId}/commands`,
|
|
290
|
+
payload,
|
|
291
|
+
);
|
|
292
|
+
this.debugLog(
|
|
293
|
+
`Air Conditioner: ${
|
|
294
|
+
this.accessory.displayName
|
|
295
|
+
} pushChanges: ${JSON.stringify(push.data)}`,
|
|
296
|
+
);
|
|
258
297
|
this.statusCode(push);
|
|
259
298
|
this.CurrentTemperatureCached = this.CurrentTemperature;
|
|
260
299
|
this.accessory.context.CurrentTemperature = this.CurrentTemperatureCached;
|
|
261
300
|
this.HeatingThresholdTemperature = this.CurrentTemperatureCached;
|
|
262
301
|
this.HeatingThresholdTemperatureCached = this.CurrentTemperatureCached;
|
|
263
|
-
this.accessory.context.HeatingThresholdTemperature =
|
|
302
|
+
this.accessory.context.HeatingThresholdTemperature =
|
|
303
|
+
this.HeatingThresholdTemperatureCached;
|
|
264
304
|
this.CoolingThresholdTemperature = this.CurrentTemperatureCached;
|
|
265
305
|
this.CoolingThresholdTemperatureCached = this.CurrentTemperatureCached;
|
|
266
|
-
this.accessory.context.CoolingThresholdTemperature =
|
|
306
|
+
this.accessory.context.CoolingThresholdTemperature =
|
|
307
|
+
this.CoolingThresholdTemperatureCached;
|
|
267
308
|
this.updateHomeKitCharacteristics();
|
|
268
309
|
} catch (e: any) {
|
|
269
|
-
this.errorLog(
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
310
|
+
this.errorLog(
|
|
311
|
+
`Air Conditioner: ${this.accessory.displayName} failed pushChanges`,
|
|
312
|
+
);
|
|
313
|
+
if (this.deviceLogging === "debug") {
|
|
314
|
+
this.errorLog(
|
|
315
|
+
`Air Conditioner: ${this.accessory.displayName} failed pushChanges,` +
|
|
316
|
+
` Error Message: ${JSON.stringify(e.message)}`,
|
|
317
|
+
);
|
|
273
318
|
}
|
|
274
319
|
if (this.platform.debugMode) {
|
|
275
|
-
this.errorLog(
|
|
276
|
-
|
|
320
|
+
this.errorLog(
|
|
321
|
+
`Air Conditioner: ${this.accessory.displayName} failed pushChanges,` +
|
|
322
|
+
` Error: ${JSON.stringify(e)}`,
|
|
323
|
+
);
|
|
277
324
|
}
|
|
278
325
|
this.apiError(e);
|
|
279
326
|
}
|
|
280
327
|
}
|
|
281
328
|
|
|
282
|
-
statusCode(push: AxiosResponse<{ statusCode: number
|
|
329
|
+
statusCode(push: AxiosResponse<{ statusCode: number }>) {
|
|
283
330
|
switch (push.data.statusCode) {
|
|
284
331
|
case 151:
|
|
285
|
-
this.errorLog(
|
|
332
|
+
this.errorLog(
|
|
333
|
+
`Air Conditioner: ${this.accessory.displayName} Command not supported by this device type.`,
|
|
334
|
+
);
|
|
286
335
|
break;
|
|
287
336
|
case 152:
|
|
288
|
-
this.errorLog(
|
|
337
|
+
this.errorLog(
|
|
338
|
+
`Air Conditioner: ${this.accessory.displayName} Device not found.`,
|
|
339
|
+
);
|
|
289
340
|
break;
|
|
290
341
|
case 160:
|
|
291
|
-
this.errorLog(
|
|
342
|
+
this.errorLog(
|
|
343
|
+
`Air Conditioner: ${this.accessory.displayName} Command is not supported.`,
|
|
344
|
+
);
|
|
292
345
|
break;
|
|
293
346
|
case 161:
|
|
294
|
-
this.errorLog(
|
|
347
|
+
this.errorLog(
|
|
348
|
+
`Air Conditioner: ${this.accessory.displayName} Device is offline.`,
|
|
349
|
+
);
|
|
295
350
|
break;
|
|
296
351
|
case 171:
|
|
297
|
-
this.errorLog(
|
|
352
|
+
this.errorLog(
|
|
353
|
+
`Air Conditioner: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`,
|
|
354
|
+
);
|
|
298
355
|
break;
|
|
299
356
|
case 190:
|
|
300
|
-
this.errorLog(
|
|
301
|
-
|
|
357
|
+
this.errorLog(
|
|
358
|
+
`Air Conditioner: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
|
|
359
|
+
` with server, Or command: ${JSON.stringify(
|
|
360
|
+
push.data,
|
|
361
|
+
)} format is invalid`,
|
|
362
|
+
);
|
|
302
363
|
break;
|
|
303
364
|
case 100:
|
|
304
|
-
this.debugLog(
|
|
365
|
+
this.debugLog(
|
|
366
|
+
`Air Conditioner: ${this.accessory.displayName} Command successfully sent.`,
|
|
367
|
+
);
|
|
305
368
|
break;
|
|
306
369
|
default:
|
|
307
|
-
this.debugLog(
|
|
370
|
+
this.debugLog(
|
|
371
|
+
`Air Conditioner: ${this.accessory.displayName} Unknown statusCode.`,
|
|
372
|
+
);
|
|
308
373
|
}
|
|
309
374
|
}
|
|
310
375
|
|
|
311
376
|
updateHomeKitCharacteristics() {
|
|
312
377
|
if (this.Active === undefined) {
|
|
313
|
-
this.debugLog(
|
|
378
|
+
this.debugLog(
|
|
379
|
+
`Air Conditioner: ${this.accessory.displayName} Active: ${this.Active}`,
|
|
380
|
+
);
|
|
314
381
|
} else {
|
|
315
|
-
this.service?.updateCharacteristic(
|
|
316
|
-
|
|
382
|
+
this.service?.updateCharacteristic(
|
|
383
|
+
this.platform.Characteristic.Active,
|
|
384
|
+
this.Active,
|
|
385
|
+
);
|
|
386
|
+
this.debugLog(
|
|
387
|
+
`Air Conditioner: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`,
|
|
388
|
+
);
|
|
317
389
|
}
|
|
318
390
|
if (this.RotationSpeed === undefined) {
|
|
319
|
-
this.debugLog(
|
|
391
|
+
this.debugLog(
|
|
392
|
+
`Air Conditioner: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`,
|
|
393
|
+
);
|
|
320
394
|
} else {
|
|
321
|
-
this.service?.updateCharacteristic(
|
|
322
|
-
|
|
395
|
+
this.service?.updateCharacteristic(
|
|
396
|
+
this.platform.Characteristic.RotationSpeed,
|
|
397
|
+
this.RotationSpeed,
|
|
398
|
+
);
|
|
399
|
+
this.debugLog(
|
|
400
|
+
`Air Conditioner: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`,
|
|
401
|
+
);
|
|
323
402
|
}
|
|
324
403
|
if (this.CurrentTemperature === undefined) {
|
|
325
|
-
this.debugLog(
|
|
404
|
+
this.debugLog(
|
|
405
|
+
`Air Conditioner: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`,
|
|
406
|
+
);
|
|
326
407
|
} else {
|
|
327
|
-
this.service?.updateCharacteristic(
|
|
328
|
-
|
|
408
|
+
this.service?.updateCharacteristic(
|
|
409
|
+
this.platform.Characteristic.CurrentTemperature,
|
|
410
|
+
this.CurrentTemperature,
|
|
411
|
+
);
|
|
412
|
+
this.debugLog(
|
|
413
|
+
`Air Conditioner: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`,
|
|
414
|
+
);
|
|
329
415
|
}
|
|
330
416
|
if (this.TargetHeaterCoolerState === undefined) {
|
|
331
|
-
this.debugLog(
|
|
417
|
+
this.debugLog(
|
|
418
|
+
`Air Conditioner: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
|
|
419
|
+
);
|
|
332
420
|
} else {
|
|
333
|
-
this.service?.updateCharacteristic(
|
|
334
|
-
|
|
335
|
-
|
|
421
|
+
this.service?.updateCharacteristic(
|
|
422
|
+
this.platform.Characteristic.TargetHeaterCoolerState,
|
|
423
|
+
this.TargetHeaterCoolerState,
|
|
424
|
+
);
|
|
425
|
+
this.debugLog(
|
|
426
|
+
`Air Conditioner: ${this.accessory.displayName}` +
|
|
427
|
+
` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
|
|
428
|
+
);
|
|
336
429
|
}
|
|
337
430
|
if (this.CurrentHeaterCoolerState === undefined) {
|
|
338
|
-
this.debugLog(
|
|
431
|
+
this.debugLog(
|
|
432
|
+
`Air Conditioner: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
433
|
+
);
|
|
339
434
|
} else {
|
|
340
|
-
this.service?.updateCharacteristic(
|
|
341
|
-
|
|
342
|
-
|
|
435
|
+
this.service?.updateCharacteristic(
|
|
436
|
+
this.platform.Characteristic.CurrentHeaterCoolerState,
|
|
437
|
+
this.CurrentHeaterCoolerState,
|
|
438
|
+
);
|
|
439
|
+
this.debugLog(
|
|
440
|
+
`Air Conditioner: ${this.accessory.displayName}` +
|
|
441
|
+
` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
442
|
+
);
|
|
343
443
|
}
|
|
344
444
|
if (this.HeatingThresholdTemperature === undefined) {
|
|
345
|
-
this.debugLog(
|
|
445
|
+
this.debugLog(
|
|
446
|
+
`Air Conditioner: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`,
|
|
447
|
+
);
|
|
346
448
|
} else {
|
|
347
|
-
this.service?.updateCharacteristic(
|
|
348
|
-
|
|
349
|
-
|
|
449
|
+
this.service?.updateCharacteristic(
|
|
450
|
+
this.platform.Characteristic.HeatingThresholdTemperature,
|
|
451
|
+
this.HeatingThresholdTemperature,
|
|
452
|
+
);
|
|
453
|
+
this.debugLog(
|
|
454
|
+
`Air Conditioner: ${this.accessory.displayName}` +
|
|
455
|
+
` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`,
|
|
456
|
+
);
|
|
350
457
|
}
|
|
351
458
|
if (this.CoolingThresholdTemperature === undefined) {
|
|
352
|
-
this.debugLog(
|
|
459
|
+
this.debugLog(
|
|
460
|
+
`Air Conditioner: ${this.accessory.displayName} CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`,
|
|
461
|
+
);
|
|
353
462
|
} else {
|
|
354
|
-
this.service?.updateCharacteristic(
|
|
355
|
-
|
|
356
|
-
|
|
463
|
+
this.service?.updateCharacteristic(
|
|
464
|
+
this.platform.Characteristic.CoolingThresholdTemperature,
|
|
465
|
+
this.CoolingThresholdTemperature,
|
|
466
|
+
);
|
|
467
|
+
this.debugLog(
|
|
468
|
+
`Air Conditioner: ${this.accessory.displayName}` +
|
|
469
|
+
` updateCharacteristic CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`,
|
|
470
|
+
);
|
|
357
471
|
}
|
|
358
472
|
}
|
|
359
473
|
|
|
360
474
|
public apiError(e: any) {
|
|
361
475
|
this.service.updateCharacteristic(this.platform.Characteristic.Active, e);
|
|
362
|
-
this.service.updateCharacteristic(
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
this.service.updateCharacteristic(
|
|
367
|
-
|
|
476
|
+
this.service.updateCharacteristic(
|
|
477
|
+
this.platform.Characteristic.RotationSpeed,
|
|
478
|
+
e,
|
|
479
|
+
);
|
|
480
|
+
this.service.updateCharacteristic(
|
|
481
|
+
this.platform.Characteristic.CurrentTemperature,
|
|
482
|
+
e,
|
|
483
|
+
);
|
|
484
|
+
this.service.updateCharacteristic(
|
|
485
|
+
this.platform.Characteristic.TargetHeaterCoolerState,
|
|
486
|
+
e,
|
|
487
|
+
);
|
|
488
|
+
this.service.updateCharacteristic(
|
|
489
|
+
this.platform.Characteristic.CurrentHeaterCoolerState,
|
|
490
|
+
e,
|
|
491
|
+
);
|
|
492
|
+
this.service.updateCharacteristic(
|
|
493
|
+
this.platform.Characteristic.HeatingThresholdTemperature,
|
|
494
|
+
e,
|
|
495
|
+
);
|
|
496
|
+
this.service.updateCharacteristic(
|
|
497
|
+
this.platform.Characteristic.CoolingThresholdTemperature,
|
|
498
|
+
e,
|
|
499
|
+
);
|
|
368
500
|
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
369
501
|
}
|
|
370
502
|
|
|
@@ -375,7 +507,9 @@ export class AirConditioner {
|
|
|
375
507
|
} else {
|
|
376
508
|
this.CurrentTemperatureCached = this.CurrentTemperature;
|
|
377
509
|
}
|
|
378
|
-
this.debugLog(
|
|
510
|
+
this.debugLog(
|
|
511
|
+
`Air Conditioner: ${this.accessory.displayName} Get CurrentTemperature: ${this.CurrentTemperature}`,
|
|
512
|
+
);
|
|
379
513
|
this.accessory.context.CurrentTemperature = this.CurrentTemperatureCached;
|
|
380
514
|
return this.CurrentTemperature;
|
|
381
515
|
}
|
|
@@ -388,7 +522,9 @@ export class AirConditioner {
|
|
|
388
522
|
} else {
|
|
389
523
|
this.RotationSpeed = this.CurrentFanSpeed - 1;
|
|
390
524
|
}
|
|
391
|
-
this.debugLog(
|
|
525
|
+
this.debugLog(
|
|
526
|
+
`Air Conditioner: ${this.accessory.displayName} Get RotationSpeed: ${this.RotationSpeed}`,
|
|
527
|
+
);
|
|
392
528
|
this.RotationSpeedCached = this.RotationSpeed;
|
|
393
529
|
this.accessory.context.RotationSpeed = this.RotationSpeedCached;
|
|
394
530
|
return this.RotationSpeed;
|
|
@@ -406,38 +542,53 @@ export class AirConditioner {
|
|
|
406
542
|
this.pushAirConditionerStatusChanges();
|
|
407
543
|
}
|
|
408
544
|
|
|
409
|
-
ActiveSet(value: CharacteristicValue) {
|
|
410
|
-
this.debugLog(
|
|
545
|
+
ActiveSet(value: CharacteristicValue): void {
|
|
546
|
+
this.debugLog(
|
|
547
|
+
`Air Conditioner: ${this.accessory.displayName} Set Active: ${value}`,
|
|
548
|
+
);
|
|
411
549
|
|
|
412
550
|
this.Active = value;
|
|
413
551
|
this.ActiveCached = this.Active;
|
|
414
552
|
this.accessory.context.Active = this.ActiveCached;
|
|
415
553
|
|
|
416
554
|
if (value === this.platform.Characteristic.Active.INACTIVE) {
|
|
417
|
-
this.debugLog(
|
|
555
|
+
this.debugLog(
|
|
556
|
+
`Air Conditioner: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`,
|
|
557
|
+
);
|
|
418
558
|
this.pushAirConditionerOffChanges();
|
|
419
559
|
} else {
|
|
420
|
-
this.debugLog(
|
|
560
|
+
this.debugLog(
|
|
561
|
+
`Air Conditioner: ${this.accessory.displayName} pushAirConditionerOnChanges, Active: ${this.Active}`,
|
|
562
|
+
);
|
|
421
563
|
this.pushAirConditionerStatusChanges();
|
|
422
564
|
}
|
|
423
565
|
}
|
|
424
566
|
|
|
425
567
|
TargetHeaterCoolerStateGet() {
|
|
426
568
|
if (this.ValidValues === [0, 1, 2]) {
|
|
427
|
-
this.TargetHeaterCoolerState =
|
|
428
|
-
|
|
429
|
-
|
|
569
|
+
this.TargetHeaterCoolerState =
|
|
570
|
+
this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
571
|
+
this.debugLog(
|
|
572
|
+
`Air Conditioner: ${this.accessory.displayName} Get (AUTO) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
|
|
573
|
+
` ValidValues: ${this.ValidValues}`,
|
|
574
|
+
);
|
|
430
575
|
} else if (this.ValidValues === [1, 2]) {
|
|
431
|
-
this.TargetHeaterCoolerState =
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
576
|
+
this.TargetHeaterCoolerState =
|
|
577
|
+
this.platform.Characteristic.TargetHeaterCoolerState.COOL ||
|
|
578
|
+
this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
579
|
+
this.debugLog(
|
|
580
|
+
`Air Conditioner: ${this.accessory.displayName} Get (COOL/HEAT) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
|
|
581
|
+
` ValidValues: ${this.ValidValues}`,
|
|
582
|
+
);
|
|
435
583
|
} else {
|
|
436
|
-
this.debugLog(
|
|
437
|
-
|
|
584
|
+
this.debugLog(
|
|
585
|
+
`Air Conditioner: ${this.accessory.displayName} Get TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
|
|
586
|
+
` ValidValues: ${this.ValidValues}`,
|
|
587
|
+
);
|
|
438
588
|
}
|
|
439
589
|
this.TargetHeaterCoolerStateCached = this.TargetHeaterCoolerState;
|
|
440
|
-
this.accessory.context.TargetHeaterCoolerState =
|
|
590
|
+
this.accessory.context.TargetHeaterCoolerState =
|
|
591
|
+
this.TargetHeaterCoolerStateCached;
|
|
441
592
|
return this.TargetHeaterCoolerState;
|
|
442
593
|
}
|
|
443
594
|
|
|
@@ -445,66 +596,102 @@ export class AirConditioner {
|
|
|
445
596
|
if (this.hide_automode) {
|
|
446
597
|
if (value === this.platform.Characteristic.TargetHeaterCoolerState.HEAT) {
|
|
447
598
|
this.TargetHeaterCoolerStateHEAT();
|
|
448
|
-
} else if (
|
|
599
|
+
} else if (
|
|
600
|
+
value === this.platform.Characteristic.TargetHeaterCoolerState.COOL
|
|
601
|
+
) {
|
|
449
602
|
this.TargetHeaterCoolerStateCOOL();
|
|
450
603
|
} else {
|
|
451
|
-
this.errorLog(
|
|
452
|
-
|
|
604
|
+
this.errorLog(
|
|
605
|
+
`Air Conditioner: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
|
|
606
|
+
` hide_automode: ${this.hide_automode} `,
|
|
607
|
+
);
|
|
453
608
|
}
|
|
454
609
|
} else {
|
|
455
610
|
if (value === this.platform.Characteristic.TargetHeaterCoolerState.AUTO) {
|
|
456
611
|
this.TargetHeaterCoolerStateAUTO();
|
|
457
|
-
} else if (
|
|
612
|
+
} else if (
|
|
613
|
+
value === this.platform.Characteristic.TargetHeaterCoolerState.HEAT
|
|
614
|
+
) {
|
|
458
615
|
this.TargetHeaterCoolerStateHEAT();
|
|
459
|
-
} else if (
|
|
616
|
+
} else if (
|
|
617
|
+
value === this.platform.Characteristic.TargetHeaterCoolerState.COOL
|
|
618
|
+
) {
|
|
460
619
|
this.TargetHeaterCoolerStateCOOL();
|
|
461
620
|
} else {
|
|
462
|
-
this.errorLog(
|
|
463
|
-
|
|
621
|
+
this.errorLog(
|
|
622
|
+
`Air Conditioner: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
|
|
623
|
+
` hide_automode: ${this.hide_automode} `,
|
|
624
|
+
);
|
|
464
625
|
}
|
|
465
626
|
}
|
|
466
627
|
this.TargetHeaterCoolerStateCached = this.TargetHeaterCoolerState;
|
|
467
|
-
this.accessory.context.TargetHeaterCoolerState =
|
|
628
|
+
this.accessory.context.TargetHeaterCoolerState =
|
|
629
|
+
this.TargetHeaterCoolerStateCached;
|
|
468
630
|
this.pushAirConditionerStatusChanges();
|
|
469
631
|
}
|
|
470
632
|
|
|
471
633
|
private TargetHeaterCoolerStateAUTO() {
|
|
472
|
-
this.TargetHeaterCoolerState =
|
|
634
|
+
this.TargetHeaterCoolerState =
|
|
635
|
+
this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
473
636
|
this.CurrentMode = 1;
|
|
474
|
-
this.debugLog(
|
|
475
|
-
|
|
637
|
+
this.debugLog(
|
|
638
|
+
`Air Conditioner: ${this.accessory.displayName} Set (AUTO) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
|
|
639
|
+
);
|
|
640
|
+
this.debugLog(
|
|
641
|
+
`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`,
|
|
642
|
+
);
|
|
476
643
|
}
|
|
477
644
|
|
|
478
645
|
private TargetHeaterCoolerStateCOOL() {
|
|
479
|
-
this.TargetHeaterCoolerState =
|
|
646
|
+
this.TargetHeaterCoolerState =
|
|
647
|
+
this.platform.Characteristic.TargetHeaterCoolerState.COOL;
|
|
480
648
|
this.CurrentMode = 2;
|
|
481
|
-
this.debugLog(
|
|
482
|
-
|
|
649
|
+
this.debugLog(
|
|
650
|
+
`Air Conditioner: ${this.accessory.displayName} Set (COOL) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
|
|
651
|
+
);
|
|
652
|
+
this.debugLog(
|
|
653
|
+
`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`,
|
|
654
|
+
);
|
|
483
655
|
}
|
|
484
656
|
|
|
485
657
|
private TargetHeaterCoolerStateHEAT() {
|
|
486
|
-
this.TargetHeaterCoolerState =
|
|
658
|
+
this.TargetHeaterCoolerState =
|
|
659
|
+
this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
487
660
|
this.CurrentMode = 5;
|
|
488
|
-
this.debugLog(
|
|
489
|
-
|
|
661
|
+
this.debugLog(
|
|
662
|
+
`Air Conditioner: ${this.accessory.displayName} Set (HEAT) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
|
|
663
|
+
);
|
|
664
|
+
this.debugLog(
|
|
665
|
+
`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`,
|
|
666
|
+
);
|
|
490
667
|
}
|
|
491
668
|
|
|
492
669
|
CurrentHeaterCoolerStateGet() {
|
|
493
670
|
if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
494
671
|
this.CurrentTemperatureUndefined();
|
|
495
672
|
if (this.CurrentTemperature < this.CurrentTemperatureCached) {
|
|
496
|
-
this.CurrentHeaterCoolerState =
|
|
497
|
-
|
|
673
|
+
this.CurrentHeaterCoolerState =
|
|
674
|
+
this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
675
|
+
this.debugLog(
|
|
676
|
+
`Air Conditioner: ${this.accessory.displayName} Get (COOLLING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
677
|
+
);
|
|
498
678
|
} else if (this.CurrentTemperature > this.CurrentTemperatureCached) {
|
|
499
|
-
this.CurrentHeaterCoolerState =
|
|
500
|
-
|
|
679
|
+
this.CurrentHeaterCoolerState =
|
|
680
|
+
this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
681
|
+
this.debugLog(
|
|
682
|
+
`Air Conditioner: ${this.accessory.displayName} Get (HEATING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
683
|
+
);
|
|
501
684
|
}
|
|
502
685
|
} else {
|
|
503
|
-
this.CurrentHeaterCoolerState =
|
|
504
|
-
|
|
686
|
+
this.CurrentHeaterCoolerState =
|
|
687
|
+
this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
688
|
+
this.debugLog(
|
|
689
|
+
`Air Conditioner: ${this.accessory.displayName} Get (INACTIVE) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
690
|
+
);
|
|
505
691
|
}
|
|
506
692
|
this.CurrentHeaterCoolerStateCached = this.CurrentHeaterCoolerState;
|
|
507
|
-
this.accessory.context.CurrentHeaterCoolerState =
|
|
693
|
+
this.accessory.context.CurrentHeaterCoolerState =
|
|
694
|
+
this.CurrentHeaterCoolerStateCached;
|
|
508
695
|
return this.CurrentHeaterCoolerState;
|
|
509
696
|
}
|
|
510
697
|
|
|
@@ -513,8 +700,11 @@ export class AirConditioner {
|
|
|
513
700
|
this.CurrentTemperature = this.CurrentTemperatureCached;
|
|
514
701
|
this.HeatingThresholdTemperature = this.CurrentTemperatureCached;
|
|
515
702
|
this.HeatingThresholdTemperatureCached = this.HeatingThresholdTemperature;
|
|
516
|
-
this.accessory.context.HeatingThresholdTemperature =
|
|
517
|
-
|
|
703
|
+
this.accessory.context.HeatingThresholdTemperature =
|
|
704
|
+
this.HeatingThresholdTemperatureCached;
|
|
705
|
+
this.debugLog(
|
|
706
|
+
`Air Conditioner: ${this.accessory.displayName} Get HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`,
|
|
707
|
+
);
|
|
518
708
|
return this.HeatingThresholdTemperature;
|
|
519
709
|
}
|
|
520
710
|
|
|
@@ -522,20 +712,25 @@ export class AirConditioner {
|
|
|
522
712
|
this.CurrentTemperatureCached = this.CurrentTemperature;
|
|
523
713
|
this.CurrentTemperature = value;
|
|
524
714
|
this.HeatingThresholdTemperatureCached = this.HeatingThresholdTemperature;
|
|
525
|
-
this.accessory.context.HeatingThresholdTemperature =
|
|
526
|
-
|
|
527
|
-
|
|
715
|
+
this.accessory.context.HeatingThresholdTemperature =
|
|
716
|
+
this.HeatingThresholdTemperatureCached;
|
|
717
|
+
this.debugLog(
|
|
718
|
+
`Air Conditioner: ${this.accessory.displayName} Set HeatingThresholdTemperature: ${this.HeatingThresholdTemperature},` +
|
|
719
|
+
` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`,
|
|
720
|
+
);
|
|
528
721
|
this.pushAirConditionerStatusChanges();
|
|
529
722
|
}
|
|
530
723
|
|
|
531
|
-
|
|
532
724
|
private CoolingThresholdTemperatureGet() {
|
|
533
725
|
this.CurrentTemperatureUndefined;
|
|
534
726
|
this.CurrentTemperature = this.CurrentTemperatureCached;
|
|
535
727
|
this.CoolingThresholdTemperature = this.CurrentTemperatureCached;
|
|
536
728
|
this.CoolingThresholdTemperatureCached = this.CoolingThresholdTemperature;
|
|
537
|
-
this.accessory.context.CoolingThresholdTemperature =
|
|
538
|
-
|
|
729
|
+
this.accessory.context.CoolingThresholdTemperature =
|
|
730
|
+
this.CoolingThresholdTemperatureCached;
|
|
731
|
+
this.debugLog(
|
|
732
|
+
`Air Conditioner: ${this.accessory.displayName} Get CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`,
|
|
733
|
+
);
|
|
539
734
|
return this.CoolingThresholdTemperature;
|
|
540
735
|
}
|
|
541
736
|
|
|
@@ -543,9 +738,12 @@ export class AirConditioner {
|
|
|
543
738
|
this.CurrentTemperatureCached = this.CurrentTemperature;
|
|
544
739
|
this.CurrentTemperature = value;
|
|
545
740
|
this.CoolingThresholdTemperatureCached = this.CoolingThresholdTemperature;
|
|
546
|
-
this.accessory.context.CoolingThresholdTemperature =
|
|
547
|
-
|
|
548
|
-
|
|
741
|
+
this.accessory.context.CoolingThresholdTemperature =
|
|
742
|
+
this.CoolingThresholdTemperatureCached;
|
|
743
|
+
this.debugLog(
|
|
744
|
+
`Air Conditioner: ${this.accessory.displayName} Set CoolingThresholdTemperature: ${this.CoolingThresholdTemperature},` +
|
|
745
|
+
` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`,
|
|
746
|
+
);
|
|
549
747
|
this.pushAirConditionerStatusChanges();
|
|
550
748
|
}
|
|
551
749
|
|
|
@@ -564,32 +762,45 @@ export class AirConditioner {
|
|
|
564
762
|
config = device.irair;
|
|
565
763
|
}
|
|
566
764
|
if (device.logging !== undefined) {
|
|
567
|
-
config[
|
|
765
|
+
config["logging"] = device.logging;
|
|
568
766
|
}
|
|
569
767
|
if (Object.entries(config).length !== 0) {
|
|
570
|
-
this.warnLog(
|
|
768
|
+
this.warnLog(
|
|
769
|
+
`Air Conditioner: ${
|
|
770
|
+
this.accessory.displayName
|
|
771
|
+
} Config: ${JSON.stringify(config)}`,
|
|
772
|
+
);
|
|
571
773
|
}
|
|
572
774
|
}
|
|
573
775
|
|
|
574
776
|
logs(device: irdevice & irDevicesConfig) {
|
|
575
777
|
if (this.platform.debugMode) {
|
|
576
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
577
|
-
this.debugLog(
|
|
778
|
+
this.deviceLogging = this.accessory.context.logging = "debugMode";
|
|
779
|
+
this.debugLog(
|
|
780
|
+
`Air Conditioner: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`,
|
|
781
|
+
);
|
|
578
782
|
} else if (device.logging) {
|
|
579
783
|
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
580
|
-
this.debugLog(
|
|
784
|
+
this.debugLog(
|
|
785
|
+
`Air Conditioner: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`,
|
|
786
|
+
);
|
|
581
787
|
} else if (this.platform.config.options?.logging) {
|
|
582
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
583
|
-
|
|
788
|
+
this.deviceLogging = this.accessory.context.logging =
|
|
789
|
+
this.platform.config.options?.logging;
|
|
790
|
+
this.debugLog(
|
|
791
|
+
`Air Conditioner: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`,
|
|
792
|
+
);
|
|
584
793
|
} else {
|
|
585
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
586
|
-
this.debugLog(
|
|
794
|
+
this.deviceLogging = this.accessory.context.logging = "standard";
|
|
795
|
+
this.debugLog(
|
|
796
|
+
`Air Conditioner: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`,
|
|
797
|
+
);
|
|
587
798
|
}
|
|
588
799
|
}
|
|
589
800
|
|
|
590
801
|
/**
|
|
591
|
-
|
|
592
|
-
|
|
802
|
+
* Logging for Device
|
|
803
|
+
*/
|
|
593
804
|
infoLog(...log: any[]) {
|
|
594
805
|
if (this.enablingDeviceLogging()) {
|
|
595
806
|
this.platform.log.info(String(...log));
|
|
@@ -610,8 +821,8 @@ export class AirConditioner {
|
|
|
610
821
|
|
|
611
822
|
debugLog(...log: any[]) {
|
|
612
823
|
if (this.enablingDeviceLogging()) {
|
|
613
|
-
if (this.deviceLogging ===
|
|
614
|
-
this.platform.log.info(
|
|
824
|
+
if (this.deviceLogging === "debug") {
|
|
825
|
+
this.platform.log.info("[DEBUG]", String(...log));
|
|
615
826
|
} else {
|
|
616
827
|
this.platform.log.debug(String(...log));
|
|
617
828
|
}
|
|
@@ -619,6 +830,6 @@ export class AirConditioner {
|
|
|
619
830
|
}
|
|
620
831
|
|
|
621
832
|
enablingDeviceLogging(): boolean {
|
|
622
|
-
return this.deviceLogging
|
|
833
|
+
return this.deviceLogging.includes("debug") || this.deviceLogging === "standard";
|
|
623
834
|
}
|
|
624
835
|
}
|