@switchbot/homebridge-switchbot 3.5.1-beta.12 → 3.5.1-beta.3
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/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +9 -6
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +3 -7
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.js +9 -9
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +3 -5
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +3 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +103 -44
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +1 -0
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +49 -18
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +9 -9
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +19 -19
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +10 -22
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js +67 -89
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +17 -15
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +76 -76
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +35 -35
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +9 -9
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +9 -9
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +12 -14
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +245 -245
- package/dist/platform.js.map +1 -1
- package/dist/types/devicewebhookstatus.d.ts +1 -1
- package/dist/types/devicewebhookstatus.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/device/blindtilt.ts +1 -1
- package/src/device/bot.ts +1 -1
- package/src/device/ceilinglight.ts +15 -7
- package/src/device/colorbulb.ts +11 -8
- package/src/device/curtain.ts +1 -1
- package/src/device/device.ts +9 -9
- package/src/device/fan.ts +1 -1
- package/src/device/waterdetector.ts +3 -5
- package/src/irdevice/airconditioner.ts +97 -53
- package/src/irdevice/airpurifier.ts +45 -23
- package/src/irdevice/camera.ts +9 -9
- package/src/irdevice/fan.ts +19 -19
- package/src/irdevice/irdevice.ts +68 -92
- package/src/irdevice/light.ts +17 -15
- package/src/irdevice/other.ts +76 -76
- package/src/irdevice/tv.ts +35 -35
- package/src/irdevice/vacuumcleaner.ts +9 -9
- package/src/irdevice/waterheater.ts +9 -9
- package/src/platform.ts +247 -247
- package/src/types/devicewebhookstatus.ts +1 -1
|
@@ -200,13 +200,22 @@ export class CeilingLight extends deviceBase {
|
|
|
200
200
|
// On
|
|
201
201
|
this.LightBulb.On = deviceStatus.power;
|
|
202
202
|
await this.debugLog(`On: ${this.LightBulb.On}`);
|
|
203
|
+
|
|
203
204
|
// Brightness
|
|
204
205
|
this.LightBulb.Brightness = deviceStatus.brightness;
|
|
205
206
|
await this.debugLog(`Brightness: ${this.LightBulb.Brightness}`);
|
|
207
|
+
|
|
206
208
|
// ColorTemperature
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
209
|
+
if (!Number.isNaN(deviceStatus.colorTemperature)) {
|
|
210
|
+
await this.debugLog(`OpenAPI ColorTemperature: ${deviceStatus.colorTemperature}`);
|
|
211
|
+
const mired = Math.round(1000000 / deviceStatus.colorTemperature);
|
|
212
|
+
|
|
213
|
+
this.LightBulb.ColorTemperature = Number(mired);
|
|
214
|
+
|
|
215
|
+
this.LightBulb.ColorTemperature = Math.max(Math.min(this.LightBulb.ColorTemperature, 500), 140);
|
|
216
|
+
await this.debugLog(`ColorTemperature: ${this.LightBulb.ColorTemperature}`);
|
|
217
|
+
}
|
|
218
|
+
|
|
210
219
|
// Firmware Version
|
|
211
220
|
const version = deviceStatus.version.toString();
|
|
212
221
|
await this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`);
|
|
@@ -234,8 +243,7 @@ export class CeilingLight extends deviceBase {
|
|
|
234
243
|
this.LightBulb.Brightness = context.brightness;
|
|
235
244
|
await this.debugLog(`Brightness: ${this.LightBulb.Brightness}`);
|
|
236
245
|
// ColorTemperature
|
|
237
|
-
|
|
238
|
-
this.LightBulb.ColorTemperature = Math.max(Math.min(miredColorTemperature, 500), 140);
|
|
246
|
+
this.LightBulb.ColorTemperature = context.colorTemperature;
|
|
239
247
|
await this.debugLog(`ColorTemperature: ${this.LightBulb.ColorTemperature}`);
|
|
240
248
|
}
|
|
241
249
|
|
|
@@ -301,7 +309,7 @@ export class CeilingLight extends deviceBase {
|
|
|
301
309
|
async registerWebhook() {
|
|
302
310
|
if (this.device.webhook) {
|
|
303
311
|
await this.debugLog('is listening webhook.');
|
|
304
|
-
this.platform.webhookEventHandler[this.device.deviceId] = async (context
|
|
312
|
+
this.platform.webhookEventHandler[this.device.deviceId] = async (context) => {
|
|
305
313
|
try {
|
|
306
314
|
await this.debugLog(`received Webhook: ${JSON.stringify(context)}`);
|
|
307
315
|
await this.parseStatusWebhook(context);
|
|
@@ -468,7 +476,7 @@ export class CeilingLight extends deviceBase {
|
|
|
468
476
|
async pushColorTemperatureChanges(): Promise<void> {
|
|
469
477
|
await this.debugLog('pushColorTemperatureChanges');
|
|
470
478
|
if (this.LightBulb.ColorTemperature !== this.accessory.context.ColorTemperature) {
|
|
471
|
-
const kelvin = Math.round(1000000
|
|
479
|
+
const kelvin = Math.round(1000000 / Number(this.LightBulb.ColorTemperature));
|
|
472
480
|
this.accessory.context.kelvin = kelvin;
|
|
473
481
|
const bodyChange = JSON.stringify({
|
|
474
482
|
command: 'setColorTemperature',
|
package/src/device/colorbulb.ts
CHANGED
|
@@ -200,8 +200,7 @@ export class ColorBulb extends deviceBase {
|
|
|
200
200
|
this.LightBulb.Saturation = saturation;
|
|
201
201
|
await this.debugLog(`Saturation: ${this.LightBulb.Saturation}`);
|
|
202
202
|
// ColorTemperature
|
|
203
|
-
|
|
204
|
-
this.LightBulb.ColorTemperature = Math.max(Math.min(miredColorTemperature, 500), 140);
|
|
203
|
+
this.LightBulb.ColorTemperature = Math.max(Math.min(serviceData.color_temperature, 500), 140);
|
|
205
204
|
await this.debugLog(`ColorTemperature: ${this.LightBulb.ColorTemperature}`);
|
|
206
205
|
}
|
|
207
206
|
|
|
@@ -210,28 +209,35 @@ export class ColorBulb extends deviceBase {
|
|
|
210
209
|
*/
|
|
211
210
|
async openAPIparseStatus(deviceStatus: colorBulbStatus): Promise<void> {
|
|
212
211
|
await this.debugLog('openAPIparseStatus');
|
|
212
|
+
|
|
213
213
|
// On
|
|
214
214
|
this.LightBulb.On = deviceStatus.power === 'on' ? true : false;
|
|
215
215
|
await this.debugLog(`On: ${this.LightBulb.On}`);
|
|
216
|
+
|
|
216
217
|
// Brightness
|
|
217
218
|
this.LightBulb.Brightness = deviceStatus.brightness;
|
|
218
219
|
await this.debugLog(`Brightness: ${this.LightBulb.Brightness}`);
|
|
220
|
+
|
|
219
221
|
// Color, Hue & Brightness
|
|
220
222
|
await this.debugLog(`color: ${JSON.stringify(deviceStatus.color)}`);
|
|
221
223
|
const [red, green, blue] = deviceStatus.color.split(':');
|
|
222
224
|
await this.debugLog(`red: ${JSON.stringify(red)}, green: ${JSON.stringify(green)}, blue: ${JSON.stringify(blue)}`);
|
|
223
225
|
const [hue, saturation] = rgb2hs(red, green, blue);
|
|
224
226
|
await this.debugLog(`hs: ${JSON.stringify(rgb2hs(red, green, blue))}`);
|
|
227
|
+
|
|
225
228
|
// Hue
|
|
226
229
|
this.LightBulb.Hue = hue;
|
|
227
230
|
await this.debugLog(`Hue: ${this.LightBulb.Hue}`);
|
|
231
|
+
|
|
228
232
|
// Saturation
|
|
229
233
|
this.LightBulb.Saturation = saturation;
|
|
230
234
|
await this.debugLog(`Saturation: ${this.LightBulb.Saturation}`);
|
|
235
|
+
|
|
231
236
|
// ColorTemperature
|
|
232
237
|
const miredColorTemperature = Math.round(1000000 / deviceStatus.colorTemperature);
|
|
233
238
|
this.LightBulb.ColorTemperature = Math.max(Math.min(miredColorTemperature, 500), 140);
|
|
234
239
|
await this.debugLog(`ColorTemperature: ${this.LightBulb.ColorTemperature}`);
|
|
240
|
+
|
|
235
241
|
// Firmware Version
|
|
236
242
|
const version = deviceStatus.version.toString();
|
|
237
243
|
await this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`);
|
|
@@ -272,8 +278,7 @@ export class ColorBulb extends deviceBase {
|
|
|
272
278
|
this.LightBulb.Saturation = saturation;
|
|
273
279
|
await this.debugLog(`Saturation: ${this.LightBulb.Saturation}`);
|
|
274
280
|
// ColorTemperature
|
|
275
|
-
|
|
276
|
-
this.LightBulb.ColorTemperature = Math.max(Math.min(miredColorTemperature, 500), 140);
|
|
281
|
+
this.LightBulb.ColorTemperature = context.colorTemperature;
|
|
277
282
|
await this.debugLog(`ColorTemperature: ${this.LightBulb.ColorTemperature}`);
|
|
278
283
|
}
|
|
279
284
|
|
|
@@ -339,7 +344,7 @@ export class ColorBulb extends deviceBase {
|
|
|
339
344
|
async registerWebhook() {
|
|
340
345
|
if (this.device.webhook) {
|
|
341
346
|
await this.debugLog('is listening webhook.');
|
|
342
|
-
this.platform.webhookEventHandler[this.device.deviceId] = async (context
|
|
347
|
+
this.platform.webhookEventHandler[this.device.deviceId] = async (context) => {
|
|
343
348
|
try {
|
|
344
349
|
await this.debugLog(`received Webhook: ${JSON.stringify(context)}`);
|
|
345
350
|
await this.parseStatusWebhook(context);
|
|
@@ -484,8 +489,6 @@ export class ColorBulb extends deviceBase {
|
|
|
484
489
|
async BLEpushColorTemperatureChanges(): Promise<void> {
|
|
485
490
|
await this.debugLog('BLEpushColorTemperatureChanges');
|
|
486
491
|
if (this.LightBulb.ColorTemperature !== this.accessory.context.ColorTemperature) {
|
|
487
|
-
const kelvin = Math.round(1000000 / Number(this.LightBulb.ColorTemperature));
|
|
488
|
-
this.accessory.context.kelvin = kelvin;
|
|
489
492
|
const switchbot = await this.platform.connectBLE(this.accessory, this.device);
|
|
490
493
|
await this.convertBLEAddress();
|
|
491
494
|
if (switchbot !== false) {
|
|
@@ -493,7 +496,7 @@ export class ColorBulb extends deviceBase {
|
|
|
493
496
|
.discover({ model: this.device.bleModel, id: this.device.bleMac })
|
|
494
497
|
.then(async (device_list: any) => {
|
|
495
498
|
await this.infoLog(`ColorTemperature: ${this.LightBulb.ColorTemperature}`);
|
|
496
|
-
return await device_list[0].setColorTemperature(
|
|
499
|
+
return await device_list[0].setColorTemperature(this.LightBulb.ColorTemperature);
|
|
497
500
|
})
|
|
498
501
|
.then(async () => {
|
|
499
502
|
await this.successLog(`ColorTemperature: ${this.LightBulb.ColorTemperature} sent over SwitchBot BLE, sent successfully`);
|
package/src/device/curtain.ts
CHANGED
|
@@ -462,7 +462,7 @@ export class Curtain extends deviceBase {
|
|
|
462
462
|
async registerWebhook() {
|
|
463
463
|
if (this.device.webhook) {
|
|
464
464
|
await this.debugLog('is listening webhook.');
|
|
465
|
-
this.platform.webhookEventHandler[this.device.deviceId] = async (context
|
|
465
|
+
this.platform.webhookEventHandler[this.device.deviceId] = async (context) => {
|
|
466
466
|
try {
|
|
467
467
|
await this.debugLog(`received Webhook: ${JSON.stringify(context)}`);
|
|
468
468
|
await this.parseStatusWebhook(context);
|
package/src/device/device.ts
CHANGED
|
@@ -841,48 +841,48 @@ export abstract class deviceBase {
|
|
|
841
841
|
*/
|
|
842
842
|
async infoLog(...log: any[]): Promise<void> {
|
|
843
843
|
if (await this.enablingDeviceLogging()) {
|
|
844
|
-
this.log.info(`${this.device.deviceType}: ${this.accessory.displayName}`, String(...log));
|
|
844
|
+
this.log.info(`${this.device.deviceType}: ${this.accessory.displayName} `, String(...log));
|
|
845
845
|
}
|
|
846
846
|
}
|
|
847
847
|
|
|
848
848
|
async successLog(...log: any[]): Promise<void> {
|
|
849
849
|
if (await this.enablingDeviceLogging()) {
|
|
850
|
-
this.log.success(`${this.device.deviceType}: ${this.accessory.displayName}`, String(...log));
|
|
850
|
+
this.log.success(`${this.device.deviceType}: ${this.accessory.displayName} `, String(...log));
|
|
851
851
|
}
|
|
852
852
|
}
|
|
853
853
|
|
|
854
854
|
async debugSuccessLog(...log: any[]): Promise<void> {
|
|
855
855
|
if (await this.enablingDeviceLogging()) {
|
|
856
856
|
if (this.deviceLogging?.includes('debug')) {
|
|
857
|
-
this.log.success(`[DEBUG] ${this.device.deviceType}: ${this.accessory.displayName}`, String(...log));
|
|
857
|
+
this.log.success(`[DEBUG] ${this.device.deviceType}: ${this.accessory.displayName} `, String(...log));
|
|
858
858
|
}
|
|
859
859
|
}
|
|
860
860
|
}
|
|
861
861
|
|
|
862
862
|
async warnLog(...log: any[]): Promise<void> {
|
|
863
863
|
if (await this.enablingDeviceLogging()) {
|
|
864
|
-
this.log.warn(`${this.device.deviceType}: ${this.accessory.displayName}`, String(...log));
|
|
864
|
+
this.log.warn(`${this.device.deviceType}: ${this.accessory.displayName} `, String(...log));
|
|
865
865
|
}
|
|
866
866
|
}
|
|
867
867
|
|
|
868
868
|
async debugWarnLog(...log: any[]): Promise<void> {
|
|
869
869
|
if (await this.enablingDeviceLogging()) {
|
|
870
870
|
if (this.deviceLogging?.includes('debug')) {
|
|
871
|
-
this.log.warn(`[DEBUG] ${this.device.deviceType}: ${this.accessory.displayName}`, String(...log));
|
|
871
|
+
this.log.warn(`[DEBUG] ${this.device.deviceType}: ${this.accessory.displayName} `, String(...log));
|
|
872
872
|
}
|
|
873
873
|
}
|
|
874
874
|
}
|
|
875
875
|
|
|
876
876
|
async errorLog(...log: any[]): Promise<void> {
|
|
877
877
|
if (await this.enablingDeviceLogging()) {
|
|
878
|
-
this.log.error(`${this.device.deviceType}: ${this.accessory.displayName}`, String(...log));
|
|
878
|
+
this.log.error(`${this.device.deviceType}: ${this.accessory.displayName} `, String(...log));
|
|
879
879
|
}
|
|
880
880
|
}
|
|
881
881
|
|
|
882
882
|
async debugErrorLog(...log: any[]): Promise<void> {
|
|
883
883
|
if (await this.enablingDeviceLogging()) {
|
|
884
884
|
if (this.deviceLogging?.includes('debug')) {
|
|
885
|
-
this.log.error(`[DEBUG] ${this.device.deviceType}: ${this.accessory.displayName}`, String(...log));
|
|
885
|
+
this.log.error(`[DEBUG] ${this.device.deviceType}: ${this.accessory.displayName} `, String(...log));
|
|
886
886
|
}
|
|
887
887
|
}
|
|
888
888
|
}
|
|
@@ -890,9 +890,9 @@ export abstract class deviceBase {
|
|
|
890
890
|
async debugLog(...log: any[]): Promise<void> {
|
|
891
891
|
if (await this.enablingDeviceLogging()) {
|
|
892
892
|
if (this.deviceLogging === 'debug') {
|
|
893
|
-
this.log.info(`[DEBUG] ${this.device.deviceType}: ${this.accessory.displayName}`, String(...log));
|
|
893
|
+
this.log.info(`[DEBUG] ${this.device.deviceType}: ${this.accessory.displayName} `, String(...log));
|
|
894
894
|
} else {
|
|
895
|
-
this.log.debug(`${this.device.deviceType}: ${this.accessory.displayName}`, String(...log));
|
|
895
|
+
this.log.debug(`${this.device.deviceType}: ${this.accessory.displayName} `, String(...log));
|
|
896
896
|
}
|
|
897
897
|
}
|
|
898
898
|
}
|
package/src/device/fan.ts
CHANGED
|
@@ -339,7 +339,7 @@ export class Fan extends deviceBase {
|
|
|
339
339
|
async registerWebhook() {
|
|
340
340
|
if (this.device.webhook) {
|
|
341
341
|
await this.debugLog('is listening webhook.');
|
|
342
|
-
this.platform.webhookEventHandler[this.device.deviceId] = async (context
|
|
342
|
+
this.platform.webhookEventHandler[this.device.deviceId] = async (context) => {
|
|
343
343
|
try {
|
|
344
344
|
await this.debugLog(`received Webhook: ${JSON.stringify(context)}`);
|
|
345
345
|
await this.parseStatusWebhook(context);
|
|
@@ -106,11 +106,10 @@ export class WaterDetector extends deviceBase {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
// Retrieve initial values and updateHomekit
|
|
109
|
-
this.debugLog('retrieve initial values and Update Homekit');
|
|
110
109
|
this.refreshStatus();
|
|
111
110
|
|
|
112
111
|
// Retrieve initial values and updateHomekit
|
|
113
|
-
|
|
112
|
+
this.updateHomeKitCharacteristics();
|
|
114
113
|
|
|
115
114
|
//regisiter webhook event handler
|
|
116
115
|
this.registerWebhook();
|
|
@@ -119,7 +118,6 @@ export class WaterDetector extends deviceBase {
|
|
|
119
118
|
interval(this.deviceRefreshRate * 1000)
|
|
120
119
|
.pipe(skipWhile(() => this.WaterDetectorUpdateInProgress))
|
|
121
120
|
.subscribe(async () => {
|
|
122
|
-
await this.debugLog(`update interval: ${this.deviceRefreshRate * 1000} seconds`);
|
|
123
121
|
await this.refreshStatus();
|
|
124
122
|
});
|
|
125
123
|
}
|
|
@@ -147,7 +145,7 @@ export class WaterDetector extends deviceBase {
|
|
|
147
145
|
await this.debugLog('openAPIparseStatus');
|
|
148
146
|
if (!this.device.waterdetector?.hide_leak && this.LeakSensor?.Service) {
|
|
149
147
|
// StatusActive
|
|
150
|
-
this.LeakSensor.StatusActive = deviceStatus.
|
|
148
|
+
this.LeakSensor.StatusActive = deviceStatus.status ? true : false;
|
|
151
149
|
await this.debugLog(`StatusActive: ${this.LeakSensor.StatusActive}`);
|
|
152
150
|
// LeakDetected
|
|
153
151
|
this.LeakSensor.LeakDetected = deviceStatus.status;
|
|
@@ -162,7 +160,7 @@ export class WaterDetector extends deviceBase {
|
|
|
162
160
|
await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
|
|
163
161
|
// FirmwareVersion
|
|
164
162
|
const version = deviceStatus.version.toString();
|
|
165
|
-
await this.debugLog(`
|
|
163
|
+
await this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`);
|
|
166
164
|
if (deviceStatus.version) {
|
|
167
165
|
const deviceVersion = version.replace(/^V|-.*$/g, '') ?? '0.0.0';
|
|
168
166
|
this.accessory
|
|
@@ -28,7 +28,6 @@ export class AirConditioner extends irdeviceBase {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
meter?: PlatformAccessory;
|
|
31
|
-
|
|
32
31
|
private HumiditySensor?: {
|
|
33
32
|
Name: CharacteristicValue;
|
|
34
33
|
Service: Service;
|
|
@@ -182,7 +181,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
182
181
|
* AirConditioner: "command" "highSpeed" "default" = fan speed to high
|
|
183
182
|
*/
|
|
184
183
|
async pushAirConditionerOnChanges(): Promise<void> {
|
|
185
|
-
|
|
184
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges Active: ${this.HeaterCooler.Active},`
|
|
186
185
|
+ ` disablePushOn: ${this.disablePushOn}`);
|
|
187
186
|
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
188
187
|
const commandType: string = await this.commandType();
|
|
@@ -197,7 +196,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
197
196
|
}
|
|
198
197
|
|
|
199
198
|
async pushAirConditionerOffChanges(): Promise<void> {
|
|
200
|
-
|
|
199
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges Active: ${this.HeaterCooler.Active},`
|
|
201
200
|
+ ` disablePushOff: ${this.disablePushOff}`);
|
|
202
201
|
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.INACTIVE && !this.disablePushOff) {
|
|
203
202
|
const commandType: string = await this.commandType();
|
|
@@ -212,7 +211,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
212
211
|
}
|
|
213
212
|
|
|
214
213
|
async pushAirConditionerStatusChanges(): Promise<void> {
|
|
215
|
-
|
|
214
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerStatusChanges Active: ${this.HeaterCooler.Active},`
|
|
216
215
|
+ ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`);
|
|
217
216
|
if (!this.Busy) {
|
|
218
217
|
this.Busy = true;
|
|
@@ -225,7 +224,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
225
224
|
}
|
|
226
225
|
|
|
227
226
|
async pushAirConditionerDetailsChanges(): Promise<void> {
|
|
228
|
-
|
|
227
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerDetailsChanges Active: ${this.HeaterCooler.Active},`
|
|
229
228
|
+ ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`);
|
|
230
229
|
//await this.deviceContext();
|
|
231
230
|
if (this.CurrentMode === undefined) {
|
|
@@ -242,7 +241,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
242
241
|
if (this.CurrentMode === 1) {
|
|
243
242
|
// Remove or make configurable?
|
|
244
243
|
this.HeaterCooler.ThresholdTemperature = 25;
|
|
245
|
-
|
|
244
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},`
|
|
246
245
|
+ ` ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
|
|
247
246
|
}
|
|
248
247
|
const parameter = `${this.HeaterCooler.ThresholdTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
|
|
@@ -345,9 +344,9 @@ export class AirConditioner extends irdeviceBase {
|
|
|
345
344
|
}
|
|
346
345
|
|
|
347
346
|
async pushChanges(bodyChange: any): Promise<void> {
|
|
348
|
-
|
|
347
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
|
|
349
348
|
if (this.device.connectionType === 'OpenAPI' && !this.disablePushDetail) {
|
|
350
|
-
|
|
349
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
351
350
|
try {
|
|
352
351
|
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
353
352
|
const deviceStatus: any = await body.json();
|
|
@@ -364,33 +363,35 @@ export class AirConditioner extends irdeviceBase {
|
|
|
364
363
|
await this.pushChangeError(e);
|
|
365
364
|
}
|
|
366
365
|
} else {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
366
|
+
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
367
|
+
+ ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
368
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
369
|
+
+ ` Connection Type: ${this.device.connectionType}, disablePushDetails: ${this.disablePushDetail}`);
|
|
370
|
+
this.updateHomeKitCharacteristics();
|
|
370
371
|
}
|
|
371
372
|
}
|
|
372
373
|
|
|
373
374
|
async CurrentTemperatureGet(): Promise<CharacteristicValue> {
|
|
374
375
|
if (this.meter?.context?.CurrentTemperature) {
|
|
375
376
|
this.accessory.context.CurrentTemperature = this.meter.context.CurrentTemperature;
|
|
376
|
-
|
|
377
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
377
378
|
+ `Using CurrentTemperature from ${this.meter.context.deviceType} (${this.meter.context.deviceID})`);
|
|
378
379
|
}
|
|
379
380
|
|
|
380
381
|
this.HeaterCooler.CurrentTemperature = this.accessory.context.CurrentTemperature || 24;
|
|
381
|
-
|
|
382
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
|
|
382
383
|
return this.HeaterCooler.CurrentTemperature;
|
|
383
384
|
}
|
|
384
385
|
|
|
385
386
|
async CurrentRelativeHumidityGet(): Promise<CharacteristicValue> {
|
|
386
387
|
if (this.meter?.context?.CurrentRelativeHumidity) {
|
|
387
388
|
this.accessory.context.CurrentRelativeHumidity = this.meter.context.CurrentRelativeHumidity;
|
|
388
|
-
|
|
389
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
389
390
|
+ `Using CurrentRelativeHumidity from ${this.meter.context.deviceType} (${this.meter.context.deviceID})`);
|
|
390
391
|
}
|
|
391
392
|
|
|
392
393
|
this.HumiditySensor!.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity || 0;
|
|
393
|
-
|
|
394
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get`
|
|
394
395
|
+ ` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`);
|
|
395
396
|
return this.HumiditySensor!.CurrentRelativeHumidity as CharacteristicValue;
|
|
396
397
|
}
|
|
@@ -401,7 +402,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
401
402
|
} else {
|
|
402
403
|
this.HeaterCooler.RotationSpeed = this.CurrentFanSpeed - 1;
|
|
403
404
|
}
|
|
404
|
-
|
|
405
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
|
|
405
406
|
return this.HeaterCooler.RotationSpeed;
|
|
406
407
|
}
|
|
407
408
|
|
|
@@ -412,23 +413,24 @@ export class AirConditioner extends irdeviceBase {
|
|
|
412
413
|
this.CurrentFanSpeed = Number(value) + 1;
|
|
413
414
|
}
|
|
414
415
|
this.HeaterCooler.RotationSpeed = value;
|
|
415
|
-
|
|
416
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
417
|
+
+ `Set RotationSpeed: ${this.HeaterCooler.RotationSpeed}, CurrentFanSpeed: ${this.CurrentFanSpeed}`);
|
|
416
418
|
this.pushAirConditionerStatusChanges();
|
|
417
419
|
}
|
|
418
420
|
|
|
419
421
|
async ActiveSet(value: CharacteristicValue): Promise<void> {
|
|
420
|
-
|
|
422
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Active: ${value}`);
|
|
421
423
|
|
|
422
424
|
this.HeaterCooler.Active = value;
|
|
423
425
|
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
424
|
-
|
|
426
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges, Active: ${this.HeaterCooler.Active}`);
|
|
425
427
|
if (this.disablePushOn) {
|
|
426
428
|
this.pushAirConditionerStatusChanges();
|
|
427
429
|
} else {
|
|
428
430
|
this.pushAirConditionerOnChanges();
|
|
429
431
|
}
|
|
430
432
|
} else {
|
|
431
|
-
|
|
433
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.HeaterCooler.Active}`);
|
|
432
434
|
this.pushAirConditionerOffChanges();
|
|
433
435
|
}
|
|
434
436
|
}
|
|
@@ -436,7 +438,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
436
438
|
async TargetHeaterCoolerStateGet(): Promise<CharacteristicValue> {
|
|
437
439
|
const targetState = this.HeaterCooler.TargetHeaterCoolerState || this.accessory.context.TargetHeaterCoolerState;
|
|
438
440
|
this.HeaterCooler.TargetHeaterCoolerState = this.ValidValues.includes(targetState) ? targetState : this.ValidValues[0];
|
|
439
|
-
|
|
441
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get (${this.getTargetHeaterCoolerStateName()}) TargetHeaterCoolerState:`
|
|
440
442
|
+ ` ${this.HeaterCooler.TargetHeaterCoolerState}, ValidValues: ${this.ValidValues}, hide_automode: ${this.hide_automode}`);
|
|
441
443
|
return this.HeaterCooler.TargetHeaterCoolerState;
|
|
442
444
|
}
|
|
@@ -449,7 +451,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
449
451
|
} else if (value === this.hap.Characteristic.TargetHeaterCoolerState.COOL) {
|
|
450
452
|
this.TargetHeaterCoolerStateCOOL();
|
|
451
453
|
} else {
|
|
452
|
-
this.errorLog(
|
|
454
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Set TargetHeaterCoolerState: `
|
|
453
455
|
+ `${this.HeaterCooler.TargetHeaterCoolerState}, hide_automode: ${this.hide_automode} `);
|
|
454
456
|
}
|
|
455
457
|
this.pushAirConditionerStatusChanges();
|
|
@@ -458,30 +460,31 @@ export class AirConditioner extends irdeviceBase {
|
|
|
458
460
|
async TargetHeaterCoolerStateAUTO(): Promise<void> {
|
|
459
461
|
this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
460
462
|
this.CurrentMode = 1;
|
|
461
|
-
|
|
463
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (AUTO)`
|
|
462
464
|
+ ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
463
|
-
|
|
465
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
464
466
|
}
|
|
465
467
|
|
|
466
468
|
async TargetHeaterCoolerStateCOOL(): Promise<void> {
|
|
467
469
|
this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.COOL;
|
|
468
470
|
this.CurrentMode = 2;
|
|
469
|
-
|
|
471
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (COOL)`
|
|
470
472
|
+ ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
471
|
-
|
|
473
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
472
474
|
}
|
|
473
475
|
|
|
474
476
|
async TargetHeaterCoolerStateHEAT(): Promise<void> {
|
|
475
477
|
this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
476
478
|
this.CurrentMode = 5;
|
|
477
|
-
|
|
479
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (HEAT)`
|
|
478
480
|
+ ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
479
|
-
|
|
481
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
480
482
|
}
|
|
481
483
|
|
|
482
484
|
async CurrentHeaterCoolerStateGet(): Promise<CharacteristicValue> {
|
|
483
485
|
await this.UpdateCurrentHeaterCoolerState();
|
|
484
|
-
|
|
486
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
487
|
+
+ ` Get (${this.getTargetHeaterCoolerStateName()}) CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`);
|
|
485
488
|
|
|
486
489
|
return this.HeaterCooler.CurrentHeaterCoolerState;
|
|
487
490
|
}
|
|
@@ -535,48 +538,89 @@ export class AirConditioner extends irdeviceBase {
|
|
|
535
538
|
this.HumiditySensor!.CurrentRelativeHumidity = this.HumiditySensor!.CurrentRelativeHumidity || this.accessory.context.CurrentRelativeHumidity;
|
|
536
539
|
}
|
|
537
540
|
}
|
|
538
|
-
|
|
541
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
|
|
539
542
|
return this.HeaterCooler.ThresholdTemperature;
|
|
540
543
|
}
|
|
541
544
|
|
|
542
545
|
async ThresholdTemperatureSet(value: CharacteristicValue): Promise<void> {
|
|
543
546
|
this.HeaterCooler.ThresholdTemperature = value;
|
|
544
|
-
|
|
547
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature},`
|
|
545
548
|
+ ` ThresholdTemperatureCached: ${this.accessory.context.ThresholdTemperature}`);
|
|
546
549
|
this.pushAirConditionerStatusChanges();
|
|
547
550
|
}
|
|
548
551
|
|
|
549
552
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
550
|
-
await this.debugLog('updateHomeKitCharacteristics');
|
|
551
553
|
// Active
|
|
552
|
-
|
|
553
|
-
this.
|
|
554
|
+
if (this.HeaterCooler.Active === undefined) {
|
|
555
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.HeaterCooler.Active}`);
|
|
556
|
+
} else {
|
|
557
|
+
this.accessory.context.Active = this.HeaterCooler.Active;
|
|
558
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.Active, this.HeaterCooler.Active);
|
|
559
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.HeaterCooler.Active}`);
|
|
560
|
+
}
|
|
554
561
|
// RotationSpeed
|
|
555
|
-
|
|
556
|
-
this.
|
|
562
|
+
if (this.HeaterCooler.RotationSpeed === undefined) {
|
|
563
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
|
|
564
|
+
} else {
|
|
565
|
+
this.accessory.context.RotationSpeed = this.HeaterCooler.RotationSpeed;
|
|
566
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.RotationSpeed, this.HeaterCooler.RotationSpeed);
|
|
567
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
568
|
+
+ ` RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
|
|
569
|
+
}
|
|
557
570
|
// CurrentTemperature
|
|
558
|
-
|
|
559
|
-
this.
|
|
571
|
+
if (this.HeaterCooler.CurrentTemperature === undefined) {
|
|
572
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
|
|
573
|
+
} else {
|
|
574
|
+
this.accessory.context.CurrentTemperature = this.HeaterCooler.CurrentTemperature;
|
|
575
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, this.HeaterCooler.CurrentTemperature);
|
|
576
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
577
|
+
+ ` CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
|
|
578
|
+
}
|
|
579
|
+
// CurrentRelativeHumidity
|
|
580
|
+
if (this.meter) {
|
|
581
|
+
if (this.HumiditySensor!.CurrentRelativeHumidity === undefined) {
|
|
582
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
583
|
+
+ ` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`);
|
|
584
|
+
} else {
|
|
585
|
+
this.accessory.context.CurrentRelativeHumidity = this.HumiditySensor!.CurrentRelativeHumidity;
|
|
586
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity,
|
|
587
|
+
this.HumiditySensor!.CurrentRelativeHumidity);
|
|
588
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
589
|
+
+ ` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
560
592
|
// TargetHeaterCoolerState
|
|
561
|
-
|
|
562
|
-
this.
|
|
593
|
+
if (this.HeaterCooler.TargetHeaterCoolerState === undefined) {
|
|
594
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
595
|
+
} else {
|
|
596
|
+
this.accessory.context.TargetHeaterCoolerState = this.HeaterCooler.TargetHeaterCoolerState;
|
|
597
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.TargetHeaterCoolerState, this.HeaterCooler.TargetHeaterCoolerState);
|
|
598
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
599
|
+
+ ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
600
|
+
}
|
|
563
601
|
// CurrentHeaterCoolerState
|
|
564
|
-
|
|
565
|
-
this.
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
this.HeaterCooler.
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
602
|
+
if (this.HeaterCooler.CurrentHeaterCoolerState === undefined) {
|
|
603
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
604
|
+
+ ` CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`);
|
|
605
|
+
} else {
|
|
606
|
+
this.accessory.context.CurrentHeaterCoolerState = this.HeaterCooler.CurrentHeaterCoolerState;
|
|
607
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState, this.HeaterCooler.CurrentHeaterCoolerState);
|
|
608
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
609
|
+
+ ` updateCharacteristic CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`);
|
|
610
|
+
}
|
|
611
|
+
// ThresholdTemperature
|
|
612
|
+
if (this.HeaterCooler.ThresholdTemperature === undefined) {
|
|
613
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
|
|
614
|
+
} else {
|
|
615
|
+
this.accessory.context.ThresholdTemperature = this.HeaterCooler.ThresholdTemperature;
|
|
616
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.HeatingThresholdTemperature, this.HeaterCooler.ThresholdTemperature);
|
|
617
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CoolingThresholdTemperature, this.HeaterCooler.ThresholdTemperature);
|
|
618
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
619
|
+
+ ` ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
|
|
576
620
|
}
|
|
577
621
|
}
|
|
578
622
|
|
|
579
|
-
async apiError(e: any): Promise<void> {
|
|
623
|
+
async apiError({ e }: { e: any }): Promise<void> {
|
|
580
624
|
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.Active, e);
|
|
581
625
|
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.RotationSpeed, e);
|
|
582
626
|
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, e);
|