@switchbot/homebridge-switchbot 3.1.1-beta.6 → 3.1.1-beta.8
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 +9 -9
- package/README.md +2 -2
- package/config.schema.json +1 -1
- package/dist/device/blindtilt.js +2 -2
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.js +14 -14
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.js +1 -1
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.js +1 -1
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +6 -6
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +2 -11
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.js +1 -1
- package/dist/device/humidifier.js +1 -1
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.js +2 -2
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.js +1 -1
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.js +1 -1
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.js +2 -2
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.js +2 -2
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.js +1 -1
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.js +1 -1
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.js +1 -1
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/irdevice/fan.js +1 -1
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/other.js +12 -12
- package/dist/irdevice/other.js.map +1 -1
- package/dist/platform.d.ts +1 -1
- package/dist/platform.js +8 -8
- package/package.json +1 -1
- package/src/device/blindtilt.ts +2 -2
- package/src/device/bot.ts +14 -14
- package/src/device/ceilinglight.ts +1 -1
- package/src/device/colorbulb.ts +1 -1
- package/src/device/contact.ts +6 -6
- package/src/device/curtain.ts +2 -12
- package/src/device/hub.ts +1 -1
- package/src/device/humidifier.ts +1 -1
- package/src/device/iosensor.ts +2 -2
- package/src/device/lightstrip.ts +1 -1
- package/src/device/lock.ts +1 -1
- package/src/device/meter.ts +2 -2
- package/src/device/meterplus.ts +2 -2
- package/src/device/motion.ts +1 -1
- package/src/device/plug.ts +1 -1
- package/src/device/robotvacuumcleaner.ts +1 -1
- package/src/irdevice/fan.ts +1 -1
- package/src/irdevice/other.ts +12 -12
- package/src/platform.ts +8 -8
- package/src/settings.ts +1 -1
package/dist/platform.js
CHANGED
|
@@ -142,7 +142,7 @@ export class SwitchBotPlatform {
|
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
async setupwebhook() {
|
|
145
|
-
//webhook
|
|
145
|
+
//webhook configuration
|
|
146
146
|
if (this.config.options?.webhookURL) {
|
|
147
147
|
const url = this.config.options?.webhookURL;
|
|
148
148
|
try {
|
|
@@ -2422,36 +2422,36 @@ export class SwitchBotPlatform {
|
|
|
2422
2422
|
* Otherwise send debug logs to log.debug
|
|
2423
2423
|
*/
|
|
2424
2424
|
infoLog(...log) {
|
|
2425
|
-
if (this.
|
|
2425
|
+
if (this.enablingPlatformLogging()) {
|
|
2426
2426
|
this.log.info(String(...log));
|
|
2427
2427
|
}
|
|
2428
2428
|
}
|
|
2429
2429
|
warnLog(...log) {
|
|
2430
|
-
if (this.
|
|
2430
|
+
if (this.enablingPlatformLogging()) {
|
|
2431
2431
|
this.log.warn(String(...log));
|
|
2432
2432
|
}
|
|
2433
2433
|
}
|
|
2434
2434
|
debugWarnLog(...log) {
|
|
2435
|
-
if (this.
|
|
2435
|
+
if (this.enablingPlatformLogging()) {
|
|
2436
2436
|
if (this.platformLogging?.includes('debug')) {
|
|
2437
2437
|
this.log.warn('[DEBUG]', String(...log));
|
|
2438
2438
|
}
|
|
2439
2439
|
}
|
|
2440
2440
|
}
|
|
2441
2441
|
errorLog(...log) {
|
|
2442
|
-
if (this.
|
|
2442
|
+
if (this.enablingPlatformLogging()) {
|
|
2443
2443
|
this.log.error(String(...log));
|
|
2444
2444
|
}
|
|
2445
2445
|
}
|
|
2446
2446
|
debugErrorLog(...log) {
|
|
2447
|
-
if (this.
|
|
2447
|
+
if (this.enablingPlatformLogging()) {
|
|
2448
2448
|
if (this.platformLogging?.includes('debug')) {
|
|
2449
2449
|
this.log.error('[DEBUG]', String(...log));
|
|
2450
2450
|
}
|
|
2451
2451
|
}
|
|
2452
2452
|
}
|
|
2453
2453
|
debugLog(...log) {
|
|
2454
|
-
if (this.
|
|
2454
|
+
if (this.enablingPlatformLogging()) {
|
|
2455
2455
|
if (this.platformLogging === 'debugMode') {
|
|
2456
2456
|
this.log.debug(String(...log));
|
|
2457
2457
|
}
|
|
@@ -2460,7 +2460,7 @@ export class SwitchBotPlatform {
|
|
|
2460
2460
|
}
|
|
2461
2461
|
}
|
|
2462
2462
|
}
|
|
2463
|
-
|
|
2463
|
+
enablingPlatformLogging() {
|
|
2464
2464
|
return this.platformLogging?.includes('debug') || this.platformLogging === 'standard';
|
|
2465
2465
|
}
|
|
2466
2466
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "SwitchBot",
|
|
3
3
|
"name": "@switchbot/homebridge-switchbot",
|
|
4
|
-
"version": "3.1.1-beta.
|
|
4
|
+
"version": "3.1.1-beta.8",
|
|
5
5
|
"description": "The SwitchBot plugin allows you to access your SwitchBot device(s) from HomeKit.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "SwitchBot",
|
package/src/device/blindtilt.ts
CHANGED
|
@@ -515,7 +515,7 @@ export class BlindTilt {
|
|
|
515
515
|
id: this.device.bleMac,
|
|
516
516
|
})
|
|
517
517
|
.then(async () => {
|
|
518
|
-
// Set an event
|
|
518
|
+
// Set an event handler
|
|
519
519
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
520
520
|
this.debugLog(
|
|
521
521
|
`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
|
@@ -933,7 +933,7 @@ export class BlindTilt {
|
|
|
933
933
|
}
|
|
934
934
|
|
|
935
935
|
/*
|
|
936
|
-
* Setup MQTT hadler if URL is
|
|
936
|
+
* Setup MQTT hadler if URL is specified.
|
|
937
937
|
*/
|
|
938
938
|
async setupMqtt(device: device & devicesConfig): Promise<void> {
|
|
939
939
|
if (device.mqttURL) {
|
package/src/device/bot.ts
CHANGED
|
@@ -549,7 +549,7 @@ export class Bot {
|
|
|
549
549
|
id: this.device.bleMac,
|
|
550
550
|
})
|
|
551
551
|
.then(async () => {
|
|
552
|
-
// Set an event
|
|
552
|
+
// Set an event handler
|
|
553
553
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
554
554
|
this.debugLog(
|
|
555
555
|
`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
|
@@ -753,7 +753,7 @@ export class Bot {
|
|
|
753
753
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Press Mode`);
|
|
754
754
|
this.On = false;
|
|
755
755
|
} else {
|
|
756
|
-
throw new Error(`${this.device.deviceType}: ${this.accessory.displayName} Device
|
|
756
|
+
throw new Error(`${this.device.deviceType}: ${this.accessory.displayName} Device Parameters not set for this Bot.`);
|
|
757
757
|
}
|
|
758
758
|
const bodyChange = JSON.stringify({
|
|
759
759
|
command: `${command}`,
|
|
@@ -1069,7 +1069,7 @@ export class Bot {
|
|
|
1069
1069
|
}
|
|
1070
1070
|
|
|
1071
1071
|
async removeOutletService(accessory: PlatformAccessory): Promise<void> {
|
|
1072
|
-
// If outletService still
|
|
1072
|
+
// If outletService still present, then remove first
|
|
1073
1073
|
this.outletService = this.accessory.getService(this.hap.Service.Outlet);
|
|
1074
1074
|
if (this.outletService) {
|
|
1075
1075
|
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Outlet Service`);
|
|
@@ -1078,7 +1078,7 @@ export class Bot {
|
|
|
1078
1078
|
}
|
|
1079
1079
|
|
|
1080
1080
|
async removeGarageDoorService(accessory: PlatformAccessory): Promise<void> {
|
|
1081
|
-
// If garageDoorService still
|
|
1081
|
+
// If garageDoorService still present, then remove first
|
|
1082
1082
|
this.garageDoorService = this.accessory.getService(this.hap.Service.GarageDoorOpener);
|
|
1083
1083
|
if (this.garageDoorService) {
|
|
1084
1084
|
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Garage Door Service`);
|
|
@@ -1087,7 +1087,7 @@ export class Bot {
|
|
|
1087
1087
|
}
|
|
1088
1088
|
|
|
1089
1089
|
async removeDoorService(accessory: PlatformAccessory): Promise<void> {
|
|
1090
|
-
// If doorService still
|
|
1090
|
+
// If doorService still present, then remove first
|
|
1091
1091
|
this.doorService = this.accessory.getService(this.hap.Service.Door);
|
|
1092
1092
|
if (this.doorService) {
|
|
1093
1093
|
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Door Service`);
|
|
@@ -1096,7 +1096,7 @@ export class Bot {
|
|
|
1096
1096
|
}
|
|
1097
1097
|
|
|
1098
1098
|
async removeLockService(accessory: PlatformAccessory): Promise<void> {
|
|
1099
|
-
// If lockService still
|
|
1099
|
+
// If lockService still present, then remove first
|
|
1100
1100
|
this.lockService = this.accessory.getService(this.hap.Service.LockMechanism);
|
|
1101
1101
|
if (this.lockService) {
|
|
1102
1102
|
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Lock Service`);
|
|
@@ -1105,7 +1105,7 @@ export class Bot {
|
|
|
1105
1105
|
}
|
|
1106
1106
|
|
|
1107
1107
|
async removeFaucetService(accessory: PlatformAccessory): Promise<void> {
|
|
1108
|
-
// If faucetService still
|
|
1108
|
+
// If faucetService still present, then remove first
|
|
1109
1109
|
this.faucetService = this.accessory.getService(this.hap.Service.Faucet);
|
|
1110
1110
|
if (this.faucetService) {
|
|
1111
1111
|
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Faucet Service`);
|
|
@@ -1114,7 +1114,7 @@ export class Bot {
|
|
|
1114
1114
|
}
|
|
1115
1115
|
|
|
1116
1116
|
async removeFanService(accessory: PlatformAccessory): Promise<void> {
|
|
1117
|
-
// If fanService still
|
|
1117
|
+
// If fanService still present, then remove first
|
|
1118
1118
|
this.fanService = this.accessory.getService(this.hap.Service.Fan);
|
|
1119
1119
|
if (this.fanService) {
|
|
1120
1120
|
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Fan Service`);
|
|
@@ -1123,7 +1123,7 @@ export class Bot {
|
|
|
1123
1123
|
}
|
|
1124
1124
|
|
|
1125
1125
|
async removeWindowService(accessory: PlatformAccessory): Promise<void> {
|
|
1126
|
-
// If windowService still
|
|
1126
|
+
// If windowService still present, then remove first
|
|
1127
1127
|
this.windowService = this.accessory.getService(this.hap.Service.Window);
|
|
1128
1128
|
if (this.windowService) {
|
|
1129
1129
|
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Window Service`);
|
|
@@ -1132,7 +1132,7 @@ export class Bot {
|
|
|
1132
1132
|
}
|
|
1133
1133
|
|
|
1134
1134
|
async removeWindowCoveringService(accessory: PlatformAccessory): Promise<void> {
|
|
1135
|
-
// If windowCoveringService still
|
|
1135
|
+
// If windowCoveringService still present, then remove first
|
|
1136
1136
|
this.windowCoveringService = this.accessory.getService(this.hap.Service.WindowCovering);
|
|
1137
1137
|
if (this.windowCoveringService) {
|
|
1138
1138
|
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Window Covering Service`);
|
|
@@ -1141,7 +1141,7 @@ export class Bot {
|
|
|
1141
1141
|
}
|
|
1142
1142
|
|
|
1143
1143
|
async removeStatefulProgrammableSwitchService(accessory: PlatformAccessory): Promise<void> {
|
|
1144
|
-
// If statefulProgrammableSwitchService still
|
|
1144
|
+
// If statefulProgrammableSwitchService still present, then remove first
|
|
1145
1145
|
this.statefulProgrammableSwitchService = this.accessory.getService(this.hap.Service.StatefulProgrammableSwitch);
|
|
1146
1146
|
if (this.statefulProgrammableSwitchService) {
|
|
1147
1147
|
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
|
|
@@ -1150,7 +1150,7 @@ export class Bot {
|
|
|
1150
1150
|
}
|
|
1151
1151
|
|
|
1152
1152
|
async removeSwitchService(accessory: PlatformAccessory): Promise<void> {
|
|
1153
|
-
// If switchService still
|
|
1153
|
+
// If switchService still present, then remove first
|
|
1154
1154
|
this.switchService = this.accessory.getService(this.hap.Service.Switch);
|
|
1155
1155
|
if (this.switchService) {
|
|
1156
1156
|
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Switch Service`);
|
|
@@ -1360,10 +1360,10 @@ export class Bot {
|
|
|
1360
1360
|
async deviceType(device: device & devicesConfig): Promise<void> {
|
|
1361
1361
|
if (!device.bot?.deviceType && this.accessory.context.deviceType) {
|
|
1362
1362
|
this.botDeviceType = this.accessory.context.deviceType;
|
|
1363
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Type: ${this.botDeviceType}, from
|
|
1363
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Type: ${this.botDeviceType}, from Accessory Cache.`);
|
|
1364
1364
|
} else if (device.bot?.deviceType) {
|
|
1365
1365
|
this.accessory.context.deviceType = device.bot.deviceType;
|
|
1366
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName}
|
|
1366
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Accessory Cache: ${this.accessory.context.deviceType}`);
|
|
1367
1367
|
this.botDeviceType = this.accessory.context.deviceType;
|
|
1368
1368
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Type: ${this.botDeviceType}`);
|
|
1369
1369
|
} else {
|
|
@@ -378,7 +378,7 @@ export class CeilingLight {
|
|
|
378
378
|
id: this.device.bleMac,
|
|
379
379
|
})
|
|
380
380
|
.then(async () => {
|
|
381
|
-
// Set an event
|
|
381
|
+
// Set an event handler
|
|
382
382
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
383
383
|
this.debugLog(
|
|
384
384
|
`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
package/src/device/colorbulb.ts
CHANGED
|
@@ -424,7 +424,7 @@ export class ColorBulb {
|
|
|
424
424
|
id: this.device.bleMac,
|
|
425
425
|
})
|
|
426
426
|
.then(async () => {
|
|
427
|
-
// Set an event
|
|
427
|
+
// Set an event handler
|
|
428
428
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
429
429
|
this.debugLog(
|
|
430
430
|
`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
package/src/device/contact.ts
CHANGED
|
@@ -38,7 +38,7 @@ export class Contact {
|
|
|
38
38
|
OpenAPI_CurrentAmbientLightLevel: deviceStatus['brightness'];
|
|
39
39
|
|
|
40
40
|
// BLE Status
|
|
41
|
-
|
|
41
|
+
BLE_BatteryLevel!: serviceData['battery'];
|
|
42
42
|
BLE_MotionDetected!: serviceData['movement'];
|
|
43
43
|
BLE_ContactSensorState!: serviceData['doorState'];
|
|
44
44
|
BLE_CurrentAmbientLightLevel: serviceData['lightLevel'];
|
|
@@ -257,10 +257,10 @@ export class Contact {
|
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
259
|
// Battery
|
|
260
|
-
if (this.
|
|
261
|
-
this.
|
|
260
|
+
if (this.BLE_BatteryLevel === undefined) {
|
|
261
|
+
this.BLE_BatteryLevel === 100;
|
|
262
262
|
}
|
|
263
|
-
this.BatteryLevel = Number(this.
|
|
263
|
+
this.BatteryLevel = Number(this.BLE_BatteryLevel);
|
|
264
264
|
if (this.BatteryLevel < 10) {
|
|
265
265
|
this.StatusLowBattery = this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
|
|
266
266
|
} else {
|
|
@@ -360,7 +360,7 @@ export class Contact {
|
|
|
360
360
|
id: this.device.bleMac,
|
|
361
361
|
})
|
|
362
362
|
.then(async () => {
|
|
363
|
-
// Set an event
|
|
363
|
+
// Set an event handler
|
|
364
364
|
this.scanning = true;
|
|
365
365
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
366
366
|
this.debugLog(
|
|
@@ -368,7 +368,7 @@ export class Contact {
|
|
|
368
368
|
` BLE Address Found: ${ad.address}`,
|
|
369
369
|
);
|
|
370
370
|
this.BLE_MotionDetected = ad.serviceData.movement;
|
|
371
|
-
this.
|
|
371
|
+
this.BLE_BatteryLevel = ad.serviceData.battery;
|
|
372
372
|
this.BLE_ContactSensorState = ad.serviceData.doorState;
|
|
373
373
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
|
|
374
374
|
this.debugLog(
|
package/src/device/curtain.ts
CHANGED
|
@@ -155,16 +155,6 @@ export class Curtain {
|
|
|
155
155
|
})
|
|
156
156
|
.onSet(this.TargetPositionSet.bind(this));
|
|
157
157
|
|
|
158
|
-
this.windowCoveringService
|
|
159
|
-
.getCharacteristic(this.hap.Characteristic.HoldPosition)
|
|
160
|
-
.setProps({
|
|
161
|
-
minStep: this.minStep(device),
|
|
162
|
-
minValue: 0,
|
|
163
|
-
maxValue: 100,
|
|
164
|
-
validValueRanges: [0, 100],
|
|
165
|
-
})
|
|
166
|
-
.onSet(this.HoldPositionSet.bind(this));
|
|
167
|
-
|
|
168
158
|
// Light Sensor Service
|
|
169
159
|
if (device.curtain?.hide_lightsensor) {
|
|
170
160
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Light Sensor Service`);
|
|
@@ -559,7 +549,7 @@ export class Curtain {
|
|
|
559
549
|
id: this.device.bleMac,
|
|
560
550
|
})
|
|
561
551
|
.then(async () => {
|
|
562
|
-
// Set an event
|
|
552
|
+
// Set an event handler
|
|
563
553
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
564
554
|
this.debugLog(
|
|
565
555
|
`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
|
@@ -962,7 +952,7 @@ export class Curtain {
|
|
|
962
952
|
}
|
|
963
953
|
|
|
964
954
|
/*
|
|
965
|
-
* Setup MQTT hadler if URL is
|
|
955
|
+
* Setup MQTT hadler if URL is specified.
|
|
966
956
|
*/
|
|
967
957
|
async setupMqtt(device: device & devicesConfig): Promise<void> {
|
|
968
958
|
if (device.mqttURL) {
|
package/src/device/hub.ts
CHANGED
package/src/device/humidifier.ts
CHANGED
|
@@ -355,7 +355,7 @@ export class Humidifier {
|
|
|
355
355
|
id: this.device.bleMac,
|
|
356
356
|
})
|
|
357
357
|
.then(async () => {
|
|
358
|
-
// Set an event
|
|
358
|
+
// Set an event handler
|
|
359
359
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
360
360
|
this.debugLog(
|
|
361
361
|
`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
package/src/device/iosensor.ts
CHANGED
|
@@ -328,7 +328,7 @@ export class IOSensor {
|
|
|
328
328
|
id: this.device.bleMac,
|
|
329
329
|
})
|
|
330
330
|
.then(async () => {
|
|
331
|
-
// Set an event
|
|
331
|
+
// Set an event handler
|
|
332
332
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
333
333
|
this.debugLog(
|
|
334
334
|
`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
|
@@ -495,7 +495,7 @@ export class IOSensor {
|
|
|
495
495
|
}
|
|
496
496
|
|
|
497
497
|
/*
|
|
498
|
-
* Setup MQTT hadler if URL is
|
|
498
|
+
* Setup MQTT hadler if URL is specified.
|
|
499
499
|
*/
|
|
500
500
|
async setupMqtt(device: device & devicesConfig): Promise<void> {
|
|
501
501
|
if (device.mqttURL) {
|
package/src/device/lightstrip.ts
CHANGED
|
@@ -371,7 +371,7 @@ export class StripLight {
|
|
|
371
371
|
id: this.device.bleMac,
|
|
372
372
|
})
|
|
373
373
|
.then(async () => {
|
|
374
|
-
// Set an event
|
|
374
|
+
// Set an event handler
|
|
375
375
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
376
376
|
this.debugLog(
|
|
377
377
|
`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
package/src/device/lock.ts
CHANGED
|
@@ -391,7 +391,7 @@ export class Lock {
|
|
|
391
391
|
id: this.device.bleMac,
|
|
392
392
|
})
|
|
393
393
|
.then(async () => {
|
|
394
|
-
// Set an event
|
|
394
|
+
// Set an event handler
|
|
395
395
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
396
396
|
this.debugLog(
|
|
397
397
|
`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
package/src/device/meter.ts
CHANGED
|
@@ -317,7 +317,7 @@ export class Meter {
|
|
|
317
317
|
id: this.device.bleMac,
|
|
318
318
|
})
|
|
319
319
|
.then(async () => {
|
|
320
|
-
// Set an event
|
|
320
|
+
// Set an event handler
|
|
321
321
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
322
322
|
this.debugLog(
|
|
323
323
|
`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
|
@@ -488,7 +488,7 @@ export class Meter {
|
|
|
488
488
|
}
|
|
489
489
|
|
|
490
490
|
/*
|
|
491
|
-
* Setup MQTT hadler if URL is
|
|
491
|
+
* Setup MQTT hadler if URL is specified.
|
|
492
492
|
*/
|
|
493
493
|
async setupMqtt(device: device & devicesConfig): Promise<void> {
|
|
494
494
|
if (device.mqttURL) {
|
package/src/device/meterplus.ts
CHANGED
|
@@ -319,7 +319,7 @@ export class MeterPlus {
|
|
|
319
319
|
id: this.device.bleMac,
|
|
320
320
|
})
|
|
321
321
|
.then(async () => {
|
|
322
|
-
// Set an event
|
|
322
|
+
// Set an event handler
|
|
323
323
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
324
324
|
this.debugLog(
|
|
325
325
|
`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
|
@@ -493,7 +493,7 @@ export class MeterPlus {
|
|
|
493
493
|
}
|
|
494
494
|
|
|
495
495
|
/*
|
|
496
|
-
* Setup MQTT hadler if URL is
|
|
496
|
+
* Setup MQTT hadler if URL is specified.
|
|
497
497
|
*/
|
|
498
498
|
async setupMqtt(device: device & devicesConfig): Promise<void> {
|
|
499
499
|
if (device.mqttURL) {
|
package/src/device/motion.ts
CHANGED
package/src/device/plug.ts
CHANGED
|
@@ -227,7 +227,7 @@ export class Plug {
|
|
|
227
227
|
id: this.device.bleMac,
|
|
228
228
|
})
|
|
229
229
|
.then(async () => {
|
|
230
|
-
// Set an event
|
|
230
|
+
// Set an event handler
|
|
231
231
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
232
232
|
this.debugLog(
|
|
233
233
|
`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
|
@@ -274,7 +274,7 @@ export class RobotVacuumCleaner {
|
|
|
274
274
|
id: this.device.bleMac,
|
|
275
275
|
})
|
|
276
276
|
.then(async () => {
|
|
277
|
-
// Set an event
|
|
277
|
+
// Set an event handler
|
|
278
278
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
279
279
|
this.debugLog(
|
|
280
280
|
`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
package/src/irdevice/fan.ts
CHANGED
|
@@ -86,7 +86,7 @@ export class Fan {
|
|
|
86
86
|
} else {
|
|
87
87
|
this.maxValue = 100;
|
|
88
88
|
}
|
|
89
|
-
// handle
|
|
89
|
+
// handle Rotation Speed events using the RotationSpeed characteristic
|
|
90
90
|
this.fanService
|
|
91
91
|
.getCharacteristic(this.hap.Characteristic.RotationSpeed)
|
|
92
92
|
.setProps({
|
package/src/irdevice/other.ts
CHANGED
|
@@ -770,7 +770,7 @@ export class Others {
|
|
|
770
770
|
}
|
|
771
771
|
|
|
772
772
|
async removeOutletService(accessory: PlatformAccessory): Promise<void> {
|
|
773
|
-
// If outletService still
|
|
773
|
+
// If outletService still present, then remove first
|
|
774
774
|
this.outletService = this.accessory.getService(this.hap.Service.Outlet);
|
|
775
775
|
if (this.outletService) {
|
|
776
776
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Outlet Service`);
|
|
@@ -779,7 +779,7 @@ export class Others {
|
|
|
779
779
|
}
|
|
780
780
|
|
|
781
781
|
async removeGarageDoorService(accessory: PlatformAccessory): Promise<void> {
|
|
782
|
-
// If garageDoorService still
|
|
782
|
+
// If garageDoorService still present, then remove first
|
|
783
783
|
this.garageDoorService = this.accessory.getService(this.hap.Service.GarageDoorOpener);
|
|
784
784
|
if (this.garageDoorService) {
|
|
785
785
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Garage Door Service`);
|
|
@@ -788,7 +788,7 @@ export class Others {
|
|
|
788
788
|
}
|
|
789
789
|
|
|
790
790
|
async removeDoorService(accessory: PlatformAccessory): Promise<void> {
|
|
791
|
-
// If doorService still
|
|
791
|
+
// If doorService still present, then remove first
|
|
792
792
|
this.doorService = this.accessory.getService(this.hap.Service.Door);
|
|
793
793
|
if (this.doorService) {
|
|
794
794
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Door Service`);
|
|
@@ -797,7 +797,7 @@ export class Others {
|
|
|
797
797
|
}
|
|
798
798
|
|
|
799
799
|
async removeLockService(accessory: PlatformAccessory): Promise<void> {
|
|
800
|
-
// If lockService still
|
|
800
|
+
// If lockService still present, then remove first
|
|
801
801
|
this.lockService = this.accessory.getService(this.hap.Service.LockMechanism);
|
|
802
802
|
if (this.lockService) {
|
|
803
803
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Lock Service`);
|
|
@@ -806,7 +806,7 @@ export class Others {
|
|
|
806
806
|
}
|
|
807
807
|
|
|
808
808
|
async removeFaucetService(accessory: PlatformAccessory): Promise<void> {
|
|
809
|
-
// If faucetService still
|
|
809
|
+
// If faucetService still present, then remove first
|
|
810
810
|
this.faucetService = this.accessory.getService(this.hap.Service.Faucet);
|
|
811
811
|
if (this.faucetService) {
|
|
812
812
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Faucet Service`);
|
|
@@ -815,7 +815,7 @@ export class Others {
|
|
|
815
815
|
}
|
|
816
816
|
|
|
817
817
|
async removeFanService(accessory: PlatformAccessory): Promise<void> {
|
|
818
|
-
// If fanService still
|
|
818
|
+
// If fanService still present, then remove first
|
|
819
819
|
this.fanService = this.accessory.getService(this.hap.Service.Fan);
|
|
820
820
|
if (this.fanService) {
|
|
821
821
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Fan Service`);
|
|
@@ -824,7 +824,7 @@ export class Others {
|
|
|
824
824
|
}
|
|
825
825
|
|
|
826
826
|
async removeWindowService(accessory: PlatformAccessory): Promise<void> {
|
|
827
|
-
// If windowService still
|
|
827
|
+
// If windowService still present, then remove first
|
|
828
828
|
this.windowService = this.accessory.getService(this.hap.Service.Window);
|
|
829
829
|
if (this.windowService) {
|
|
830
830
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Window Service`);
|
|
@@ -833,7 +833,7 @@ export class Others {
|
|
|
833
833
|
}
|
|
834
834
|
|
|
835
835
|
async removeWindowCoveringService(accessory: PlatformAccessory): Promise<void> {
|
|
836
|
-
// If windowCoveringService still
|
|
836
|
+
// If windowCoveringService still present, then remove first
|
|
837
837
|
this.windowCoveringService = this.accessory.getService(this.hap.Service.WindowCovering);
|
|
838
838
|
if (this.windowCoveringService) {
|
|
839
839
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Window Covering Service`);
|
|
@@ -842,7 +842,7 @@ export class Others {
|
|
|
842
842
|
}
|
|
843
843
|
|
|
844
844
|
async removeStatefulProgrammableSwitchService(accessory: PlatformAccessory): Promise<void> {
|
|
845
|
-
// If statefulProgrammableSwitchService still
|
|
845
|
+
// If statefulProgrammableSwitchService still present, then remove first
|
|
846
846
|
this.statefulProgrammableSwitchService = this.accessory.getService(this.hap.Service.StatefulProgrammableSwitch);
|
|
847
847
|
if (this.statefulProgrammableSwitchService) {
|
|
848
848
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
|
|
@@ -851,7 +851,7 @@ export class Others {
|
|
|
851
851
|
}
|
|
852
852
|
|
|
853
853
|
async removeSwitchService(accessory: PlatformAccessory): Promise<void> {
|
|
854
|
-
// If switchService still
|
|
854
|
+
// If switchService still present, then remove first
|
|
855
855
|
this.switchService = this.accessory.getService(this.hap.Service.Switch);
|
|
856
856
|
if (this.switchService) {
|
|
857
857
|
this.warnLog(`${this.device.remoteType}: ${accessory.displayName} Removing Leftover Switch Service`);
|
|
@@ -862,10 +862,10 @@ export class Others {
|
|
|
862
862
|
async deviceType(device: irdevice & irDevicesConfig): Promise<void> {
|
|
863
863
|
if (!device.other?.deviceType && this.accessory.context.deviceType) {
|
|
864
864
|
this.otherDeviceType = this.accessory.context.deviceType;
|
|
865
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Type: ${this.otherDeviceType}, from
|
|
865
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Type: ${this.otherDeviceType}, from Accessory Cache.`);
|
|
866
866
|
} else if (device.other?.deviceType) {
|
|
867
867
|
this.accessory.context.deviceType = device.other.deviceType;
|
|
868
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName}
|
|
868
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} Accessory Cache: ${this.accessory.context.deviceType}`);
|
|
869
869
|
this.otherDeviceType = this.accessory.context.deviceType;
|
|
870
870
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Type: ${this.otherDeviceType}`);
|
|
871
871
|
} else {
|
package/src/platform.ts
CHANGED
|
@@ -158,7 +158,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
async setupwebhook() {
|
|
161
|
-
//webhook
|
|
161
|
+
//webhook configuration
|
|
162
162
|
if (this.config.options?.webhookURL) {
|
|
163
163
|
const url = this.config.options?.webhookURL;
|
|
164
164
|
|
|
@@ -2551,19 +2551,19 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2551
2551
|
* Otherwise send debug logs to log.debug
|
|
2552
2552
|
*/
|
|
2553
2553
|
infoLog(...log: any[]): void {
|
|
2554
|
-
if (this.
|
|
2554
|
+
if (this.enablingPlatformLogging()) {
|
|
2555
2555
|
this.log.info(String(...log));
|
|
2556
2556
|
}
|
|
2557
2557
|
}
|
|
2558
2558
|
|
|
2559
2559
|
warnLog(...log: any[]): void {
|
|
2560
|
-
if (this.
|
|
2560
|
+
if (this.enablingPlatformLogging()) {
|
|
2561
2561
|
this.log.warn(String(...log));
|
|
2562
2562
|
}
|
|
2563
2563
|
}
|
|
2564
2564
|
|
|
2565
2565
|
debugWarnLog(...log: any[]): void {
|
|
2566
|
-
if (this.
|
|
2566
|
+
if (this.enablingPlatformLogging()) {
|
|
2567
2567
|
if (this.platformLogging?.includes('debug')) {
|
|
2568
2568
|
this.log.warn('[DEBUG]', String(...log));
|
|
2569
2569
|
}
|
|
@@ -2571,13 +2571,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2571
2571
|
}
|
|
2572
2572
|
|
|
2573
2573
|
errorLog(...log: any[]): void {
|
|
2574
|
-
if (this.
|
|
2574
|
+
if (this.enablingPlatformLogging()) {
|
|
2575
2575
|
this.log.error(String(...log));
|
|
2576
2576
|
}
|
|
2577
2577
|
}
|
|
2578
2578
|
|
|
2579
2579
|
debugErrorLog(...log: any[]): void {
|
|
2580
|
-
if (this.
|
|
2580
|
+
if (this.enablingPlatformLogging()) {
|
|
2581
2581
|
if (this.platformLogging?.includes('debug')) {
|
|
2582
2582
|
this.log.error('[DEBUG]', String(...log));
|
|
2583
2583
|
}
|
|
@@ -2585,7 +2585,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2585
2585
|
}
|
|
2586
2586
|
|
|
2587
2587
|
debugLog(...log: any[]): void {
|
|
2588
|
-
if (this.
|
|
2588
|
+
if (this.enablingPlatformLogging()) {
|
|
2589
2589
|
if (this.platformLogging === 'debugMode') {
|
|
2590
2590
|
this.log.debug(String(...log));
|
|
2591
2591
|
} else if (this.platformLogging === 'debug') {
|
|
@@ -2594,7 +2594,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2594
2594
|
}
|
|
2595
2595
|
}
|
|
2596
2596
|
|
|
2597
|
-
|
|
2597
|
+
enablingPlatformLogging(): boolean {
|
|
2598
2598
|
return this.platformLogging?.includes('debug') || this.platformLogging === 'standard';
|
|
2599
2599
|
}
|
|
2600
2600
|
}
|
package/src/settings.ts
CHANGED
|
@@ -303,7 +303,7 @@ export type deviceStatus = {
|
|
|
303
303
|
mode?: number; //available for devices. the fan mode. (Used by the following deviceTypes: Smart Fan)
|
|
304
304
|
speed?: number; //the fan speed. (Used by the following deviceTypes: Smart Fan)
|
|
305
305
|
shaking?: boolean; //determines if the fan is swinging or not. (Used by the following deviceTypes: Smart Fan)
|
|
306
|
-
shakeCenter?: string; //the fan's swing
|
|
306
|
+
shakeCenter?: string; //the fan's swing direction. (Used by the following deviceTypes: Smart Fan)
|
|
307
307
|
shakeRange?: string; //the fan's swing range, 0~120°. (Used by the following deviceTypes: Smart Fan)
|
|
308
308
|
};
|
|
309
309
|
|