@switchbot/homebridge-switchbot 2.9.1-beta.3 → 2.9.1-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/device/blindtilt.d.ts +0 -3
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +7 -58
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +0 -3
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +7 -81
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +0 -3
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +14 -58
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +0 -3
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +10 -54
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +0 -3
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +7 -58
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +0 -3
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +7 -58
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts +1 -4
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +7 -60
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +0 -3
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +10 -57
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +0 -3
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +7 -57
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +0 -3
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +10 -54
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +0 -3
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +13 -61
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +0 -3
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +7 -60
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +1 -4
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +7 -61
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +0 -3
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +3 -55
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +0 -3
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +3 -51
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +0 -3
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +12 -61
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +0 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +6 -45
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +0 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +6 -45
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +0 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +6 -45
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +0 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +6 -45
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +0 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +6 -45
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +0 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +6 -45
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +0 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +6 -45
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +0 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +6 -45
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +0 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +6 -45
- package/dist/irdevice/waterheater.js.map +1 -1
- package/package.json +8 -8
- package/src/device/blindtilt.ts +7 -57
- package/src/device/bot.ts +7 -71
- package/src/device/ceilinglight.ts +14 -59
- package/src/device/colorbulb.ts +10 -54
- package/src/device/contact.ts +7 -58
- package/src/device/curtain.ts +7 -57
- package/src/device/hub.ts +7 -61
- package/src/device/humidifier.ts +10 -58
- package/src/device/iosensor.ts +7 -57
- package/src/device/lightstrip.ts +10 -54
- package/src/device/lock.ts +13 -62
- package/src/device/meter.ts +7 -59
- package/src/device/meterplus.ts +7 -61
- package/src/device/motion.ts +3 -54
- package/src/device/plug.ts +3 -50
- package/src/device/robotvacuumcleaner.ts +12 -61
- package/src/irdevice/airconditioner.ts +6 -44
- package/src/irdevice/airpurifier.ts +6 -46
- package/src/irdevice/camera.ts +6 -46
- package/src/irdevice/fan.ts +6 -46
- package/src/irdevice/light.ts +6 -46
- package/src/irdevice/other.ts +6 -46
- package/src/irdevice/tv.ts +6 -46
- package/src/irdevice/vacuumcleaner.ts +6 -46
- package/src/irdevice/waterheater.ts +6 -46
package/src/device/hub.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { MqttClient } from 'mqtt';
|
|
|
4
4
|
import { hostname } from 'os';
|
|
5
5
|
import { interval } from 'rxjs';
|
|
6
6
|
import { request } from 'undici';
|
|
7
|
-
import { Context } from 'vm';
|
|
8
7
|
import { SwitchBotPlatform } from '../platform';
|
|
9
8
|
import { Devices, device, deviceStatus, devicesConfig } from '../settings';
|
|
10
9
|
|
|
@@ -56,7 +55,7 @@ export class Hub {
|
|
|
56
55
|
// default placeholders
|
|
57
56
|
this.logs(device);
|
|
58
57
|
this.refreshRate(device);
|
|
59
|
-
this.context(
|
|
58
|
+
this.context();
|
|
60
59
|
this.setupHistoryService(device);
|
|
61
60
|
this.setupMqtt(device);
|
|
62
61
|
this.config(device);
|
|
@@ -72,20 +71,8 @@ export class Hub {
|
|
|
72
71
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
73
72
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
74
73
|
.setCharacteristic(this.platform.Characteristic.Model, accessory.context.model)
|
|
75
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId
|
|
76
|
-
|
|
77
|
-
if (accessory.context.FirmwareRevision) {
|
|
78
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
79
|
-
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
|
|
80
|
-
accessory
|
|
81
|
-
.getService(this.platform.Service.AccessoryInformation)!
|
|
82
|
-
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
83
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
84
|
-
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
85
|
-
.updateValue(accessory.context.FirmwareRevision);
|
|
86
|
-
} else {
|
|
87
|
-
this.setFirmwareRevision(accessory, device);
|
|
88
|
-
}
|
|
74
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
|
|
75
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
|
|
89
76
|
|
|
90
77
|
// Temperature Sensor Service
|
|
91
78
|
if (device.hub?.hide_temperature) {
|
|
@@ -303,6 +290,7 @@ export class Hub {
|
|
|
303
290
|
|
|
304
291
|
// FirmwareRevision
|
|
305
292
|
this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
|
|
293
|
+
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
306
294
|
}
|
|
307
295
|
|
|
308
296
|
async refreshStatus(): Promise<void> {
|
|
@@ -412,25 +400,6 @@ export class Hub {
|
|
|
412
400
|
}
|
|
413
401
|
}
|
|
414
402
|
|
|
415
|
-
// FirmwareRevision
|
|
416
|
-
if (this.FirmwareRevision === undefined) {
|
|
417
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
|
|
418
|
-
} else {
|
|
419
|
-
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
420
|
-
|
|
421
|
-
if (!this.device.hub?.hide_humidity) {
|
|
422
|
-
this.humidityService!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
423
|
-
}
|
|
424
|
-
if (!this.device.hub?.hide_temperature) {
|
|
425
|
-
this.temperatureService!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
426
|
-
}
|
|
427
|
-
if (!this.device.hub?.hide_lightsensor) {
|
|
428
|
-
this.lightSensorService!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
429
|
-
}
|
|
430
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
431
|
-
+ `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
|
|
432
|
-
}
|
|
433
|
-
|
|
434
403
|
// MQTT
|
|
435
404
|
if (this.device.mqttURL) {
|
|
436
405
|
this.mqttPublish(`{${mqttmessage.join(',')}}`);
|
|
@@ -536,7 +505,7 @@ export class Hub {
|
|
|
536
505
|
|
|
537
506
|
async offlineOff(): Promise<void> {
|
|
538
507
|
if (this.device.offline) {
|
|
539
|
-
await this.context(
|
|
508
|
+
await this.context();
|
|
540
509
|
await this.updateHomeKitCharacteristics();
|
|
541
510
|
}
|
|
542
511
|
}
|
|
@@ -571,28 +540,7 @@ export class Hub {
|
|
|
571
540
|
return this.set_maxLux;
|
|
572
541
|
}
|
|
573
542
|
|
|
574
|
-
async
|
|
575
|
-
await this.refreshStatus();
|
|
576
|
-
if (device.firmware) {
|
|
577
|
-
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
578
|
-
accessory.context.FirmwareRevision = device.firmware;
|
|
579
|
-
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
580
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
581
|
-
} else {
|
|
582
|
-
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version: ${device.version}`);
|
|
583
|
-
accessory.context.FirmwareRevision = device.version;
|
|
584
|
-
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
585
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
586
|
-
}
|
|
587
|
-
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
|
|
588
|
-
accessory
|
|
589
|
-
.getService(this.platform.Service.AccessoryInformation)!
|
|
590
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
591
|
-
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
592
|
-
.updateValue(this.FirmwareRevision);
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
async context(accessory, device) {
|
|
543
|
+
async context() {
|
|
596
544
|
if (this.CurrentRelativeHumidity === undefined) {
|
|
597
545
|
this.CurrentRelativeHumidity = 0;
|
|
598
546
|
} else {
|
|
@@ -610,9 +558,7 @@ export class Hub {
|
|
|
610
558
|
}
|
|
611
559
|
if (this.FirmwareRevision === undefined) {
|
|
612
560
|
this.FirmwareRevision = this.platform.version;
|
|
613
|
-
|
|
614
|
-
this.setFirmwareRevision(accessory, device);
|
|
615
|
-
this.FirmwareRevision = this.accessory.context.FirmwareRevision;
|
|
561
|
+
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
616
562
|
}
|
|
617
563
|
}
|
|
618
564
|
|
package/src/device/humidifier.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable brace-style */
|
|
2
|
-
import { Context } from 'vm';
|
|
3
1
|
import { request } from 'undici';
|
|
4
2
|
import { sleep } from '../utils';
|
|
5
3
|
import { interval, Subject } from 'rxjs';
|
|
@@ -81,20 +79,8 @@ export class Humidifier {
|
|
|
81
79
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
82
80
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
83
81
|
.setCharacteristic(this.platform.Characteristic.Model, 'W0801800')
|
|
84
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId
|
|
85
|
-
|
|
86
|
-
if (accessory.context.FirmwareRevision) {
|
|
87
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
88
|
-
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
|
|
89
|
-
accessory
|
|
90
|
-
.getService(this.platform.Service.AccessoryInformation)!
|
|
91
|
-
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
92
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
93
|
-
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
94
|
-
.updateValue(accessory.context.FirmwareRevision);
|
|
95
|
-
} else {
|
|
96
|
-
this.setFirmwareRevision(accessory, device);
|
|
97
|
-
}
|
|
82
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
|
|
83
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
|
|
98
84
|
|
|
99
85
|
// get the service if it exists, otherwise create a new service
|
|
100
86
|
// you can create multiple services for each accessory
|
|
@@ -294,6 +280,7 @@ export class Humidifier {
|
|
|
294
280
|
|
|
295
281
|
// FirmwareRevision
|
|
296
282
|
this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
|
|
283
|
+
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
297
284
|
}
|
|
298
285
|
|
|
299
286
|
/**
|
|
@@ -421,9 +408,9 @@ export class Humidifier {
|
|
|
421
408
|
async pushChanges(): Promise<void> {
|
|
422
409
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
423
410
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
|
|
424
|
-
}
|
|
425
|
-
await this.BLEpushChanges()
|
|
426
|
-
} else
|
|
411
|
+
/*} else if (this.BLE) {
|
|
412
|
+
await this.BLEpushChanges();*/
|
|
413
|
+
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
427
414
|
await this.openAPIpushChanges();
|
|
428
415
|
} else {
|
|
429
416
|
await this.offlineOff();
|
|
@@ -747,19 +734,6 @@ export class Humidifier {
|
|
|
747
734
|
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
748
735
|
}
|
|
749
736
|
}
|
|
750
|
-
|
|
751
|
-
// FirmwareRevision
|
|
752
|
-
if (this.FirmwareRevision === undefined) {
|
|
753
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
|
|
754
|
-
} else {
|
|
755
|
-
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
756
|
-
this.humidifierService.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
757
|
-
if (!this.device.humidifier?.hide_temperature) {
|
|
758
|
-
this.temperatureservice!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
759
|
-
}
|
|
760
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
761
|
-
+ `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
|
|
762
|
-
}
|
|
763
737
|
}
|
|
764
738
|
|
|
765
739
|
async stopScanning(switchbot: any) {
|
|
@@ -895,32 +869,6 @@ export class Humidifier {
|
|
|
895
869
|
}
|
|
896
870
|
}
|
|
897
871
|
|
|
898
|
-
async setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig) {
|
|
899
|
-
await this.refreshStatus();
|
|
900
|
-
if (device.firmware) {
|
|
901
|
-
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
902
|
-
accessory.context.FirmwareRevision = device.firmware;
|
|
903
|
-
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
904
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
905
|
-
} else if (device.version) {
|
|
906
|
-
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version: ${device.version}`);
|
|
907
|
-
accessory.context.FirmwareRevision = device.version;
|
|
908
|
-
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
909
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
910
|
-
} else {
|
|
911
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
912
|
-
accessory.context.FirmwareRevision = this.platform.version;
|
|
913
|
-
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
914
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
915
|
-
}
|
|
916
|
-
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
|
|
917
|
-
accessory
|
|
918
|
-
.getService(this.platform.Service.AccessoryInformation)!
|
|
919
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
920
|
-
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
921
|
-
.updateValue(this.FirmwareRevision);
|
|
922
|
-
}
|
|
923
|
-
|
|
924
872
|
async context() {
|
|
925
873
|
if (this.Active === undefined) {
|
|
926
874
|
this.Active = this.platform.Characteristic.Active.ACTIVE;
|
|
@@ -961,6 +909,10 @@ export class Humidifier {
|
|
|
961
909
|
} else {
|
|
962
910
|
this.WaterLevel = this.accessory.context.WaterLevel;
|
|
963
911
|
}
|
|
912
|
+
if (this.FirmwareRevision === undefined) {
|
|
913
|
+
this.FirmwareRevision = this.platform.version;
|
|
914
|
+
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
915
|
+
}
|
|
964
916
|
}
|
|
965
917
|
|
|
966
918
|
async refreshRate(device: device & devicesConfig): Promise<void> {
|
package/src/device/iosensor.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Context } from 'vm';
|
|
2
1
|
import { hostname } from 'os';
|
|
3
2
|
import { request } from 'undici';
|
|
4
3
|
import { sleep } from '../utils';
|
|
@@ -89,20 +88,8 @@ export class IOSensor {
|
|
|
89
88
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
90
89
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
91
90
|
.setCharacteristic(this.platform.Characteristic.Model, 'WoIOSensor')
|
|
92
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId
|
|
93
|
-
|
|
94
|
-
if (accessory.context.FirmwareRevision) {
|
|
95
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
96
|
-
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
|
|
97
|
-
accessory
|
|
98
|
-
.getService(this.platform.Service.AccessoryInformation)!
|
|
99
|
-
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
100
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
101
|
-
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
102
|
-
.updateValue(accessory.context.FirmwareRevision);
|
|
103
|
-
} else {
|
|
104
|
-
this.setFirmwareRevision(accessory, device);
|
|
105
|
-
}
|
|
91
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
|
|
92
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
|
|
106
93
|
|
|
107
94
|
// Temperature Sensor Service
|
|
108
95
|
if (device.meter?.hide_temperature) {
|
|
@@ -265,6 +252,7 @@ export class IOSensor {
|
|
|
265
252
|
|
|
266
253
|
// FirmwareRevision
|
|
267
254
|
this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
|
|
255
|
+
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
268
256
|
}
|
|
269
257
|
|
|
270
258
|
/**
|
|
@@ -457,22 +445,6 @@ export class IOSensor {
|
|
|
457
445
|
this.historyService?.addEntry(entry);
|
|
458
446
|
}
|
|
459
447
|
}
|
|
460
|
-
|
|
461
|
-
// FirmwareRevision
|
|
462
|
-
if (this.FirmwareRevision === undefined) {
|
|
463
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
|
|
464
|
-
} else {
|
|
465
|
-
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
466
|
-
this.batteryService.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
467
|
-
if (this.device.meter?.hide_humidity) {
|
|
468
|
-
this.humidityservice!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
469
|
-
}
|
|
470
|
-
if (this.device.meter?.hide_temperature) {
|
|
471
|
-
this.temperatureservice!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
472
|
-
}
|
|
473
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
474
|
-
+ `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
|
|
475
|
-
}
|
|
476
448
|
}
|
|
477
449
|
|
|
478
450
|
/*
|
|
@@ -634,32 +606,6 @@ export class IOSensor {
|
|
|
634
606
|
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
|
|
635
607
|
}
|
|
636
608
|
|
|
637
|
-
async setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig) {
|
|
638
|
-
await this.refreshStatus();
|
|
639
|
-
if (device.firmware) {
|
|
640
|
-
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
641
|
-
accessory.context.FirmwareRevision = device.firmware;
|
|
642
|
-
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
643
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
644
|
-
} else if (device.version) {
|
|
645
|
-
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version: ${device.version}`);
|
|
646
|
-
accessory.context.FirmwareRevision = device.version;
|
|
647
|
-
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
648
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
649
|
-
} else {
|
|
650
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
651
|
-
accessory.context.FirmwareRevision = this.platform.version;
|
|
652
|
-
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
653
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
654
|
-
}
|
|
655
|
-
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
|
|
656
|
-
accessory
|
|
657
|
-
.getService(this.platform.Service.AccessoryInformation)!
|
|
658
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
659
|
-
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
660
|
-
.updateValue(this.FirmwareRevision);
|
|
661
|
-
}
|
|
662
|
-
|
|
663
609
|
async context() {
|
|
664
610
|
if (this.CurrentRelativeHumidity === undefined) {
|
|
665
611
|
this.CurrentRelativeHumidity = 0;
|
|
@@ -682,6 +628,10 @@ export class IOSensor {
|
|
|
682
628
|
} else {
|
|
683
629
|
this.StatusLowBattery = this.accessory.context.StatusLowBattery;
|
|
684
630
|
}
|
|
631
|
+
if (this.FirmwareRevision === undefined) {
|
|
632
|
+
this.FirmwareRevision = this.platform.version;
|
|
633
|
+
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
634
|
+
}
|
|
685
635
|
}
|
|
686
636
|
|
|
687
637
|
async refreshRate(device: device & devicesConfig): Promise<void> {
|
package/src/device/lightstrip.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable brace-style */
|
|
2
|
-
import { Context } from 'vm';
|
|
3
1
|
import { request } from 'undici';
|
|
4
2
|
import { sleep } from '../utils';
|
|
5
3
|
import { interval, Subject } from 'rxjs';
|
|
@@ -86,20 +84,8 @@ export class StripLight {
|
|
|
86
84
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
87
85
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
88
86
|
.setCharacteristic(this.platform.Characteristic.Model, 'W1701100')
|
|
89
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId
|
|
90
|
-
|
|
91
|
-
if (accessory.context.FirmwareRevision) {
|
|
92
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
93
|
-
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
|
|
94
|
-
accessory
|
|
95
|
-
.getService(this.platform.Service.AccessoryInformation)!
|
|
96
|
-
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
97
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
98
|
-
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
99
|
-
.updateValue(accessory.context.FirmwareRevision);
|
|
100
|
-
} else {
|
|
101
|
-
this.setFirmwareRevision(accessory, device);
|
|
102
|
-
}
|
|
87
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
|
|
88
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
|
|
103
89
|
|
|
104
90
|
// get the Lightbulb service if it exists, otherwise create a new Lightbulb service
|
|
105
91
|
// you can create multiple services for each accessory
|
|
@@ -289,6 +275,7 @@ export class StripLight {
|
|
|
289
275
|
|
|
290
276
|
// FirmwareRevision
|
|
291
277
|
this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
|
|
278
|
+
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
292
279
|
}
|
|
293
280
|
|
|
294
281
|
/**
|
|
@@ -419,9 +406,9 @@ export class StripLight {
|
|
|
419
406
|
async pushChanges(): Promise<void> {
|
|
420
407
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
421
408
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
|
|
422
|
-
}
|
|
423
|
-
await this.BLEpushChanges()
|
|
424
|
-
} else
|
|
409
|
+
/* }else if (this.BLE) {
|
|
410
|
+
await this.BLEpushChanges();*/
|
|
411
|
+
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
425
412
|
await this.openAPIpushChanges();
|
|
426
413
|
} else {
|
|
427
414
|
await this.offlineOff();
|
|
@@ -870,15 +857,6 @@ export class StripLight {
|
|
|
870
857
|
this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Saturation, this.Saturation);
|
|
871
858
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Saturation: ${this.Saturation}`);
|
|
872
859
|
}
|
|
873
|
-
// FirmwareRevision
|
|
874
|
-
if (this.FirmwareRevision === undefined) {
|
|
875
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
|
|
876
|
-
} else {
|
|
877
|
-
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
878
|
-
this.lightBulbService.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
879
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
880
|
-
+ `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
|
|
881
|
-
}
|
|
882
860
|
}
|
|
883
861
|
|
|
884
862
|
async stopScanning(switchbot: any) {
|
|
@@ -1034,32 +1012,6 @@ export class StripLight {
|
|
|
1034
1012
|
this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Saturation, e);
|
|
1035
1013
|
}
|
|
1036
1014
|
|
|
1037
|
-
async setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig) {
|
|
1038
|
-
await this.refreshStatus();
|
|
1039
|
-
if (device.firmware) {
|
|
1040
|
-
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
1041
|
-
accessory.context.FirmwareRevision = device.firmware;
|
|
1042
|
-
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
1043
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
1044
|
-
} else if (device.version) {
|
|
1045
|
-
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version: ${device.version}`);
|
|
1046
|
-
accessory.context.FirmwareRevision = device.version;
|
|
1047
|
-
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
1048
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
1049
|
-
} else {
|
|
1050
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
1051
|
-
accessory.context.FirmwareRevision = this.platform.version;
|
|
1052
|
-
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
1053
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
1054
|
-
}
|
|
1055
|
-
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
|
|
1056
|
-
accessory
|
|
1057
|
-
.getService(this.platform.Service.AccessoryInformation)!
|
|
1058
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
1059
|
-
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
1060
|
-
.updateValue(this.FirmwareRevision);
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1063
1015
|
async context() {
|
|
1064
1016
|
if (this.On === undefined) {
|
|
1065
1017
|
this.On = false;
|
|
@@ -1088,6 +1040,10 @@ export class StripLight {
|
|
|
1088
1040
|
}
|
|
1089
1041
|
this.minKelvin = 2000;
|
|
1090
1042
|
this.maxKelvin = 9000;
|
|
1043
|
+
if (this.FirmwareRevision === undefined) {
|
|
1044
|
+
this.FirmwareRevision = this.platform.version;
|
|
1045
|
+
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
1046
|
+
}
|
|
1091
1047
|
}
|
|
1092
1048
|
|
|
1093
1049
|
async refreshRate(device: device & devicesConfig): Promise<void> {
|
package/src/device/lock.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable brace-style */
|
|
2
|
-
import { Context } from 'vm';
|
|
3
1
|
import { request } from 'undici';
|
|
4
2
|
import { sleep } from '../utils';
|
|
5
3
|
import { interval, Subject } from 'rxjs';
|
|
@@ -74,20 +72,8 @@ export class Lock {
|
|
|
74
72
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
75
73
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
76
74
|
.setCharacteristic(this.platform.Characteristic.Model, 'W1601700')
|
|
77
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId
|
|
78
|
-
|
|
79
|
-
if (accessory.context.FirmwareRevision) {
|
|
80
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName}`
|
|
81
|
-
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
|
|
82
|
-
accessory
|
|
83
|
-
.getService(this.platform.Service.AccessoryInformation)!
|
|
84
|
-
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
85
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
86
|
-
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
87
|
-
.updateValue(accessory.context.FirmwareRevision);
|
|
88
|
-
} else {
|
|
89
|
-
this.setFirmwareRevision(accessory, device);
|
|
90
|
-
}
|
|
75
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId)
|
|
76
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
|
|
91
77
|
|
|
92
78
|
// get the LockMechanism service if it exists, otherwise create a new LockMechanism service
|
|
93
79
|
// you can create multiple services for each accessory
|
|
@@ -173,9 +159,9 @@ export class Lock {
|
|
|
173
159
|
async parseStatus(): Promise<void> {
|
|
174
160
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
175
161
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} parseStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
176
|
-
}
|
|
177
|
-
await this.BLEparseStatus()
|
|
178
|
-
} else
|
|
162
|
+
/* } else if (this.BLE) {
|
|
163
|
+
await this.BLEparseStatus();*/
|
|
164
|
+
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
179
165
|
await this.openAPIparseStatus();
|
|
180
166
|
} else {
|
|
181
167
|
await this.offlineOff();
|
|
@@ -251,6 +237,7 @@ export class Lock {
|
|
|
251
237
|
|
|
252
238
|
// FirmwareRevision
|
|
253
239
|
this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
|
|
240
|
+
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
254
241
|
}
|
|
255
242
|
|
|
256
243
|
/**
|
|
@@ -380,9 +367,9 @@ export class Lock {
|
|
|
380
367
|
async pushChanges(): Promise<void> {
|
|
381
368
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
382
369
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
|
|
383
|
-
}
|
|
384
|
-
await this.BLEpushChanges()
|
|
385
|
-
} else
|
|
370
|
+
/*} else if (this.BLE) {
|
|
371
|
+
await this.BLEpushChanges();*/
|
|
372
|
+
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
386
373
|
await this.openAPIpushChanges();
|
|
387
374
|
} else {
|
|
388
375
|
await this.offlineOff();
|
|
@@ -542,20 +529,6 @@ export class Lock {
|
|
|
542
529
|
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
|
|
543
530
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
|
|
544
531
|
}
|
|
545
|
-
|
|
546
|
-
// FirmwareRevision
|
|
547
|
-
if (this.FirmwareRevision === undefined) {
|
|
548
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} FirmwareRevision: ${this.FirmwareRevision}`);
|
|
549
|
-
} else {
|
|
550
|
-
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
551
|
-
this.lockService.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
552
|
-
this.batteryService.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
553
|
-
if (this.device.lock?.hide_contactsensor) {
|
|
554
|
-
this.contactSensorService!.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.FirmwareRevision);
|
|
555
|
-
}
|
|
556
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
557
|
-
+ `updateCharacteristic FirmwareRevision: ${this.FirmwareRevision}`);
|
|
558
|
-
}
|
|
559
532
|
}
|
|
560
533
|
|
|
561
534
|
async stopScanning(switchbot: any) {
|
|
@@ -672,38 +645,16 @@ export class Lock {
|
|
|
672
645
|
this.lockService.updateCharacteristic(this.platform.Characteristic.LockCurrentState, e);
|
|
673
646
|
}
|
|
674
647
|
|
|
675
|
-
async setFirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig) {
|
|
676
|
-
await this.refreshStatus();
|
|
677
|
-
if (device.firmware) {
|
|
678
|
-
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
679
|
-
accessory.context.FirmwareRevision = device.firmware;
|
|
680
|
-
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
681
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
682
|
-
} else if (device.version) {
|
|
683
|
-
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version: ${device.version}`);
|
|
684
|
-
accessory.context.FirmwareRevision = device.version;
|
|
685
|
-
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
686
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} device.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
687
|
-
} else {
|
|
688
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
689
|
-
accessory.context.FirmwareRevision = this.platform.version;
|
|
690
|
-
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
691
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
692
|
-
}
|
|
693
|
-
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
|
|
694
|
-
accessory
|
|
695
|
-
.getService(this.platform.Service.AccessoryInformation)!
|
|
696
|
-
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
697
|
-
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
698
|
-
.updateValue(this.FirmwareRevision);
|
|
699
|
-
}
|
|
700
|
-
|
|
701
648
|
async context() {
|
|
702
649
|
if (this.LockTargetState === undefined) {
|
|
703
650
|
this.LockTargetState = false;
|
|
704
651
|
} else {
|
|
705
652
|
this.LockTargetState = this.accessory.context.On;
|
|
706
653
|
}
|
|
654
|
+
if (this.FirmwareRevision === undefined) {
|
|
655
|
+
this.FirmwareRevision = this.platform.version;
|
|
656
|
+
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
657
|
+
}
|
|
707
658
|
}
|
|
708
659
|
|
|
709
660
|
async refreshRate(device: device & devicesConfig): Promise<void> {
|