@switchbot/homebridge-switchbot 2.0.0-beta.8 → 2.0.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/CHANGELOG.md +10 -1
- package/README.md +3 -2
- package/config.schema.json +91 -19
- package/dist/device/bot.d.ts +34 -28
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +657 -648
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +137 -0
- package/dist/device/ceilinglight.d.ts.map +1 -0
- package/dist/device/ceilinglight.js +1127 -0
- package/dist/device/ceilinglight.js.map +1 -0
- package/dist/device/colorbulb.d.ts +36 -19
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +486 -309
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +18 -8
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +306 -237
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +23 -16
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +566 -502
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/humidifier.d.ts +24 -18
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +453 -369
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/lock.d.ts +27 -8
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +305 -148
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +22 -16
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +367 -267
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +24 -12
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +381 -213
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +18 -8
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +279 -216
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +27 -17
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +295 -251
- package/dist/device/plug.js.map +1 -1
- package/dist/device/striplight.d.ts +43 -19
- package/dist/device/striplight.d.ts.map +1 -1
- package/dist/device/striplight.js +506 -262
- package/dist/device/striplight.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +9 -12
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +278 -230
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +5 -3
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +154 -104
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +11 -8
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +133 -86
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +10 -7
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +160 -109
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +11 -8
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +137 -103
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +11 -8
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +145 -98
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +12 -9
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +143 -93
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +9 -10
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +132 -89
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +8 -9
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +132 -89
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +13 -12
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +524 -418
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +19 -11
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/homebridge-ui/public/index.html +1 -0
- package/package.json +11 -9
- package/src/device/bot.ts +656 -659
- package/src/device/ceilinglight.ts +1208 -0
- package/src/device/colorbulb.ts +490 -344
- package/src/device/contact.ts +309 -241
- package/src/device/curtain.ts +571 -516
- package/src/device/humidifier.ts +456 -403
- package/src/device/lock.ts +314 -149
- package/src/device/meter.ts +378 -280
- package/src/device/meterplus.ts +391 -219
- package/src/device/motion.ts +285 -222
- package/src/device/plug.ts +299 -260
- package/src/device/striplight.ts +522 -289
- package/src/irdevice/airconditioner.ts +282 -241
- package/src/irdevice/airpurifier.ts +151 -103
- package/src/irdevice/camera.ts +131 -85
- package/src/irdevice/fan.ts +157 -106
- package/src/irdevice/light.ts +135 -103
- package/src/irdevice/other.ts +143 -97
- package/src/irdevice/tv.ts +142 -93
- package/src/irdevice/vacuumcleaner.ts +131 -89
- package/src/irdevice/waterheater.ts +130 -89
- package/src/platform.ts +522 -446
- package/src/settings.ts +20 -11
- package/.github/npm-version-script.js +0 -81
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.AirConditioner = void 0;
|
|
7
7
|
const https_1 = __importDefault(require("https"));
|
|
8
8
|
const crypto_1 = __importDefault(require("crypto"));
|
|
9
|
+
const super_stringify_1 = __importDefault(require("super-stringify"));
|
|
9
10
|
const settings_1 = require("../settings");
|
|
10
11
|
/**
|
|
11
12
|
* Platform Accessory
|
|
@@ -24,32 +25,16 @@ class AirConditioner {
|
|
|
24
25
|
this.logs(device);
|
|
25
26
|
this.config(device);
|
|
26
27
|
this.pushOnChanges(device);
|
|
27
|
-
|
|
28
|
-
this.Active = this.platform.Characteristic.Active.INACTIVE;
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
this.Active = this.accessory.context.Active;
|
|
32
|
-
}
|
|
33
|
-
if (this.CurrentTemperature === undefined) {
|
|
34
|
-
this.CurrentTemperature = 24;
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
this.CurrentTemperature = this.accessory.context.CurrentTemperature;
|
|
38
|
-
}
|
|
39
|
-
if (device.irair?.hide_automode) {
|
|
40
|
-
this.hide_automode = device.irair?.hide_automode;
|
|
41
|
-
this.accessory.context.hide_automode = this.hide_automode;
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
this.hide_automode = device.irair?.hide_automode;
|
|
45
|
-
this.accessory.context.hide_automode = this.hide_automode;
|
|
46
|
-
}
|
|
28
|
+
this.context(device);
|
|
47
29
|
// set accessory information
|
|
48
30
|
accessory
|
|
49
31
|
.getService(this.platform.Service.AccessoryInformation)
|
|
50
32
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
51
33
|
.setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
|
|
52
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
|
|
34
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
|
|
35
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision(accessory, device))
|
|
36
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
37
|
+
.updateValue(this.FirmwareRevision(accessory, device));
|
|
53
38
|
// get the Television service if it exists, otherwise create a new Television service
|
|
54
39
|
// you can create multiple services for each accessory
|
|
55
40
|
(this.coolerService = accessory.getService(this.platform.Service.HeaterCooler) || accessory.addService(this.platform.Service.HeaterCooler)),
|
|
@@ -75,13 +60,13 @@ class AirConditioner {
|
|
|
75
60
|
if (this.hide_automode) {
|
|
76
61
|
this.TargetHeaterCoolerState = 1 || 2;
|
|
77
62
|
this.ValidValues = [1, 2];
|
|
78
|
-
this.debugLog(
|
|
63
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ValidValues: ${(0, super_stringify_1.default)(this.ValidValues)},` +
|
|
79
64
|
` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
80
65
|
}
|
|
81
66
|
else {
|
|
82
67
|
this.TargetHeaterCoolerState = 0 || 1 || 2;
|
|
83
68
|
this.ValidValues = [0, 1, 2];
|
|
84
|
-
this.debugLog(
|
|
69
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ValidValues: ${(0, super_stringify_1.default)(this.ValidValues)},` +
|
|
85
70
|
` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
86
71
|
}
|
|
87
72
|
this.coolerService
|
|
@@ -141,7 +126,7 @@ class AirConditioner {
|
|
|
141
126
|
*/
|
|
142
127
|
async pushAirConditionerOnChanges() {
|
|
143
128
|
if (this.Active !== this.platform.Characteristic.Active.ACTIVE || this.pushOn) {
|
|
144
|
-
const body =
|
|
129
|
+
const body = (0, super_stringify_1.default)({
|
|
145
130
|
'command': 'turnOn',
|
|
146
131
|
'parameter': 'default',
|
|
147
132
|
'commandType': 'command',
|
|
@@ -150,7 +135,7 @@ class AirConditioner {
|
|
|
150
135
|
}
|
|
151
136
|
}
|
|
152
137
|
async pushAirConditionerOffChanges() {
|
|
153
|
-
const body =
|
|
138
|
+
const body = (0, super_stringify_1.default)({
|
|
154
139
|
'command': 'turnOff',
|
|
155
140
|
'parameter': 'default',
|
|
156
141
|
'commandType': 'command',
|
|
@@ -182,22 +167,23 @@ class AirConditioner {
|
|
|
182
167
|
}
|
|
183
168
|
if (this.CurrentMode === 1) {
|
|
184
169
|
this.CurrentTemperature = 25;
|
|
185
|
-
this.debugLog(
|
|
170
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},`
|
|
171
|
+
+ ` CurrentTemperature: ${this.CurrentTemperature}`);
|
|
186
172
|
}
|
|
187
173
|
const parameter = `${this.CurrentTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
|
|
188
174
|
if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
189
175
|
this.CurrentTemperatureUndefined();
|
|
190
|
-
if (this.CurrentTemperature < this.
|
|
176
|
+
if (this.CurrentTemperature < this.accessory.context.CurrentTemperature) {
|
|
191
177
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
192
178
|
}
|
|
193
|
-
else if (this.CurrentTemperature > this.
|
|
179
|
+
else if (this.CurrentTemperature > this.accessory.context.CurrentTemperature) {
|
|
194
180
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
195
181
|
}
|
|
196
182
|
}
|
|
197
183
|
else {
|
|
198
184
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
199
185
|
}
|
|
200
|
-
const body =
|
|
186
|
+
const body = (0, super_stringify_1.default)({
|
|
201
187
|
'command': 'setAll',
|
|
202
188
|
'parameter': `${parameter}`,
|
|
203
189
|
'commandType': 'command',
|
|
@@ -205,161 +191,73 @@ class AirConditioner {
|
|
|
205
191
|
await this.pushChanges(body);
|
|
206
192
|
}
|
|
207
193
|
async pushChanges(body) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
.
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
194
|
+
if (this.device.connectionType === 'OpenAPI') {
|
|
195
|
+
try {
|
|
196
|
+
// Make Push On request to the API
|
|
197
|
+
const t = Date.now();
|
|
198
|
+
const nonce = 'requestID';
|
|
199
|
+
const data = this.platform.config.credentials?.token + t + nonce;
|
|
200
|
+
const signTerm = crypto_1.default.createHmac('sha256', this.platform.config.credentials?.secret)
|
|
201
|
+
.update(Buffer.from(data, 'utf-8'))
|
|
202
|
+
.digest();
|
|
203
|
+
const sign = signTerm.toString('base64');
|
|
204
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} sign: ${sign}`);
|
|
205
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
|
|
206
|
+
const options = {
|
|
207
|
+
hostname: settings_1.HostDomain,
|
|
208
|
+
port: 443,
|
|
209
|
+
path: `${settings_1.DevicePath}/${this.device.deviceId}/commands`,
|
|
210
|
+
method: 'POST',
|
|
211
|
+
headers: {
|
|
212
|
+
'Authorization': this.platform.config.credentials?.token,
|
|
213
|
+
'sign': sign,
|
|
214
|
+
'nonce': nonce,
|
|
215
|
+
't': t,
|
|
216
|
+
'Content-Type': 'application/json',
|
|
217
|
+
'Content-Length': body.length,
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
const req = https_1.default.request(options, res => {
|
|
221
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushchanges statusCode: ${res.statusCode}`);
|
|
222
|
+
this.statusCode({ res });
|
|
223
|
+
res.on('data', d => {
|
|
224
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} d: ${d}`);
|
|
225
|
+
});
|
|
238
226
|
});
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
catch (e) {
|
|
257
|
-
this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges`);
|
|
258
|
-
if (this.deviceLogging.includes('debug')) {
|
|
259
|
-
this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges,` + ` Error Message: ${JSON.stringify(e.message)}`);
|
|
227
|
+
req.on('error', (e) => {
|
|
228
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} error message: ${e.message}`);
|
|
229
|
+
});
|
|
230
|
+
req.write(body);
|
|
231
|
+
req.end();
|
|
232
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushchanges: ${(0, super_stringify_1.default)(req)}`);
|
|
233
|
+
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
234
|
+
this.HeatingThresholdTemperature = this.CurrentTemperature;
|
|
235
|
+
this.CoolingThresholdTemperature = this.CurrentTemperature;
|
|
236
|
+
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperature;
|
|
237
|
+
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperature;
|
|
238
|
+
this.updateHomeKitCharacteristics();
|
|
239
|
+
}
|
|
240
|
+
catch (e) {
|
|
241
|
+
this.apiError(e);
|
|
242
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType} Connection,`
|
|
243
|
+
+ ` Error Message: ${(0, super_stringify_1.default)(e.message)}`);
|
|
260
244
|
}
|
|
261
|
-
this.apiError(e);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
async statusCode({ res }) {
|
|
265
|
-
switch (res.statusCode) {
|
|
266
|
-
case 151:
|
|
267
|
-
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Command not supported by this device type.`);
|
|
268
|
-
break;
|
|
269
|
-
case 152:
|
|
270
|
-
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Device not found.`);
|
|
271
|
-
break;
|
|
272
|
-
case 160:
|
|
273
|
-
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Command is not supported.`);
|
|
274
|
-
break;
|
|
275
|
-
case 161:
|
|
276
|
-
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Device is offline.`);
|
|
277
|
-
break;
|
|
278
|
-
case 171:
|
|
279
|
-
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
280
|
-
break;
|
|
281
|
-
case 190:
|
|
282
|
-
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
|
|
283
|
-
` with server, Or command: ${JSON.stringify(res)} format is invalid`);
|
|
284
|
-
break;
|
|
285
|
-
case 100:
|
|
286
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Command successfully sent.`);
|
|
287
|
-
break;
|
|
288
|
-
default:
|
|
289
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Unknown statusCode.`);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
async updateHomeKitCharacteristics() {
|
|
293
|
-
if (this.Active === undefined) {
|
|
294
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
295
|
-
}
|
|
296
|
-
else {
|
|
297
|
-
this.coolerService?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
|
|
298
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
|
|
299
|
-
}
|
|
300
|
-
if (this.RotationSpeed === undefined) {
|
|
301
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`);
|
|
302
|
-
}
|
|
303
|
-
else {
|
|
304
|
-
this.coolerService?.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.RotationSpeed);
|
|
305
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`);
|
|
306
|
-
}
|
|
307
|
-
if (this.CurrentTemperature === undefined) {
|
|
308
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
|
|
309
|
-
}
|
|
310
|
-
else {
|
|
311
|
-
this.coolerService?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
|
|
312
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
|
|
313
|
-
}
|
|
314
|
-
if (this.TargetHeaterCoolerState === undefined) {
|
|
315
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
316
|
-
}
|
|
317
|
-
else {
|
|
318
|
-
this.coolerService?.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.TargetHeaterCoolerState);
|
|
319
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName}` + ` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
320
|
-
}
|
|
321
|
-
if (this.CurrentHeaterCoolerState === undefined) {
|
|
322
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
323
|
-
}
|
|
324
|
-
else {
|
|
325
|
-
this.coolerService?.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
|
|
326
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName}` + ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
327
|
-
}
|
|
328
|
-
if (this.HeatingThresholdTemperature === undefined) {
|
|
329
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
330
|
-
}
|
|
331
|
-
else {
|
|
332
|
-
this.coolerService?.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, this.HeatingThresholdTemperature);
|
|
333
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName}` + ` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
334
|
-
}
|
|
335
|
-
if (this.CoolingThresholdTemperature === undefined) {
|
|
336
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
|
|
337
245
|
}
|
|
338
246
|
else {
|
|
339
|
-
this.
|
|
340
|
-
|
|
247
|
+
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
248
|
+
+ ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
341
249
|
}
|
|
342
250
|
}
|
|
343
|
-
async apiError(e) {
|
|
344
|
-
this.coolerService.updateCharacteristic(this.platform.Characteristic.Active, e);
|
|
345
|
-
this.coolerService.updateCharacteristic(this.platform.Characteristic.RotationSpeed, e);
|
|
346
|
-
this.coolerService.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
|
|
347
|
-
this.coolerService.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, e);
|
|
348
|
-
this.coolerService.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, e);
|
|
349
|
-
this.coolerService.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, e);
|
|
350
|
-
this.coolerService.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, e);
|
|
351
|
-
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
352
|
-
}
|
|
353
251
|
async CurrentTemperatureGet() {
|
|
354
252
|
if (this.CurrentTemperature === undefined) {
|
|
355
253
|
this.CurrentTemperature = 24;
|
|
356
|
-
this.
|
|
254
|
+
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
357
255
|
}
|
|
358
256
|
else {
|
|
359
|
-
this.
|
|
257
|
+
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
360
258
|
}
|
|
361
|
-
this.debugLog(
|
|
362
|
-
this.accessory.context.CurrentTemperature = this.
|
|
259
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CurrentTemperature: ${this.CurrentTemperature}`);
|
|
260
|
+
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
363
261
|
return this.CurrentTemperature;
|
|
364
262
|
}
|
|
365
263
|
async RotationSpeedGet() {
|
|
@@ -372,9 +270,8 @@ class AirConditioner {
|
|
|
372
270
|
else {
|
|
373
271
|
this.RotationSpeed = this.CurrentFanSpeed - 1;
|
|
374
272
|
}
|
|
375
|
-
this.debugLog(
|
|
376
|
-
this.
|
|
377
|
-
this.accessory.context.RotationSpeed = this.RotationSpeedCached;
|
|
273
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get RotationSpeed: ${this.RotationSpeed}`);
|
|
274
|
+
this.accessory.context.RotationSpeed = this.RotationSpeed;
|
|
378
275
|
return this.RotationSpeed;
|
|
379
276
|
}
|
|
380
277
|
async RotationSpeedSet(value) {
|
|
@@ -385,21 +282,19 @@ class AirConditioner {
|
|
|
385
282
|
this.CurrentFanSpeed = Number(value) + 1;
|
|
386
283
|
}
|
|
387
284
|
this.RotationSpeed = this.CurrentFanSpeed;
|
|
388
|
-
this.
|
|
389
|
-
this.accessory.context.RotationSpeed = this.RotationSpeedCached;
|
|
285
|
+
this.accessory.context.RotationSpeed = this.RotationSpeed;
|
|
390
286
|
this.pushAirConditionerStatusChanges();
|
|
391
287
|
}
|
|
392
288
|
async ActiveSet(value) {
|
|
393
|
-
this.debugLog(
|
|
289
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Active: ${value}`);
|
|
394
290
|
this.Active = value;
|
|
395
|
-
this.
|
|
396
|
-
this.accessory.context.Active = this.ActiveCached;
|
|
291
|
+
this.accessory.context.Active = this.Active;
|
|
397
292
|
if (value === this.platform.Characteristic.Active.INACTIVE) {
|
|
398
|
-
this.debugLog(
|
|
293
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`);
|
|
399
294
|
this.pushAirConditionerOffChanges();
|
|
400
295
|
}
|
|
401
296
|
else {
|
|
402
|
-
this.debugLog(
|
|
297
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges, Active: ${this.Active}`);
|
|
403
298
|
if (this.pushOn) {
|
|
404
299
|
this.pushAirConditionerOnChanges();
|
|
405
300
|
}
|
|
@@ -411,21 +306,20 @@ class AirConditioner {
|
|
|
411
306
|
async TargetHeaterCoolerStateGet() {
|
|
412
307
|
if (this.ValidValues === this.valid012) {
|
|
413
308
|
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
414
|
-
this.debugLog(
|
|
309
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get (AUTO) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
|
|
415
310
|
` ValidValues: ${this.ValidValues}`);
|
|
416
311
|
}
|
|
417
312
|
else if (this.ValidValues === this.valid12) {
|
|
418
313
|
this.TargetHeaterCoolerState =
|
|
419
314
|
this.platform.Characteristic.TargetHeaterCoolerState.COOL || this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
420
|
-
this.debugLog(
|
|
315
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get (COOL/HEAT) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
|
|
421
316
|
` ValidValues: ${this.ValidValues}`);
|
|
422
317
|
}
|
|
423
318
|
else {
|
|
424
|
-
this.debugLog(
|
|
319
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
|
|
425
320
|
` ValidValues: ${this.ValidValues}`);
|
|
426
321
|
}
|
|
427
|
-
this.
|
|
428
|
-
this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerStateCached;
|
|
322
|
+
this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerState;
|
|
429
323
|
return this.TargetHeaterCoolerState;
|
|
430
324
|
}
|
|
431
325
|
async TargetHeaterCoolerStateSet(value) {
|
|
@@ -437,7 +331,7 @@ class AirConditioner {
|
|
|
437
331
|
this.TargetHeaterCoolerStateCOOL();
|
|
438
332
|
}
|
|
439
333
|
else {
|
|
440
|
-
this.errorLog(
|
|
334
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
|
|
441
335
|
` hide_automode: ${this.hide_automode} `);
|
|
442
336
|
}
|
|
443
337
|
}
|
|
@@ -452,96 +346,230 @@ class AirConditioner {
|
|
|
452
346
|
this.TargetHeaterCoolerStateCOOL();
|
|
453
347
|
}
|
|
454
348
|
else {
|
|
455
|
-
this.errorLog(
|
|
349
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
|
|
456
350
|
` hide_automode: ${this.hide_automode} `);
|
|
457
351
|
}
|
|
458
352
|
}
|
|
459
|
-
this.
|
|
460
|
-
this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerStateCached;
|
|
353
|
+
this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerState;
|
|
461
354
|
this.pushAirConditionerStatusChanges();
|
|
462
355
|
}
|
|
463
356
|
async TargetHeaterCoolerStateAUTO() {
|
|
464
357
|
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
465
358
|
this.CurrentMode = 1;
|
|
466
|
-
this.debugLog(
|
|
467
|
-
this.debugLog(
|
|
359
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (AUTO) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
360
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
468
361
|
}
|
|
469
362
|
async TargetHeaterCoolerStateCOOL() {
|
|
470
363
|
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.COOL;
|
|
471
364
|
this.CurrentMode = 2;
|
|
472
|
-
this.debugLog(
|
|
473
|
-
this.debugLog(
|
|
365
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (COOL) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
366
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
474
367
|
}
|
|
475
368
|
async TargetHeaterCoolerStateHEAT() {
|
|
476
369
|
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
477
370
|
this.CurrentMode = 5;
|
|
478
|
-
this.debugLog(
|
|
479
|
-
this.debugLog(
|
|
371
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (HEAT) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
372
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
480
373
|
}
|
|
481
374
|
async CurrentHeaterCoolerStateGet() {
|
|
482
375
|
if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
483
376
|
this.CurrentTemperatureUndefined();
|
|
484
|
-
if (this.CurrentTemperature < this.
|
|
377
|
+
if (this.CurrentTemperature < this.accessory.context.CurrentTemperature) {
|
|
485
378
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
486
|
-
this.debugLog(
|
|
379
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
380
|
+
+ ` Get (COOLLING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
487
381
|
}
|
|
488
|
-
else if (this.CurrentTemperature > this.
|
|
382
|
+
else if (this.CurrentTemperature > this.accessory.context.CurrentTemperature) {
|
|
489
383
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
490
|
-
this.debugLog(
|
|
384
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
385
|
+
+ ` Get (HEATING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
491
386
|
}
|
|
492
387
|
}
|
|
493
388
|
else {
|
|
494
389
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
495
|
-
this.debugLog(
|
|
390
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
391
|
+
+ ` Get (INACTIVE) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
496
392
|
}
|
|
497
|
-
this.
|
|
498
|
-
this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerStateCached;
|
|
393
|
+
this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerState;
|
|
499
394
|
return this.CurrentHeaterCoolerState;
|
|
500
395
|
}
|
|
501
396
|
async HeatingThresholdTemperatureGet() {
|
|
502
397
|
this.CurrentTemperatureUndefined;
|
|
503
|
-
this.CurrentTemperature = this.
|
|
504
|
-
this.HeatingThresholdTemperature = this.
|
|
505
|
-
this.
|
|
506
|
-
this.accessory.
|
|
507
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
398
|
+
this.CurrentTemperature = this.accessory.context.CurrentTemperature;
|
|
399
|
+
this.HeatingThresholdTemperature = this.accessory.context.CurrentTemperature;
|
|
400
|
+
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperature;
|
|
401
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
508
402
|
return this.HeatingThresholdTemperature;
|
|
509
403
|
}
|
|
510
404
|
async HeatingThresholdTemperatureSet(value) {
|
|
511
|
-
this.
|
|
405
|
+
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
512
406
|
this.CurrentTemperature = value;
|
|
513
|
-
this.
|
|
514
|
-
this.accessory.
|
|
515
|
-
|
|
516
|
-
` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`);
|
|
407
|
+
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperature;
|
|
408
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set HeatingThresholdTemperature: ${this.HeatingThresholdTemperature},` +
|
|
409
|
+
` CurrentTemperatureCached: ${this.accessory.context.CurrentTemperature}`);
|
|
517
410
|
this.pushAirConditionerStatusChanges();
|
|
518
411
|
}
|
|
519
412
|
async CoolingThresholdTemperatureGet() {
|
|
520
413
|
this.CurrentTemperatureUndefined;
|
|
521
|
-
this.CurrentTemperature = this.
|
|
522
|
-
this.CoolingThresholdTemperature = this.
|
|
523
|
-
this.
|
|
524
|
-
this.accessory.
|
|
525
|
-
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
|
|
414
|
+
this.CurrentTemperature = this.accessory.context.CurrentTemperature;
|
|
415
|
+
this.CoolingThresholdTemperature = this.accessory.context.CurrentTemperature;
|
|
416
|
+
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperature;
|
|
417
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
|
|
526
418
|
return this.CoolingThresholdTemperature;
|
|
527
419
|
}
|
|
528
420
|
async CoolingThresholdTemperatureSet(value) {
|
|
529
|
-
this.
|
|
421
|
+
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
530
422
|
this.CurrentTemperature = value;
|
|
531
|
-
this.
|
|
532
|
-
this.accessory.
|
|
533
|
-
|
|
534
|
-
` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`);
|
|
423
|
+
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperature;
|
|
424
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set CoolingThresholdTemperature: ${this.CoolingThresholdTemperature},` +
|
|
425
|
+
` CurrentTemperatureCached: ${this.accessory.context.CurrentTemperature}`);
|
|
535
426
|
this.pushAirConditionerStatusChanges();
|
|
536
427
|
}
|
|
537
428
|
async CurrentTemperatureUndefined() {
|
|
538
429
|
if (this.CurrentTemperature === undefined) {
|
|
539
430
|
this.CurrentTemperature = 24;
|
|
540
431
|
}
|
|
541
|
-
if (this.
|
|
432
|
+
if (this.accessory.context.CurrentTemperature === undefined) {
|
|
542
433
|
this.CurrentTemperature = 30;
|
|
543
434
|
}
|
|
544
435
|
}
|
|
436
|
+
async updateHomeKitCharacteristics() {
|
|
437
|
+
if (this.Active === undefined) {
|
|
438
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
this.accessory.context.Active = this.Active;
|
|
442
|
+
this.coolerService?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
|
|
443
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
|
|
444
|
+
}
|
|
445
|
+
if (this.RotationSpeed === undefined) {
|
|
446
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`);
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
this.accessory.context.RotationSpeed = this.RotationSpeed;
|
|
450
|
+
this.coolerService?.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.RotationSpeed);
|
|
451
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`);
|
|
452
|
+
}
|
|
453
|
+
if (this.CurrentTemperature === undefined) {
|
|
454
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
458
|
+
this.coolerService?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
|
|
459
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
|
|
460
|
+
}
|
|
461
|
+
if (this.TargetHeaterCoolerState === undefined) {
|
|
462
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
463
|
+
}
|
|
464
|
+
else {
|
|
465
|
+
this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerState;
|
|
466
|
+
this.coolerService?.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.TargetHeaterCoolerState);
|
|
467
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}` + ` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
468
|
+
}
|
|
469
|
+
if (this.CurrentHeaterCoolerState === undefined) {
|
|
470
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerState;
|
|
474
|
+
this.coolerService?.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
|
|
475
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
476
|
+
+ ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
477
|
+
}
|
|
478
|
+
if (this.HeatingThresholdTemperature === undefined) {
|
|
479
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperature;
|
|
483
|
+
this.coolerService?.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, this.HeatingThresholdTemperature);
|
|
484
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
485
|
+
+ ` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
486
|
+
}
|
|
487
|
+
if (this.CoolingThresholdTemperature === undefined) {
|
|
488
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
|
|
489
|
+
}
|
|
490
|
+
else {
|
|
491
|
+
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperature;
|
|
492
|
+
this.coolerService?.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, this.CoolingThresholdTemperature);
|
|
493
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
494
|
+
+ ` updateCharacteristic CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
async statusCode({ res }) {
|
|
498
|
+
switch (res.statusCode) {
|
|
499
|
+
case 151:
|
|
500
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command not supported by this device type.`);
|
|
501
|
+
break;
|
|
502
|
+
case 152:
|
|
503
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device not found.`);
|
|
504
|
+
break;
|
|
505
|
+
case 160:
|
|
506
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command is not supported.`);
|
|
507
|
+
break;
|
|
508
|
+
case 161:
|
|
509
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline.`);
|
|
510
|
+
break;
|
|
511
|
+
case 171:
|
|
512
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
513
|
+
break;
|
|
514
|
+
case 190:
|
|
515
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
|
|
516
|
+
` with server, Or command: ${(0, super_stringify_1.default)(res)} format is invalid`);
|
|
517
|
+
break;
|
|
518
|
+
case 100:
|
|
519
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Command successfully sent.`);
|
|
520
|
+
break;
|
|
521
|
+
default:
|
|
522
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode.`);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
async apiError(e) {
|
|
526
|
+
this.coolerService.updateCharacteristic(this.platform.Characteristic.Active, e);
|
|
527
|
+
this.coolerService.updateCharacteristic(this.platform.Characteristic.RotationSpeed, e);
|
|
528
|
+
this.coolerService.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
|
|
529
|
+
this.coolerService.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, e);
|
|
530
|
+
this.coolerService.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, e);
|
|
531
|
+
this.coolerService.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, e);
|
|
532
|
+
this.coolerService.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, e);
|
|
533
|
+
}
|
|
534
|
+
FirmwareRevision(accessory, device) {
|
|
535
|
+
let FirmwareRevision;
|
|
536
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
537
|
+
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
|
|
538
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
539
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
540
|
+
if (accessory.context.FirmwareRevision) {
|
|
541
|
+
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
542
|
+
}
|
|
543
|
+
else if (device.firmware) {
|
|
544
|
+
FirmwareRevision = device.firmware;
|
|
545
|
+
}
|
|
546
|
+
else {
|
|
547
|
+
FirmwareRevision = this.platform.version;
|
|
548
|
+
}
|
|
549
|
+
return FirmwareRevision;
|
|
550
|
+
}
|
|
551
|
+
async context(device) {
|
|
552
|
+
if (this.Active === undefined) {
|
|
553
|
+
this.Active = this.platform.Characteristic.Active.INACTIVE;
|
|
554
|
+
}
|
|
555
|
+
else {
|
|
556
|
+
this.Active = this.accessory.context.Active;
|
|
557
|
+
}
|
|
558
|
+
if (this.CurrentTemperature === undefined) {
|
|
559
|
+
this.CurrentTemperature = 24;
|
|
560
|
+
}
|
|
561
|
+
else {
|
|
562
|
+
this.CurrentTemperature = this.accessory.context.CurrentTemperature;
|
|
563
|
+
}
|
|
564
|
+
if (device.irair?.hide_automode) {
|
|
565
|
+
this.hide_automode = device.irair?.hide_automode;
|
|
566
|
+
this.accessory.context.hide_automode = this.hide_automode;
|
|
567
|
+
}
|
|
568
|
+
else {
|
|
569
|
+
this.hide_automode = device.irair?.hide_automode;
|
|
570
|
+
this.accessory.context.hide_automode = this.hide_automode;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
545
573
|
async config(device) {
|
|
546
574
|
let config = {};
|
|
547
575
|
if (device.irair) {
|
|
@@ -550,26 +578,32 @@ class AirConditioner {
|
|
|
550
578
|
if (device.logging !== undefined) {
|
|
551
579
|
config['logging'] = device.logging;
|
|
552
580
|
}
|
|
581
|
+
if (device.connectionType !== undefined) {
|
|
582
|
+
config['connectionType'] = device.connectionType;
|
|
583
|
+
}
|
|
584
|
+
if (device.external !== undefined) {
|
|
585
|
+
config['external'] = device.external;
|
|
586
|
+
}
|
|
553
587
|
if (Object.entries(config).length !== 0) {
|
|
554
|
-
this.infoLog(
|
|
588
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${(0, super_stringify_1.default)(config)}`);
|
|
555
589
|
}
|
|
556
590
|
}
|
|
557
591
|
async logs(device) {
|
|
558
592
|
if (this.platform.debugMode) {
|
|
559
593
|
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
560
|
-
this.debugLog(
|
|
594
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
561
595
|
}
|
|
562
596
|
else if (device.logging) {
|
|
563
597
|
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
564
|
-
this.debugLog(
|
|
598
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
565
599
|
}
|
|
566
600
|
else if (this.platform.config.options?.logging) {
|
|
567
601
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
568
|
-
this.debugLog(
|
|
602
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
569
603
|
}
|
|
570
604
|
else {
|
|
571
605
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
572
|
-
this.debugLog(
|
|
606
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
573
607
|
}
|
|
574
608
|
}
|
|
575
609
|
async pushOnChanges(device) {
|
|
@@ -593,11 +627,25 @@ class AirConditioner {
|
|
|
593
627
|
this.platform.log.warn(String(...log));
|
|
594
628
|
}
|
|
595
629
|
}
|
|
630
|
+
debugWarnLog(...log) {
|
|
631
|
+
if (this.enablingDeviceLogging()) {
|
|
632
|
+
if (this.deviceLogging?.includes('debug')) {
|
|
633
|
+
this.platform.log.warn('[DEBUG]', String(...log));
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
596
637
|
errorLog(...log) {
|
|
597
638
|
if (this.enablingDeviceLogging()) {
|
|
598
639
|
this.platform.log.error(String(...log));
|
|
599
640
|
}
|
|
600
641
|
}
|
|
642
|
+
debugErrorLog(...log) {
|
|
643
|
+
if (this.enablingDeviceLogging()) {
|
|
644
|
+
if (this.deviceLogging?.includes('debug')) {
|
|
645
|
+
this.platform.log.error('[DEBUG]', String(...log));
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
}
|
|
601
649
|
debugLog(...log) {
|
|
602
650
|
if (this.enablingDeviceLogging()) {
|
|
603
651
|
if (this.deviceLogging === 'debug') {
|