@switchbot/homebridge-switchbot 3.5.0 → 3.5.1-beta.1
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/.github/npm-version-script.cjs +81 -0
- package/config.schema.json +4 -4
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +64 -189
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +34 -68
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +65 -158
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +47 -159
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +42 -105
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +1 -0
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +61 -182
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +41 -2
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +182 -5
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +76 -145
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts +7 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +54 -17
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +55 -104
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +27 -46
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +56 -120
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +36 -66
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +27 -46
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +26 -45
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +24 -43
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +32 -66
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +43 -88
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +23 -43
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +10 -28
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +8 -20
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +8 -20
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +8 -20
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +7 -0
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js +28 -0
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +8 -20
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +8 -20
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +8 -20
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +8 -20
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +8 -20
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/settings.d.ts +4 -2
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/dist/utils.d.ts +19 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +20 -1
- package/dist/utils.js.map +1 -1
- package/package.json +8 -8
- package/src/device/blindtilt.ts +71 -186
- package/src/device/bot.ts +32 -68
- package/src/device/ceilinglight.ts +67 -153
- package/src/device/colorbulb.ts +51 -155
- package/src/device/contact.ts +49 -104
- package/src/device/curtain.ts +70 -177
- package/src/device/device.ts +207 -8
- package/src/device/fan.ts +75 -147
- package/src/device/hub.ts +55 -19
- package/src/device/humidifier.ts +52 -104
- package/src/device/iosensor.ts +25 -46
- package/src/device/lightstrip.ts +54 -121
- package/src/device/lock.ts +35 -67
- package/src/device/meter.ts +25 -46
- package/src/device/meterplus.ts +24 -45
- package/src/device/motion.ts +22 -43
- package/src/device/plug.ts +30 -66
- package/src/device/robotvacuumcleaner.ts +40 -89
- package/src/device/waterdetector.ts +22 -43
- package/src/irdevice/airconditioner.ts +10 -26
- package/src/irdevice/airpurifier.ts +8 -20
- package/src/irdevice/camera.ts +8 -20
- package/src/irdevice/fan.ts +8 -20
- package/src/irdevice/irdevice.ts +29 -0
- package/src/irdevice/light.ts +8 -20
- package/src/irdevice/other.ts +8 -20
- package/src/irdevice/tv.ts +8 -20
- package/src/irdevice/vacuumcleaner.ts +8 -20
- package/src/irdevice/waterheater.ts +8 -20
- package/src/settings.ts +4 -2
- package/src/utils.ts +20 -1
package/src/device/device.ts
CHANGED
|
@@ -4,13 +4,15 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { hostname } from 'os';
|
|
7
|
+
import { request } from 'undici';
|
|
7
8
|
import asyncmqtt from 'async-mqtt';
|
|
8
|
-
import {
|
|
9
|
+
import { Devices } from '../settings.js';
|
|
10
|
+
import { BlindTiltMappingMode, SwitchBotModel, SwitchBotBLEModel, SwitchBotBLEModelName, sleep } from '../utils.js';
|
|
9
11
|
|
|
10
12
|
import type { MqttClient } from 'mqtt';
|
|
11
13
|
import type { SwitchBotPlatform } from '../platform.js';
|
|
12
|
-
import type { API, HAP, Logging, PlatformAccessory } from 'homebridge';
|
|
13
|
-
import type {
|
|
14
|
+
import type { API, CharacteristicValue, HAP, Logging, PlatformAccessory, Service } from 'homebridge';
|
|
15
|
+
import type { ad, device, serviceData, SwitchBotPlatformConfig, devicesConfig, deviceStatus } from '../settings.js';
|
|
14
16
|
|
|
15
17
|
export abstract class deviceBase {
|
|
16
18
|
public readonly api: API;
|
|
@@ -365,14 +367,54 @@ export abstract class deviceBase {
|
|
|
365
367
|
: null;
|
|
366
368
|
}
|
|
367
369
|
|
|
368
|
-
async
|
|
370
|
+
async switchbotBLE() {
|
|
371
|
+
const switchbot = await this.platform.connectBLE();
|
|
372
|
+
// Convert to BLE Address
|
|
373
|
+
await this.convertBLEAddress();
|
|
374
|
+
await this.getCustomBLEAddress(switchbot);
|
|
375
|
+
return switchbot;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
async convertBLEAddress() {
|
|
379
|
+
this.device.bleMac = this.device
|
|
380
|
+
.deviceId!.match(/.{1,2}/g)!
|
|
381
|
+
.join(':')
|
|
382
|
+
.toLowerCase();
|
|
383
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
async monitorAdvertisementPackets(switchbot: any) {
|
|
387
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Scanning for ${this.device.bleModelName} devices...`);
|
|
388
|
+
await switchbot.startScan({ model: this.device.bleModel, id: this.device.bleMac });
|
|
389
|
+
// Set an event handler
|
|
390
|
+
let serviceData: serviceData = { model: this.device.bleModel, modelName: this.device.bleModelName } as serviceData;
|
|
391
|
+
switchbot.onadvertisement = async (ad: ad) => {
|
|
392
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} ad: ${JSON.stringify(ad, null, ' ')}`);
|
|
393
|
+
if (this.device.bleMac === ad.address && ad.serviceData.model === this.device.bleModel) {
|
|
394
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ${JSON.stringify(ad, null, ' ')}`);
|
|
395
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} address: ${ad.address}, model: ${ad.serviceData.model}`);
|
|
396
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
|
|
397
|
+
serviceData = ad.serviceData;
|
|
398
|
+
} else {
|
|
399
|
+
serviceData = { model: '', modelName: '' } as serviceData;
|
|
400
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
// Wait 10 seconds
|
|
404
|
+
await switchbot.wait(this.scanDuration * 1000);
|
|
405
|
+
// Stop to monitor
|
|
406
|
+
await switchbot.stopScan();
|
|
407
|
+
return serviceData;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
async getCustomBLEAddress(switchbot: any): Promise<void> {
|
|
369
411
|
if (this.device.customBLEaddress && this.deviceLogging.includes('debug')) {
|
|
370
412
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} customBLEaddress: ${this.device.customBLEaddress}`);
|
|
371
413
|
(async () => {
|
|
372
414
|
// Start to monitor advertisement packets
|
|
373
415
|
await switchbot.startScan({ model: this.device.bleModel });
|
|
374
416
|
// Set an event handler
|
|
375
|
-
switchbot.onadvertisement = (ad:
|
|
417
|
+
switchbot.onadvertisement = async (ad: ad) => {
|
|
376
418
|
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} ad: ${JSON.stringify(ad, null, ' ')}`);
|
|
377
419
|
};
|
|
378
420
|
await sleep(10000);
|
|
@@ -382,27 +424,155 @@ export abstract class deviceBase {
|
|
|
382
424
|
}
|
|
383
425
|
}
|
|
384
426
|
|
|
427
|
+
async successfulPushChange_BLE(Characteristic: string, CharacteristicValue: CharacteristicValue, Connection: string) {
|
|
428
|
+
this.successLog(`${this.device.deviceType}: ${this.accessory.displayName} ${Characteristic}: ${CharacteristicValue}`
|
|
429
|
+
+ ` sent over ${Connection}, sent successfully`);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
async successfulPushChange(statusCode: any, deviceStatus: any, bodyChange: string) {
|
|
433
|
+
this.debugSuccessLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode} & deviceStatus`
|
|
434
|
+
+ ` StatusCode: ${deviceStatus.statusCode}`);
|
|
435
|
+
this.successLog(`${this.device.deviceType}: ${this.accessory.displayName} request to SwitchBot API,`
|
|
436
|
+
+ ` body: ${JSON.stringify(JSON.parse(bodyChange))} sent successfully`);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
async failedBLEChanges(e: Error): Promise<void> {
|
|
440
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed BLEpushChanges with ${this.device.connectionType}`
|
|
441
|
+
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
async bodyChange(bodyChange: string, Connection: string) {
|
|
445
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to ${Connection}, body: ${bodyChange},`);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
async pushChangeDisabled() {
|
|
449
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
|
|
450
|
+
+ ` ${this.device.connectionType}, pushChanges will not happen.`);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
async pushChangeRequest(bodyChange: string): Promise<{ body: any; statusCode: any; }> {
|
|
454
|
+
return await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
455
|
+
body: bodyChange,
|
|
456
|
+
method: 'POST',
|
|
457
|
+
headers: this.platform.generateHeaders(),
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
async pushChange(pushChange: string) {
|
|
462
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ${pushChange}`);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
async pushChangeError(Change: string, e: Error) {
|
|
466
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed ${Change} with ${this.device.connectionType}`
|
|
467
|
+
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
async noChanges(Change: string, CharacteristicValue: CharacteristicValue, CharacteristicValueCached: CharacteristicValue) {
|
|
471
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No Changes, ${Change}: ${CharacteristicValue}, `
|
|
472
|
+
+ `${Change}Cached: ${CharacteristicValueCached}`);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
async successfulRefreshStatus(statusCode: any, deviceStatus: any) {
|
|
476
|
+
this.debugSuccessLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
477
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
async openAPIRefreshError(e: Error) {
|
|
481
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}`
|
|
482
|
+
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
async statusCodes(statusCode: any, deviceStatus: any) {
|
|
486
|
+
this.statusCode(statusCode);
|
|
487
|
+
this.statusCode(deviceStatus.statusCode);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
async refreshStatusCodes(statusCode: number, deviceStatus: deviceStatus): Promise<void> {
|
|
491
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
492
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
493
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
async pushStatusCodes(statusCode: number, deviceStatus: any) {
|
|
497
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
498
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
499
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
500
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
async deviceRefreshStatus(): Promise<{ body: any; statusCode: any; }> {
|
|
504
|
+
return await this.platform.retryRequest(this.deviceMaxRetries, this.deviceDelayBetweenRetries,
|
|
505
|
+
`${Devices}/${this.device.deviceId}/status`, { headers: this.platform.generateHeaders() });
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Update the characteristic value and log the change.
|
|
510
|
+
* params: Service, Characteristic, CharacteristicValue, CharacteristicName, history
|
|
511
|
+
* @param Service: Service
|
|
512
|
+
* @param Characteristic: Characteristic
|
|
513
|
+
* @param CharacteristicValue: CharacteristicValue | undefined
|
|
514
|
+
* @param CharacteristicName: string
|
|
515
|
+
* @param history: object
|
|
516
|
+
* @return: void
|
|
517
|
+
*
|
|
518
|
+
*/
|
|
519
|
+
async updateCharacteristic(Service: Service, Characteristic: any,
|
|
520
|
+
CharacteristicValue: CharacteristicValue | undefined, CharacteristicName: string, history?: object): Promise<void> {
|
|
521
|
+
if (CharacteristicValue === undefined) {
|
|
522
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ${CharacteristicName}: ${CharacteristicValue}`);
|
|
523
|
+
} else {
|
|
524
|
+
await this.mqtt(CharacteristicName, CharacteristicValue);
|
|
525
|
+
if (this.device.history) {
|
|
526
|
+
this.historyService?.addEntry(history);
|
|
527
|
+
}
|
|
528
|
+
Service.updateCharacteristic(Characteristic, CharacteristicValue);
|
|
529
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
530
|
+
+ ` ${CharacteristicName}: ${CharacteristicValue}`);
|
|
531
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} context before: ${this.accessory.context[CharacteristicName]}`);
|
|
532
|
+
this.accessory.context[CharacteristicName] = CharacteristicValue;
|
|
533
|
+
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} context after: ${this.accessory.context[CharacteristicName]}`);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
async mqtt(CharacteristicName: string, CharacteristicValue: CharacteristicValue) {
|
|
538
|
+
if (this.device.mqttURL) {
|
|
539
|
+
this.mqttPublish(CharacteristicName, CharacteristicValue.toString());
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
async noChangeSet(value: CharacteristicValue, CharacteristicName: string) {
|
|
544
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No Changes, Set ${CharacteristicName}: ${value}`);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
async changeSet(value: CharacteristicValue, CharacteristicName: string) {
|
|
548
|
+
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set ${CharacteristicName}: ${value}`);
|
|
549
|
+
}
|
|
550
|
+
|
|
385
551
|
async getDeviceContext(accessory: PlatformAccessory, device: device & devicesConfig): Promise<void> {
|
|
386
552
|
// Set the accessory context
|
|
387
553
|
switch (device.deviceType) {
|
|
388
554
|
case 'Humidifier':
|
|
389
555
|
device.model = SwitchBotModel.Humidifier;
|
|
390
556
|
device.bleModel = SwitchBotBLEModel.Humidifier;
|
|
557
|
+
device.bleModelName = SwitchBotBLEModelName.Humidifier;
|
|
391
558
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
392
559
|
break;
|
|
393
560
|
case 'Hub Mini':
|
|
394
561
|
device.model = SwitchBotModel.HubMini;
|
|
395
562
|
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
563
|
+
device.bleModelName = SwitchBotBLEModelName.Unknown;
|
|
396
564
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
397
565
|
break;
|
|
398
566
|
case 'Hub Plus':
|
|
399
567
|
device.model = SwitchBotModel.HubPlus;
|
|
400
568
|
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
569
|
+
device.bleModelName = SwitchBotBLEModelName.Unknown;
|
|
401
570
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
402
571
|
break;
|
|
403
572
|
case 'Hub 2':
|
|
404
573
|
device.model = SwitchBotModel.Hub2;
|
|
405
|
-
device.bleModel = SwitchBotBLEModel.
|
|
574
|
+
device.bleModel = SwitchBotBLEModel.Hub2;
|
|
575
|
+
device.bleModelName = SwitchBotBLEModelName.Hub2;
|
|
406
576
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
407
577
|
break;
|
|
408
578
|
case 'Bot':
|
|
@@ -413,96 +583,115 @@ export abstract class deviceBase {
|
|
|
413
583
|
case 'Meter':
|
|
414
584
|
device.model = SwitchBotModel.Meter;
|
|
415
585
|
device.bleModel = SwitchBotBLEModel.Meter;
|
|
586
|
+
device.bleModelName = SwitchBotBLEModelName.Meter;
|
|
416
587
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
417
588
|
break;
|
|
418
589
|
case 'MeterPlus':
|
|
419
590
|
device.model = SwitchBotModel.MeterPlusUS;
|
|
420
591
|
device.bleModel = SwitchBotBLEModel.MeterPlus;
|
|
592
|
+
device.bleModelName = SwitchBotBLEModelName.MeterPlus;
|
|
421
593
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
422
594
|
break;
|
|
423
595
|
case 'Meter Plus (JP)':
|
|
424
596
|
device.model = SwitchBotModel.MeterPlusJP;
|
|
425
597
|
device.bleModel = SwitchBotBLEModel.MeterPlus;
|
|
598
|
+
device.bleModelName = SwitchBotBLEModelName.MeterPlus;
|
|
426
599
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
427
600
|
break;
|
|
428
601
|
case 'WoIOSensor':
|
|
429
602
|
device.model = SwitchBotModel.OutdoorMeter;
|
|
430
603
|
device.bleModel = SwitchBotBLEModel.OutdoorMeter;
|
|
604
|
+
device.bleModelName = SwitchBotBLEModelName.OutdoorMeter;
|
|
431
605
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
432
606
|
break;
|
|
433
607
|
case 'Water Detector':
|
|
434
608
|
device.model = SwitchBotModel.WaterDetector;
|
|
435
609
|
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
610
|
+
device.bleModelName = SwitchBotBLEModelName.Unknown;
|
|
436
611
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
437
612
|
break;
|
|
438
613
|
case 'Motion Sensor':
|
|
439
614
|
device.model = SwitchBotModel.MotionSensor;
|
|
440
615
|
device.bleModel = SwitchBotBLEModel.MotionSensor;
|
|
616
|
+
device.bleModelName = SwitchBotBLEModelName.MotionSensor;
|
|
441
617
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
442
618
|
break;
|
|
443
619
|
case 'Contact Sensor':
|
|
444
620
|
device.model = SwitchBotModel.ContactSensor;
|
|
445
621
|
device.bleModel = SwitchBotBLEModel.ContactSensor;
|
|
622
|
+
device.bleModelName = SwitchBotBLEModelName.ContactSensor;
|
|
446
623
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
447
624
|
break;
|
|
448
625
|
case 'Curtain':
|
|
449
626
|
device.model = SwitchBotModel.Curtain;
|
|
450
627
|
device.bleModel = SwitchBotBLEModel.Curtain;
|
|
628
|
+
device.bleModelName = SwitchBotBLEModelName.Curtain;
|
|
451
629
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
452
630
|
break;
|
|
453
631
|
case 'Curtain3':
|
|
454
632
|
device.model = SwitchBotModel.Curtain3;
|
|
455
633
|
device.bleModel = SwitchBotBLEModel.Curtain3;
|
|
634
|
+
device.bleModelName = SwitchBotBLEModelName.Curtain3;
|
|
456
635
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
457
636
|
break;
|
|
458
637
|
case 'Blind Tilt':
|
|
459
638
|
device.model = SwitchBotModel.BlindTilt;
|
|
460
639
|
device.bleModel = SwitchBotBLEModel.BlindTilt;
|
|
640
|
+
device.bleModelName = SwitchBotBLEModelName.BlindTilt;
|
|
461
641
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
462
642
|
break;
|
|
463
643
|
case 'Plug':
|
|
464
644
|
device.model = SwitchBotModel.Plug;
|
|
465
645
|
device.bleModel = SwitchBotBLEModel.PlugMiniUS;
|
|
646
|
+
device.bleModelName = SwitchBotBLEModelName.PlugMini;
|
|
466
647
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
467
648
|
break;
|
|
468
649
|
case 'Plug Mini (US)':
|
|
469
650
|
device.model = SwitchBotModel.PlugMiniUS;
|
|
470
651
|
device.bleModel = SwitchBotBLEModel.PlugMiniUS;
|
|
652
|
+
device.bleModelName = SwitchBotBLEModelName.PlugMini;
|
|
471
653
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
472
654
|
break;
|
|
473
655
|
case 'Plug Mini (JP)':
|
|
474
656
|
device.model = SwitchBotModel.PlugMiniJP;
|
|
475
657
|
device.bleModel = SwitchBotBLEModel.PlugMiniJP;
|
|
658
|
+
device.bleModelName = SwitchBotBLEModelName.PlugMini;
|
|
476
659
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
477
660
|
break;
|
|
478
661
|
case 'Smart Lock':
|
|
479
662
|
device.model = SwitchBotModel.Lock;
|
|
480
663
|
device.bleModel = SwitchBotBLEModel.Lock;
|
|
664
|
+
device.bleModelName = SwitchBotBLEModelName.Lock;
|
|
481
665
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
482
666
|
break;
|
|
483
667
|
case 'Smart Lock Pro':
|
|
484
668
|
device.model = SwitchBotModel.LockPro;
|
|
485
|
-
device.bleModel = SwitchBotBLEModel.
|
|
669
|
+
device.bleModel = SwitchBotBLEModel.Lock;
|
|
670
|
+
device.bleModelName = SwitchBotBLEModelName.Lock;
|
|
486
671
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
487
672
|
break;
|
|
488
673
|
case 'Color Bulb':
|
|
489
674
|
device.model = SwitchBotModel.ColorBulb;
|
|
490
675
|
device.bleModel = SwitchBotBLEModel.ColorBulb;
|
|
676
|
+
device.bleModelName = SwitchBotBLEModelName.ColorBulb;
|
|
491
677
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
492
678
|
break;
|
|
493
679
|
case 'K10+':
|
|
494
680
|
device.model = SwitchBotModel.K10;
|
|
495
681
|
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
682
|
+
device.bleModelName = SwitchBotBLEModelName.Unknown;
|
|
496
683
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
497
684
|
break;
|
|
498
685
|
case 'WoSweeper':
|
|
499
686
|
device.model = SwitchBotModel.WoSweeper;
|
|
500
687
|
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
688
|
+
device.bleModelName = SwitchBotBLEModelName.Unknown;
|
|
501
689
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
502
690
|
break;
|
|
503
691
|
case 'WoSweeperMini':
|
|
504
692
|
device.model = SwitchBotModel.WoSweeperMini;
|
|
505
693
|
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
694
|
+
device.bleModelName = SwitchBotBLEModelName.Unknown;
|
|
506
695
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
507
696
|
break;
|
|
508
697
|
case 'Robot Vacuum Cleaner S1':
|
|
@@ -513,51 +702,61 @@ export abstract class deviceBase {
|
|
|
513
702
|
case 'Robot Vacuum Cleaner S1 Plus':
|
|
514
703
|
device.model = SwitchBotModel.RobotVacuumCleanerS1Plus;
|
|
515
704
|
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
705
|
+
device.bleModelName = SwitchBotBLEModelName.Unknown;
|
|
516
706
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
517
707
|
break;
|
|
518
708
|
case 'Robot Vacuum Cleaner S10':
|
|
519
709
|
device.model = SwitchBotModel.RobotVacuumCleanerS10;
|
|
520
710
|
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
711
|
+
device.bleModelName = SwitchBotBLEModelName.Unknown;
|
|
521
712
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
522
713
|
break;
|
|
523
714
|
case 'Ceiling Light':
|
|
524
715
|
device.model = SwitchBotModel.CeilingLight;
|
|
525
716
|
device.bleModel = SwitchBotBLEModel.CeilingLight;
|
|
717
|
+
device.bleModelName = SwitchBotBLEModelName.Unknown;
|
|
526
718
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
527
719
|
break;
|
|
528
720
|
case 'Ceiling Light Pro':
|
|
529
721
|
device.model = SwitchBotModel.CeilingLightPro;
|
|
530
722
|
device.bleModel = SwitchBotBLEModel.CeilingLightPro;
|
|
723
|
+
device.bleModelName = SwitchBotBLEModelName.Unknown;
|
|
531
724
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
532
725
|
break;
|
|
533
726
|
case 'Strip Light':
|
|
534
727
|
device.model = SwitchBotModel.StripLight;
|
|
535
728
|
device.bleModel = SwitchBotBLEModel.StripLight;
|
|
729
|
+
device.bleModelName = SwitchBotBLEModelName.StripLight;
|
|
536
730
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
537
731
|
break;
|
|
538
732
|
case 'Indoor Cam':
|
|
539
733
|
device.model = SwitchBotModel.IndoorCam;
|
|
540
734
|
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
735
|
+
device.bleModelName = SwitchBotBLEModelName.Unknown;
|
|
541
736
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
542
737
|
break;
|
|
543
738
|
case 'Remote':
|
|
544
739
|
device.model = SwitchBotModel.Remote;
|
|
545
|
-
device.bleModel = SwitchBotBLEModel.
|
|
740
|
+
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
741
|
+
device.bleModelName = SwitchBotBLEModelName.Unknown;
|
|
546
742
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
547
743
|
break;
|
|
548
744
|
case 'remote with screen+':
|
|
549
745
|
device.model = SwitchBotModel.UniversalRemote;
|
|
550
746
|
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
747
|
+
device.bleModelName = SwitchBotBLEModelName.Unknown;
|
|
551
748
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
552
749
|
break;
|
|
553
750
|
case 'Battery Circulator Fan':
|
|
554
751
|
device.model = SwitchBotModel.BatteryCirculatorFan;
|
|
555
752
|
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
753
|
+
device.bleModelName = SwitchBotBLEModelName.Unknown;
|
|
556
754
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
557
755
|
break;
|
|
558
756
|
default:
|
|
559
757
|
device.model = SwitchBotModel.Unknown;
|
|
560
758
|
device.bleModel = SwitchBotBLEModel.Unknown;
|
|
759
|
+
device.bleModelName = SwitchBotBLEModelName.Unknown;
|
|
561
760
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Model: ${device.model}, BLE Model: ${device.bleModel}`);
|
|
562
761
|
}
|
|
563
762
|
accessory.context.model = device.model;
|