@switchbot/homebridge-switchbot 3.5.0-beta.27 → 3.5.0-beta.29
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 +1 -0
- package/config.schema.json +67 -1
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +10 -5
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +10 -5
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +36 -10
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +24 -5
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +8 -3
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +8 -3
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +2 -1
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +23 -6
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts +51 -0
- package/dist/device/fan.d.ts.map +1 -0
- package/dist/device/fan.js +499 -0
- package/dist/device/fan.js.map +1 -0
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +33 -25
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +8 -3
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +26 -18
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +42 -5
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +8 -3
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +26 -18
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +8 -3
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +8 -3
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +8 -3
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +10 -5
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +15 -8
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +3 -2
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +3 -2
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +3 -2
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +4 -3
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +2 -1
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js +9 -2
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +3 -2
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +3 -2
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +3 -2
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +3 -2
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +3 -2
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +2 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +68 -5
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +22 -4
- package/dist/settings.d.ts.map +1 -1
- package/dist/utils.d.ts +10 -5
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +23 -9
- package/dist/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/device/blindtilt.ts +10 -5
- package/src/device/bot.ts +10 -5
- package/src/device/ceilinglight.ts +36 -10
- package/src/device/colorbulb.ts +26 -7
- package/src/device/contact.ts +10 -5
- package/src/device/curtain.ts +22 -17
- package/src/device/device.ts +24 -6
- package/src/device/fan.ts +548 -0
- package/src/device/hub.ts +31 -23
- package/src/device/humidifier.ts +9 -4
- package/src/device/iosensor.ts +28 -20
- package/src/device/lightstrip.ts +41 -7
- package/src/device/lock.ts +13 -8
- package/src/device/meter.ts +30 -22
- package/src/device/meterplus.ts +12 -7
- package/src/device/motion.ts +9 -4
- package/src/device/plug.ts +9 -4
- package/src/device/robotvacuumcleaner.ts +15 -10
- package/src/device/waterdetector.ts +15 -8
- package/src/irdevice/airconditioner.ts +5 -4
- package/src/irdevice/airpurifier.ts +5 -4
- package/src/irdevice/camera.ts +4 -3
- package/src/irdevice/fan.ts +4 -3
- package/src/irdevice/irdevice.ts +11 -3
- package/src/irdevice/light.ts +3 -2
- package/src/irdevice/other.ts +47 -46
- package/src/irdevice/tv.ts +3 -2
- package/src/irdevice/vacuumcleaner.ts +3 -2
- package/src/irdevice/waterheater.ts +3 -2
- package/src/platform.ts +71 -5
- package/src/settings.ts +34 -9
- package/src/utils.ts +24 -9
package/src/device/iosensor.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { SwitchBotPlatform } from '../platform.js';
|
|
|
7
7
|
import { Subject, interval, skipWhile } from 'rxjs';
|
|
8
8
|
import { CharacteristicValue, PlatformAccessory, Service, Units } from 'homebridge';
|
|
9
9
|
import { device, devicesConfig, serviceData, deviceStatus, Devices } from '../settings.js';
|
|
10
|
+
import { convertUnits } from '../utils.js';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Platform Accessory
|
|
@@ -142,27 +143,29 @@ export class IOSensor extends deviceBase {
|
|
|
142
143
|
});
|
|
143
144
|
|
|
144
145
|
//regisiter webhook event handler
|
|
145
|
-
if (
|
|
146
|
-
this.
|
|
146
|
+
if (device.webhook) {
|
|
147
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} is listening webhook.`);
|
|
147
148
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context) => {
|
|
148
149
|
try {
|
|
149
150
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} received Webhook: ${JSON.stringify(context)}`);
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
this.
|
|
155
|
-
|
|
156
|
-
`Webhook:(${temperature}, ${humidity}), ` +
|
|
157
|
-
`current:(${CurrentTemperature}, ${CurrentRelativeHumidity})`);
|
|
158
|
-
if (this.device.iosensor?.hide_humidity) {
|
|
159
|
-
this.HumiditySensor!.CurrentRelativeHumidity = humidity;
|
|
160
|
-
}
|
|
161
|
-
if (this.device.iosensor?.hide_temperature) {
|
|
162
|
-
this.TemperatureSensor!.CurrentTemperature = temperature;
|
|
163
|
-
}
|
|
164
|
-
this.updateHomeKitCharacteristics();
|
|
151
|
+
const { temperature, humidity } = context;
|
|
152
|
+
const { CurrentTemperature } = this.TemperatureSensor || { CurrentTemperature: undefined };
|
|
153
|
+
const { CurrentRelativeHumidity } = this.HumiditySensor || { CurrentRelativeHumidity: undefined };
|
|
154
|
+
if (context.scale !== 'CELCIUS' && device.iosensor?.convertUnitTo === undefined) {
|
|
155
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} received a non-CELCIUS Webhook scale: `
|
|
156
|
+
+ `${context.scale}, Use the *convertUnitsTo* config under Indoor/Outdoor Sensor settings, if displaying incorrectly in HomeKit.`);
|
|
165
157
|
}
|
|
158
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ` +
|
|
159
|
+
'(scale, temperature, humidity) = '
|
|
160
|
+
+ `Webhook:(${context.scale}, ${convertUnits(temperature, context.scale, device.iosensor?.convertUnitTo)}, ${humidity}), `
|
|
161
|
+
+ `current:(${CurrentTemperature}, ${CurrentRelativeHumidity})`);
|
|
162
|
+
if (this.device.iosensor?.hide_humidity) {
|
|
163
|
+
this.HumiditySensor!.CurrentRelativeHumidity = humidity;
|
|
164
|
+
}
|
|
165
|
+
if (this.device.iosensor?.hide_temperature) {
|
|
166
|
+
this.TemperatureSensor!.CurrentTemperature = convertUnits(temperature, context.scale, device.iosensor?.convertUnitTo);
|
|
167
|
+
}
|
|
168
|
+
this.updateHomeKitCharacteristics();
|
|
166
169
|
} catch (e: any) {
|
|
167
170
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
168
171
|
+ `failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e}`);
|
|
@@ -226,6 +229,11 @@ export class IOSensor extends deviceBase {
|
|
|
226
229
|
}
|
|
227
230
|
// FirmwareRevision
|
|
228
231
|
this.accessory.context.FirmwareRevision = deviceStatus.body.version;
|
|
232
|
+
this.accessory
|
|
233
|
+
.getService(this.hap.Service.AccessoryInformation)!
|
|
234
|
+
.setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
|
|
235
|
+
.getCharacteristic(this.hap.Characteristic.FirmwareRevision)
|
|
236
|
+
.updateValue(this.accessory.context.FirmwareRevision);
|
|
229
237
|
}
|
|
230
238
|
|
|
231
239
|
/**
|
|
@@ -294,7 +302,7 @@ export class IOSensor extends deviceBase {
|
|
|
294
302
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
295
303
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
296
304
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
297
|
-
this.
|
|
305
|
+
this.debugSuccessLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
298
306
|
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
299
307
|
this.openAPIparseStatus(deviceStatus);
|
|
300
308
|
this.updateHomeKitCharacteristics();
|
|
@@ -403,10 +411,10 @@ export class IOSensor extends deviceBase {
|
|
|
403
411
|
async offlineOff(): Promise<void> {
|
|
404
412
|
if (this.device.offline) {
|
|
405
413
|
if (!this.device.iosensor?.hide_humidity) {
|
|
406
|
-
|
|
414
|
+
this.HumiditySensor!.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity, 50);
|
|
407
415
|
}
|
|
408
416
|
if (!this.device.iosensor?.hide_temperature) {
|
|
409
|
-
|
|
417
|
+
this.TemperatureSensor!.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, 30);
|
|
410
418
|
}
|
|
411
419
|
this.Battery.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, 100);
|
|
412
420
|
}
|
package/src/device/lightstrip.ts
CHANGED
|
@@ -149,8 +149,8 @@ export class StripLight extends deviceBase {
|
|
|
149
149
|
});
|
|
150
150
|
|
|
151
151
|
//regisiter webhook event handler
|
|
152
|
-
if (
|
|
153
|
-
this.
|
|
152
|
+
if (device.webhook) {
|
|
153
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} is listening webhook.`);
|
|
154
154
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context) => {
|
|
155
155
|
try {
|
|
156
156
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} received Webhook: ${JSON.stringify(context)}`);
|
|
@@ -160,8 +160,22 @@ export class StripLight extends deviceBase {
|
|
|
160
160
|
'(powerState, brightness, color, colorTemperature) = ' +
|
|
161
161
|
`Webhook:(${powerState}, ${brightness}, ${color}, ${colorTemperature}), ` +
|
|
162
162
|
`current:(${On}, ${Brightness}, ${Hue}, ${Saturation}, ${ColorTemperature})`);
|
|
163
|
+
|
|
164
|
+
// On
|
|
163
165
|
this.LightBulb.On = powerState === 'ON' ? true : false;
|
|
166
|
+
if (this.accessory.context.Brightness !== this.LightBulb.On) {
|
|
167
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.LightBulb.On}`);
|
|
168
|
+
} else {
|
|
169
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.LightBulb.On}`);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Brightness
|
|
164
173
|
this.LightBulb.Brightness = brightness;
|
|
174
|
+
if (this.accessory.context.Brightness !== this.LightBulb.Brightness) {
|
|
175
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Brightness: ${this.LightBulb.Brightness}`);
|
|
176
|
+
} else {
|
|
177
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Brightness: ${this.LightBulb.Brightness}`);
|
|
178
|
+
}
|
|
165
179
|
|
|
166
180
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} color: ${JSON.stringify(color)}`);
|
|
167
181
|
const [red, green, blue] = color!.split(':');
|
|
@@ -176,12 +190,27 @@ export class StripLight extends deviceBase {
|
|
|
176
190
|
|
|
177
191
|
// Hue
|
|
178
192
|
this.LightBulb.Hue = hue;
|
|
179
|
-
|
|
193
|
+
if (this.accessory.context.Hue !== this.LightBulb.Hue) {
|
|
194
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${this.LightBulb.Hue}`);
|
|
195
|
+
} else {
|
|
196
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${this.LightBulb.Hue}`);
|
|
197
|
+
}
|
|
180
198
|
|
|
181
199
|
// Saturation
|
|
182
200
|
this.LightBulb.Saturation = saturation;
|
|
183
|
-
|
|
184
|
-
|
|
201
|
+
if (this.accessory.context.Saturation !== this.LightBulb.Saturation) {
|
|
202
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${this.LightBulb.Saturation}`);
|
|
203
|
+
} else {
|
|
204
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${this.LightBulb.Saturation}`);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// ColorTemperature
|
|
208
|
+
this.LightBulb.ColorTemperature = colorTemperature;
|
|
209
|
+
if (this.accessory.context.ColorTemperature !== this.LightBulb.ColorTemperature) {
|
|
210
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} ColorTemperature: ${this.LightBulb.ColorTemperature}`);
|
|
211
|
+
} else {
|
|
212
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ColorTemperature: ${this.LightBulb.ColorTemperature}`);
|
|
213
|
+
}
|
|
185
214
|
this.updateHomeKitCharacteristics();
|
|
186
215
|
} catch (e: any) {
|
|
187
216
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
@@ -298,6 +327,11 @@ export class StripLight extends deviceBase {
|
|
|
298
327
|
|
|
299
328
|
// FirmwareRevision
|
|
300
329
|
this.accessory.context.FirmwareRevision = deviceStatus.body.version;
|
|
330
|
+
this.accessory
|
|
331
|
+
.getService(this.hap.Service.AccessoryInformation)!
|
|
332
|
+
.setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
|
|
333
|
+
.getCharacteristic(this.hap.Characteristic.FirmwareRevision)
|
|
334
|
+
.updateValue(this.accessory.context.FirmwareRevision);
|
|
301
335
|
}
|
|
302
336
|
|
|
303
337
|
/**
|
|
@@ -366,7 +400,7 @@ export class StripLight extends deviceBase {
|
|
|
366
400
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
367
401
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
368
402
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
369
|
-
this.
|
|
403
|
+
this.debugSuccessLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
370
404
|
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
371
405
|
this.openAPIparseStatus(deviceStatus);
|
|
372
406
|
this.updateHomeKitCharacteristics();
|
|
@@ -470,7 +504,7 @@ export class StripLight extends deviceBase {
|
|
|
470
504
|
this.accessory.context.kelvin = kelvin;
|
|
471
505
|
} else {
|
|
472
506
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No pushColorTemperatureChanges.`
|
|
473
|
-
|
|
507
|
+
+ `ColorTemperature: ${this.LightBulb.ColorTemperature}, ColorTemperatureCached: ${this.accessory.context.ColorTemperature}`);
|
|
474
508
|
}
|
|
475
509
|
} else {
|
|
476
510
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No BLEpushChanges,`
|
package/src/device/lock.ts
CHANGED
|
@@ -141,8 +141,8 @@ export class Lock extends deviceBase {
|
|
|
141
141
|
});
|
|
142
142
|
|
|
143
143
|
//regisiter webhook event handler
|
|
144
|
-
if (
|
|
145
|
-
this.
|
|
144
|
+
if (device.webhook) {
|
|
145
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} is listening webhook.`);
|
|
146
146
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context) => {
|
|
147
147
|
try {
|
|
148
148
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} received Webhook: ${JSON.stringify(context)}`);
|
|
@@ -257,6 +257,11 @@ export class Lock extends deviceBase {
|
|
|
257
257
|
|
|
258
258
|
// FirmwareRevision
|
|
259
259
|
this.accessory.context.FirmwareRevision = deviceStatus.body.version;
|
|
260
|
+
this.accessory
|
|
261
|
+
.getService(this.hap.Service.AccessoryInformation)!
|
|
262
|
+
.setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
|
|
263
|
+
.getCharacteristic(this.hap.Characteristic.FirmwareRevision)
|
|
264
|
+
.updateValue(this.accessory.context.FirmwareRevision);
|
|
260
265
|
}
|
|
261
266
|
|
|
262
267
|
/**
|
|
@@ -325,7 +330,7 @@ export class Lock extends deviceBase {
|
|
|
325
330
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
326
331
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
327
332
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
328
|
-
this.
|
|
333
|
+
this.debugSuccessLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
329
334
|
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
330
335
|
this.openAPIparseStatus(deviceStatus);
|
|
331
336
|
this.updateHomeKitCharacteristics();
|
|
@@ -526,7 +531,7 @@ export class Lock extends deviceBase {
|
|
|
526
531
|
this.accessory.context.ContactSensorState = this.ContactSensor!.ContactSensorState;
|
|
527
532
|
this.ContactSensor!.Service.updateCharacteristic(this.hap.Characteristic.ContactSensorState, this.ContactSensor!.ContactSensorState);
|
|
528
533
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
529
|
-
|
|
534
|
+
+ ` ContactSensorState: ${this.ContactSensor!.ContactSensorState}`);
|
|
530
535
|
}
|
|
531
536
|
}
|
|
532
537
|
if (this.LockMechanism.LockTargetState === undefined) {
|
|
@@ -535,7 +540,7 @@ export class Lock extends deviceBase {
|
|
|
535
540
|
this.accessory.context.LockTargetState = this.LockMechanism.LockTargetState;
|
|
536
541
|
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.LockMechanism.LockTargetState);
|
|
537
542
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
538
|
-
|
|
543
|
+
+ ` LockTargetState: ${this.LockMechanism.LockTargetState}`);
|
|
539
544
|
}
|
|
540
545
|
if (this.LockMechanism.LockCurrentState === undefined) {
|
|
541
546
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LockCurrentState: ${this.LockMechanism.LockCurrentState}`);
|
|
@@ -543,7 +548,7 @@ export class Lock extends deviceBase {
|
|
|
543
548
|
this.accessory.context.LockCurrentState = this.LockMechanism.LockCurrentState;
|
|
544
549
|
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.LockMechanism.LockCurrentState);
|
|
545
550
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
546
|
-
|
|
551
|
+
+ ` LockCurrentState: ${this.LockMechanism.LockCurrentState}`);
|
|
547
552
|
}
|
|
548
553
|
if (this.Battery.BatteryLevel === undefined) {
|
|
549
554
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.Battery.BatteryLevel}`);
|
|
@@ -551,7 +556,7 @@ export class Lock extends deviceBase {
|
|
|
551
556
|
this.accessory.context.BatteryLevel = this.Battery.BatteryLevel;
|
|
552
557
|
this.Battery.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, this.Battery.BatteryLevel);
|
|
553
558
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
554
|
-
|
|
559
|
+
+ ` BatteryLevel: ${this.Battery.BatteryLevel}`);
|
|
555
560
|
}
|
|
556
561
|
if (this.Battery.StatusLowBattery === undefined) {
|
|
557
562
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatusLowBattery: ${this.Battery.StatusLowBattery}`);
|
|
@@ -559,7 +564,7 @@ export class Lock extends deviceBase {
|
|
|
559
564
|
this.accessory.context.StatusLowBattery = this.Battery.StatusLowBattery;
|
|
560
565
|
this.Battery.Service.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, this.Battery.StatusLowBattery);
|
|
561
566
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
562
|
-
|
|
567
|
+
+ ` StatusLowBattery: ${this.Battery.StatusLowBattery}`);
|
|
563
568
|
}
|
|
564
569
|
}
|
|
565
570
|
|
package/src/device/meter.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { deviceBase } from './device.js';
|
|
6
6
|
import { SwitchBotPlatform } from '../platform.js';
|
|
7
|
+
import { convertUnits } from '../utils.js';
|
|
7
8
|
import { Subject, interval, skipWhile } from 'rxjs';
|
|
8
9
|
import { CharacteristicValue, PlatformAccessory, Service, Units } from 'homebridge';
|
|
9
10
|
import { device, devicesConfig, serviceData, deviceStatus, Devices } from '../settings.js';
|
|
@@ -137,27 +138,29 @@ export class Meter extends deviceBase {
|
|
|
137
138
|
});
|
|
138
139
|
|
|
139
140
|
//regisiter webhook event handler
|
|
140
|
-
if (
|
|
141
|
-
this.
|
|
141
|
+
if (device.webhook) {
|
|
142
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} is listening webhook.`);
|
|
142
143
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context) => {
|
|
143
144
|
try {
|
|
144
145
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} received Webhook: ${JSON.stringify(context)}`);
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
this.
|
|
150
|
-
|
|
151
|
-
`Webhook:(${temperature}, ${humidity}), ` +
|
|
152
|
-
`current:(${CurrentTemperature}, ${CurrentRelativeHumidity})`);
|
|
153
|
-
if (this.device.meter?.hide_humidity) {
|
|
154
|
-
this.HumiditySensor!.CurrentRelativeHumidity = humidity;
|
|
155
|
-
}
|
|
156
|
-
if (this.device.meter?.hide_temperature) {
|
|
157
|
-
this.TemperatureSensor!.CurrentTemperature = temperature;
|
|
158
|
-
}
|
|
159
|
-
this.updateHomeKitCharacteristics();
|
|
146
|
+
const { temperature, humidity } = context;
|
|
147
|
+
const { CurrentTemperature } = this.TemperatureSensor || { CurrentTemperature: undefined };
|
|
148
|
+
const { CurrentRelativeHumidity } = this.HumiditySensor || { CurrentRelativeHumidity: undefined };
|
|
149
|
+
if (context.scale !== 'CELCIUS' && device.meter?.convertUnitTo === undefined) {
|
|
150
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} received Webhook scale: `
|
|
151
|
+
+ `${context.scale}, instead of CELCIUS. Use the *convertUnitsTo* config under Meter settings, if displaying incorrectly in HomeKit.`);
|
|
160
152
|
}
|
|
153
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ` +
|
|
154
|
+
'(scale, temperature, humidity) = '
|
|
155
|
+
+ `Webhook:(${context.scale}, ${convertUnits(temperature, context.scale, device.meter?.convertUnitTo)}, ${humidity}), `
|
|
156
|
+
+ `current:(${CurrentTemperature}, ${CurrentRelativeHumidity})`);
|
|
157
|
+
if (this.device.meter?.hide_humidity) {
|
|
158
|
+
this.HumiditySensor!.CurrentRelativeHumidity = humidity;
|
|
159
|
+
}
|
|
160
|
+
if (this.device.meter?.hide_temperature) {
|
|
161
|
+
this.TemperatureSensor!.CurrentTemperature = convertUnits(temperature, context.scale, device.meter?.convertUnitTo);
|
|
162
|
+
}
|
|
163
|
+
this.updateHomeKitCharacteristics();
|
|
161
164
|
} catch (e: any) {
|
|
162
165
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
163
166
|
+ `failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e}`);
|
|
@@ -222,6 +225,11 @@ export class Meter extends deviceBase {
|
|
|
222
225
|
|
|
223
226
|
// FirmwareRevision
|
|
224
227
|
this.accessory.context.FirmwareRevision = deviceStatus.body.version;
|
|
228
|
+
this.accessory
|
|
229
|
+
.getService(this.hap.Service.AccessoryInformation)!
|
|
230
|
+
.setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
|
|
231
|
+
.getCharacteristic(this.hap.Characteristic.FirmwareRevision)
|
|
232
|
+
.updateValue(this.accessory.context.FirmwareRevision);
|
|
225
233
|
}
|
|
226
234
|
|
|
227
235
|
/**
|
|
@@ -290,7 +298,7 @@ export class Meter extends deviceBase {
|
|
|
290
298
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
291
299
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
292
300
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
293
|
-
this.
|
|
301
|
+
this.debugSuccessLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
294
302
|
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
295
303
|
this.openAPIparseStatus(deviceStatus);
|
|
296
304
|
this.updateHomeKitCharacteristics();
|
|
@@ -318,7 +326,7 @@ export class Meter extends deviceBase {
|
|
|
318
326
|
if (!this.device.meter?.hide_humidity) {
|
|
319
327
|
if (this.HumiditySensor!.CurrentRelativeHumidity === undefined) {
|
|
320
328
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
321
|
-
|
|
329
|
+
+ ` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`);
|
|
322
330
|
} else {
|
|
323
331
|
this.accessory.context.CurrentRelativeHumidity = this.HumiditySensor!.CurrentRelativeHumidity;
|
|
324
332
|
this.HumiditySensor!.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity,
|
|
@@ -369,7 +377,7 @@ export class Meter extends deviceBase {
|
|
|
369
377
|
this.accessory.context.StatusLowBattery = this.Battery.StatusLowBattery;
|
|
370
378
|
this.Battery!.Service.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, this.Battery.StatusLowBattery);
|
|
371
379
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
372
|
-
|
|
380
|
+
+ ` StatusLowBattery: ${this.Battery.StatusLowBattery}`);
|
|
373
381
|
if (this.device.mqttURL) {
|
|
374
382
|
mqttmessage.push(`"lowBattery": ${this.Battery.StatusLowBattery}`);
|
|
375
383
|
}
|
|
@@ -401,10 +409,10 @@ export class Meter extends deviceBase {
|
|
|
401
409
|
async offlineOff(): Promise<void> {
|
|
402
410
|
if (this.device.offline) {
|
|
403
411
|
if (!this.device.meter?.hide_humidity) {
|
|
404
|
-
|
|
412
|
+
this.HumiditySensor!.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity, 50);
|
|
405
413
|
}
|
|
406
414
|
if (!this.device.meter?.hide_temperature) {
|
|
407
|
-
|
|
415
|
+
this.TemperatureSensor!.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, 30);
|
|
408
416
|
}
|
|
409
417
|
this.Battery.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, 100);
|
|
410
418
|
}
|
package/src/device/meterplus.ts
CHANGED
|
@@ -142,8 +142,8 @@ export class MeterPlus extends deviceBase {
|
|
|
142
142
|
});
|
|
143
143
|
|
|
144
144
|
//regisiter webhook event handler
|
|
145
|
-
if (
|
|
146
|
-
this.
|
|
145
|
+
if (device.webhook) {
|
|
146
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} is listening webhook.`);
|
|
147
147
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context) => {
|
|
148
148
|
try {
|
|
149
149
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} received Webhook: ${JSON.stringify(context)}`);
|
|
@@ -226,6 +226,11 @@ export class MeterPlus extends deviceBase {
|
|
|
226
226
|
}
|
|
227
227
|
// FirmwareRevision
|
|
228
228
|
this.accessory.context.FirmwareRevision = deviceStatus.body.version;
|
|
229
|
+
this.accessory
|
|
230
|
+
.getService(this.hap.Service.AccessoryInformation)!
|
|
231
|
+
.setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
|
|
232
|
+
.getCharacteristic(this.hap.Characteristic.FirmwareRevision)
|
|
233
|
+
.updateValue(this.accessory.context.FirmwareRevision);
|
|
229
234
|
}
|
|
230
235
|
|
|
231
236
|
/**
|
|
@@ -294,7 +299,7 @@ export class MeterPlus extends deviceBase {
|
|
|
294
299
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
295
300
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
296
301
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
297
|
-
this.
|
|
302
|
+
this.debugSuccessLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
298
303
|
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
299
304
|
this.openAPIparseStatus(deviceStatus);
|
|
300
305
|
this.updateHomeKitCharacteristics();
|
|
@@ -322,7 +327,7 @@ export class MeterPlus extends deviceBase {
|
|
|
322
327
|
if (!this.device.meter?.hide_humidity) {
|
|
323
328
|
if (this.HumiditySensor!.CurrentRelativeHumidity === undefined) {
|
|
324
329
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
325
|
-
|
|
330
|
+
+ ` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`);
|
|
326
331
|
} else {
|
|
327
332
|
this.accessory.context.CurrentRelativeHumidity = this.HumiditySensor!.CurrentRelativeHumidity;
|
|
328
333
|
this.HumiditySensor!.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity,
|
|
@@ -374,7 +379,7 @@ export class MeterPlus extends deviceBase {
|
|
|
374
379
|
this.accessory.context.StatusLowBattery = this.Battery.StatusLowBattery;
|
|
375
380
|
this.Battery!.Service.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, this.Battery.StatusLowBattery);
|
|
376
381
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
377
|
-
|
|
382
|
+
+ ` StatusLowBattery: ${this.Battery.StatusLowBattery}`);
|
|
378
383
|
if (this.device.mqttURL) {
|
|
379
384
|
mqttmessage.push(`"lowBattery": ${this.Battery.StatusLowBattery}`);
|
|
380
385
|
}
|
|
@@ -406,10 +411,10 @@ export class MeterPlus extends deviceBase {
|
|
|
406
411
|
async offlineOff(): Promise<void> {
|
|
407
412
|
if (this.device.offline) {
|
|
408
413
|
if (!this.device.meter?.hide_humidity) {
|
|
409
|
-
|
|
414
|
+
this.HumiditySensor!.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity, 50);
|
|
410
415
|
}
|
|
411
416
|
if (!this.device.meter?.hide_temperature) {
|
|
412
|
-
|
|
417
|
+
this.TemperatureSensor!.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, 30);
|
|
413
418
|
}
|
|
414
419
|
this.Battery.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, 100);
|
|
415
420
|
}
|
package/src/device/motion.ts
CHANGED
|
@@ -49,7 +49,7 @@ export class Motion extends deviceBase {
|
|
|
49
49
|
// Initialize Motion Sensor property
|
|
50
50
|
this.MotionSensor = {
|
|
51
51
|
Service: accessory.getService(this.hap.Service.MotionSensor)!,
|
|
52
|
-
MotionDetected:accessory.context.MotionDetected || false,
|
|
52
|
+
MotionDetected: accessory.context.MotionDetected || false,
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
// Retrieve initial values and updateHomekit
|
|
@@ -100,8 +100,8 @@ export class Motion extends deviceBase {
|
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
//regisiter webhook event handler
|
|
103
|
-
if (
|
|
104
|
-
this.
|
|
103
|
+
if (device.webhook) {
|
|
104
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} is listening webhook.`);
|
|
105
105
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context) => {
|
|
106
106
|
try {
|
|
107
107
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} received Webhook: ${JSON.stringify(context)}`);
|
|
@@ -201,6 +201,11 @@ export class Motion extends deviceBase {
|
|
|
201
201
|
|
|
202
202
|
// FirmwareRevision
|
|
203
203
|
this.accessory.context.FirmwareRevision = deviceStatus.body.version;
|
|
204
|
+
this.accessory
|
|
205
|
+
.getService(this.hap.Service.AccessoryInformation)!
|
|
206
|
+
.setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
|
|
207
|
+
.getCharacteristic(this.hap.Characteristic.FirmwareRevision)
|
|
208
|
+
.updateValue(this.accessory.context.FirmwareRevision);
|
|
204
209
|
}
|
|
205
210
|
|
|
206
211
|
/**
|
|
@@ -269,7 +274,7 @@ export class Motion extends deviceBase {
|
|
|
269
274
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
270
275
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
271
276
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
272
|
-
this.
|
|
277
|
+
this.debugSuccessLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
273
278
|
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
274
279
|
this.openAPIparseStatus(deviceStatus);
|
|
275
280
|
this.updateHomeKitCharacteristics();
|
package/src/device/plug.ts
CHANGED
|
@@ -62,8 +62,8 @@ export class Plug extends deviceBase {
|
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
//regisiter webhook event handler
|
|
65
|
-
if (
|
|
66
|
-
this.
|
|
65
|
+
if (device.webhook) {
|
|
66
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} is listening webhook.`);
|
|
67
67
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context) => {
|
|
68
68
|
try {
|
|
69
69
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} received Webhook: ${JSON.stringify(context)}`);
|
|
@@ -131,6 +131,11 @@ export class Plug extends deviceBase {
|
|
|
131
131
|
|
|
132
132
|
// FirmwareRevision
|
|
133
133
|
this.accessory.context.FirmwareRevision = deviceStatus.body.version;
|
|
134
|
+
this.accessory
|
|
135
|
+
.getService(this.hap.Service.AccessoryInformation)!
|
|
136
|
+
.setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
|
|
137
|
+
.getCharacteristic(this.hap.Characteristic.FirmwareRevision)
|
|
138
|
+
.updateValue(this.accessory.context.FirmwareRevision);
|
|
134
139
|
}
|
|
135
140
|
|
|
136
141
|
/**
|
|
@@ -199,7 +204,7 @@ export class Plug extends deviceBase {
|
|
|
199
204
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
200
205
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
201
206
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
202
|
-
this.
|
|
207
|
+
this.debugSuccessLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
203
208
|
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
204
209
|
this.openAPIparseStatus(deviceStatus);
|
|
205
210
|
this.updateHomeKitCharacteristics();
|
|
@@ -340,7 +345,7 @@ export class Plug extends deviceBase {
|
|
|
340
345
|
}
|
|
341
346
|
} else {
|
|
342
347
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No openAPIpushChanges.`
|
|
343
|
-
|
|
348
|
+
+ `On: ${this.Outlet.On}, OnCached: ${this.accessory.context.On}`);
|
|
344
349
|
}
|
|
345
350
|
}
|
|
346
351
|
|
|
@@ -101,8 +101,8 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
//regisiter webhook event handler
|
|
104
|
-
if (
|
|
105
|
-
this.
|
|
104
|
+
if (device.webhook) {
|
|
105
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} is listening webhook.`);
|
|
106
106
|
this.platform.webhookEventHandler[this.device.deviceId] = async (context) => {
|
|
107
107
|
try {
|
|
108
108
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} received Webhook: ${JSON.stringify(context)}`);
|
|
@@ -200,6 +200,11 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
200
200
|
|
|
201
201
|
// FirmwareRevision
|
|
202
202
|
this.accessory.context.FirmwareRevision = deviceStatus.body.version;
|
|
203
|
+
this.accessory
|
|
204
|
+
.getService(this.hap.Service.AccessoryInformation)!
|
|
205
|
+
.setCharacteristic(this.hap.Characteristic.FirmwareRevision, this.accessory.context.FirmwareRevision)
|
|
206
|
+
.getCharacteristic(this.hap.Characteristic.FirmwareRevision)
|
|
207
|
+
.updateValue(this.accessory.context.FirmwareRevision);
|
|
203
208
|
}
|
|
204
209
|
|
|
205
210
|
/**
|
|
@@ -317,7 +322,7 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
317
322
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
318
323
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
319
324
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
320
|
-
this.
|
|
325
|
+
this.debugSuccessLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
321
326
|
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
322
327
|
this.openAPIparseStatus(deviceStatus);
|
|
323
328
|
this.updateHomeKitCharacteristics();
|
|
@@ -369,7 +374,7 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
369
374
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLEpushChanges`);
|
|
370
375
|
if (this.LightBulb.On !== this.accessory.context.On) {
|
|
371
376
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLEpushChanges`
|
|
372
|
-
|
|
377
|
+
+ ` On: ${this.LightBulb.On} OnCached: ${this.accessory.context.On}`);
|
|
373
378
|
const switchbot = await this.platform.connectBLE();
|
|
374
379
|
// Convert to BLE Address
|
|
375
380
|
this.device.bleMac = this.device
|
|
@@ -398,7 +403,7 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
398
403
|
.then(() => {
|
|
399
404
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Done.`);
|
|
400
405
|
this.successLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
401
|
-
|
|
406
|
+
+ `On: ${this.LightBulb.On} sent over BLE, sent successfully`);
|
|
402
407
|
this.LightBulb.On = false;
|
|
403
408
|
})
|
|
404
409
|
.catch(async (e: any) => {
|
|
@@ -411,7 +416,7 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
411
416
|
});
|
|
412
417
|
} else {
|
|
413
418
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No BLEpushChanges,`
|
|
414
|
-
|
|
419
|
+
+ ` On: ${this.LightBulb.On}, OnCached: ${this.accessory.context.On}`);
|
|
415
420
|
}
|
|
416
421
|
}
|
|
417
422
|
|
|
@@ -435,7 +440,7 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
435
440
|
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
436
441
|
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
437
442
|
this.successLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
438
|
-
+ `request to SwitchBot API, body: ${bodyChange} sent successfully`);
|
|
443
|
+
+ `request to SwitchBot API, body: ${JSON.stringify(bodyChange)} sent successfully`);
|
|
439
444
|
} else {
|
|
440
445
|
this.statusCode(statusCode);
|
|
441
446
|
this.statusCode(deviceStatus.statusCode);
|
|
@@ -471,10 +476,10 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
471
476
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
472
477
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
473
478
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
474
|
-
this.
|
|
479
|
+
this.debugSuccessLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
475
480
|
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
476
481
|
this.successLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
477
|
-
|
|
482
|
+
+ `request to SwitchBot API, body: ${deviceStatus} sent successfully`);
|
|
478
483
|
} else {
|
|
479
484
|
this.statusCode(statusCode);
|
|
480
485
|
this.statusCode(deviceStatus.statusCode);
|
|
@@ -595,7 +600,7 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
595
600
|
this.accessory.context.StatusLowBattery = this.Battery.StatusLowBattery;
|
|
596
601
|
this.Battery.Service.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, this.Battery.StatusLowBattery);
|
|
597
602
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
598
|
-
|
|
603
|
+
+ ` StatusLowBattery: ${this.Battery.StatusLowBattery}`);
|
|
599
604
|
}
|
|
600
605
|
}
|
|
601
606
|
|