@switchbot/homebridge-switchbot 2.9.1-beta.3 → 2.9.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/.eslintrc +47 -14
- package/.vscode/settings.json +7 -1
- package/CHANGELOG.md +79 -70
- package/SECURITY.md +2 -2
- package/config.schema.json +348 -114
- package/dist/device/blindtilt.d.ts +0 -3
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +13 -62
- 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 +49 -116
- 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 +17 -60
- 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 +13 -56
- 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 +19 -69
- 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 +16 -66
- 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 +16 -69
- 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 +16 -63
- 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 +16 -65
- 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 +13 -56
- 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 +22 -68
- 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 +16 -68
- 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 +16 -69
- 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 +12 -62
- 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 +6 -53
- 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 +18 -65
- 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 +9 -47
- 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 +9 -47
- 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 +9 -47
- 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 +9 -47
- 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 +9 -47
- 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 +44 -77
- 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 +18 -56
- 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 +9 -47
- 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 +9 -47
- package/dist/irdevice/waterheater.js.map +1 -1
- package/nodemon.json +4 -2
- package/package.json +9 -14
- package/src/device/blindtilt.ts +14 -62
- package/src/device/bot.ts +51 -108
- package/src/device/ceilinglight.ts +17 -61
- package/src/device/colorbulb.ts +13 -56
- package/src/device/contact.ts +20 -69
- package/src/device/curtain.ts +17 -66
- package/src/device/hub.ts +16 -70
- package/src/device/humidifier.ts +16 -64
- package/src/device/iosensor.ts +17 -66
- package/src/device/lightstrip.ts +13 -56
- package/src/device/lock.ts +22 -69
- package/src/device/meter.ts +18 -69
- package/src/device/meterplus.ts +17 -70
- package/src/device/motion.ts +13 -62
- package/src/device/plug.ts +6 -52
- package/src/device/robotvacuumcleaner.ts +18 -65
- package/src/irdevice/airconditioner.ts +9 -46
- package/src/irdevice/airpurifier.ts +9 -48
- package/src/irdevice/camera.ts +9 -48
- package/src/irdevice/fan.ts +9 -48
- package/src/irdevice/light.ts +9 -48
- package/src/irdevice/other.ts +44 -78
- package/src/irdevice/tv.ts +18 -57
- package/src/irdevice/vacuumcleaner.ts +9 -48
- package/src/irdevice/waterheater.ts +9 -48
- package/tsconfig.json +16 -4
- package/.github/npm-version-script.js +0 -81
- package/.prettierrc +0 -9
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,26 +79,14 @@ 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
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
87
|
+
const humidifierService = `${accessory.displayName} Humidifier`;
|
|
88
|
+
(this.humidifierService = accessory.getService(this.platform.Service.HumidifierDehumidifier)
|
|
89
|
+
|| accessory.addService(this.platform.Service.HumidifierDehumidifier)), humidifierService;
|
|
104
90
|
|
|
105
91
|
this.humidifierService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
106
92
|
if (!this.humidifierService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -145,9 +131,9 @@ export class Humidifier {
|
|
|
145
131
|
accessory.removeService(this.temperatureservice!);
|
|
146
132
|
} else if (!this.temperatureservice && !this.BLE) {
|
|
147
133
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Temperature Sensor Service`);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
134
|
+
const temperatureservice = `${accessory.displayName} Temperature Sensor`;
|
|
135
|
+
(this.temperatureservice = this.accessory.getService(this.platform.Service.TemperatureSensor)
|
|
136
|
+
|| this.accessory.addService(this.platform.Service.TemperatureSensor)), temperatureservice;
|
|
151
137
|
|
|
152
138
|
this.temperatureservice.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Temperature Sensor`);
|
|
153
139
|
if (!this.temperatureservice.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -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
|
-
|
|
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) {
|
|
@@ -111,9 +98,9 @@ export class IOSensor {
|
|
|
111
98
|
accessory.removeService(this.temperatureservice!);
|
|
112
99
|
} else if (!this.temperatureservice) {
|
|
113
100
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Temperature Sensor Service`);
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
101
|
+
const temperatureservice = `${accessory.displayName} Temperature Sensor`;
|
|
102
|
+
(this.temperatureservice = this.accessory.getService(this.platform.Service.TemperatureSensor)
|
|
103
|
+
|| this.accessory.addService(this.platform.Service.TemperatureSensor)), temperatureservice;
|
|
117
104
|
|
|
118
105
|
this.temperatureservice.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Temperature Sensor`);
|
|
119
106
|
if (!this.temperatureservice.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -142,9 +129,9 @@ export class IOSensor {
|
|
|
142
129
|
accessory.removeService(this.humidityservice!);
|
|
143
130
|
} else if (!this.humidityservice) {
|
|
144
131
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Humidity Sensor Service`);
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
132
|
+
const humidityservice = `${accessory.displayName} Humidity Sensor`;
|
|
133
|
+
(this.humidityservice = this.accessory.getService(this.platform.Service.HumiditySensor)
|
|
134
|
+
|| this.accessory.addService(this.platform.Service.HumiditySensor)), humidityservice;
|
|
148
135
|
|
|
149
136
|
this.humidityservice.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Humidity Sensor`);
|
|
150
137
|
if (!this.humidityservice.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -163,8 +150,9 @@ export class IOSensor {
|
|
|
163
150
|
}
|
|
164
151
|
|
|
165
152
|
// Battery Service
|
|
166
|
-
|
|
167
|
-
|
|
153
|
+
const batteryService = `${accessory.displayName} Battery`;
|
|
154
|
+
(this.batteryService = this.accessory.getService(this.platform.Service.Battery)
|
|
155
|
+
|| accessory.addService(this.platform.Service.Battery)), batteryService;
|
|
168
156
|
|
|
169
157
|
this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
|
|
170
158
|
if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -261,10 +249,11 @@ export class IOSensor {
|
|
|
261
249
|
this.BatteryLevel = 100;
|
|
262
250
|
}
|
|
263
251
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel},`
|
|
264
|
-
|
|
252
|
+
+ ` StatusLowBattery: ${this.StatusLowBattery}`);
|
|
265
253
|
|
|
266
254
|
// FirmwareRevision
|
|
267
255
|
this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
|
|
256
|
+
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
268
257
|
}
|
|
269
258
|
|
|
270
259
|
/**
|
|
@@ -457,22 +446,6 @@ export class IOSensor {
|
|
|
457
446
|
this.historyService?.addEntry(entry);
|
|
458
447
|
}
|
|
459
448
|
}
|
|
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
449
|
}
|
|
477
450
|
|
|
478
451
|
/*
|
|
@@ -634,32 +607,6 @@ export class IOSensor {
|
|
|
634
607
|
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
|
|
635
608
|
}
|
|
636
609
|
|
|
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
610
|
async context() {
|
|
664
611
|
if (this.CurrentRelativeHumidity === undefined) {
|
|
665
612
|
this.CurrentRelativeHumidity = 0;
|
|
@@ -682,6 +629,10 @@ export class IOSensor {
|
|
|
682
629
|
} else {
|
|
683
630
|
this.StatusLowBattery = this.accessory.context.StatusLowBattery;
|
|
684
631
|
}
|
|
632
|
+
if (this.FirmwareRevision === undefined) {
|
|
633
|
+
this.FirmwareRevision = this.platform.version;
|
|
634
|
+
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
635
|
+
}
|
|
685
636
|
}
|
|
686
637
|
|
|
687
638
|
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,25 +84,14 @@ 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
|
|
106
|
-
|
|
107
|
-
|
|
92
|
+
const lightBulbService = `${accessory.displayName} ${device.deviceType}`;
|
|
93
|
+
(this.lightBulbService = accessory.getService(this.platform.Service.Lightbulb)
|
|
94
|
+
|| accessory.addService(this.platform.Service.Lightbulb)), lightBulbService;
|
|
108
95
|
|
|
109
96
|
if (this.adaptiveLightingShift === -1 && this.accessory.context.adaptiveLighting) {
|
|
110
97
|
this.accessory.removeService(this.lightBulbService);
|
|
@@ -289,6 +276,7 @@ export class StripLight {
|
|
|
289
276
|
|
|
290
277
|
// FirmwareRevision
|
|
291
278
|
this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
|
|
279
|
+
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
292
280
|
}
|
|
293
281
|
|
|
294
282
|
/**
|
|
@@ -419,9 +407,9 @@ export class StripLight {
|
|
|
419
407
|
async pushChanges(): Promise<void> {
|
|
420
408
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
421
409
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
} else
|
|
410
|
+
/* }else if (this.BLE) {
|
|
411
|
+
await this.BLEpushChanges();*/
|
|
412
|
+
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
425
413
|
await this.openAPIpushChanges();
|
|
426
414
|
} else {
|
|
427
415
|
await this.offlineOff();
|
|
@@ -870,15 +858,6 @@ export class StripLight {
|
|
|
870
858
|
this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Saturation, this.Saturation);
|
|
871
859
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Saturation: ${this.Saturation}`);
|
|
872
860
|
}
|
|
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
861
|
}
|
|
883
862
|
|
|
884
863
|
async stopScanning(switchbot: any) {
|
|
@@ -1034,32 +1013,6 @@ export class StripLight {
|
|
|
1034
1013
|
this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Saturation, e);
|
|
1035
1014
|
}
|
|
1036
1015
|
|
|
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
1016
|
async context() {
|
|
1064
1017
|
if (this.On === undefined) {
|
|
1065
1018
|
this.On = false;
|
|
@@ -1088,6 +1041,10 @@ export class StripLight {
|
|
|
1088
1041
|
}
|
|
1089
1042
|
this.minKelvin = 2000;
|
|
1090
1043
|
this.maxKelvin = 9000;
|
|
1044
|
+
if (this.FirmwareRevision === undefined) {
|
|
1045
|
+
this.FirmwareRevision = this.platform.version;
|
|
1046
|
+
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
1047
|
+
}
|
|
1091
1048
|
}
|
|
1092
1049
|
|
|
1093
1050
|
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,25 +72,14 @@ 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
|
|
94
|
-
|
|
95
|
-
|
|
80
|
+
const lockService = `${accessory.displayName} ${device.deviceType}`;
|
|
81
|
+
(this.lockService = accessory.getService(this.platform.Service.LockMechanism)
|
|
82
|
+
|| accessory.addService(this.platform.Service.LockMechanism)), lockService;
|
|
96
83
|
|
|
97
84
|
this.lockService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
98
85
|
if (!this.lockService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -112,9 +99,9 @@ export class Lock {
|
|
|
112
99
|
accessory.removeService(this.contactSensorService!);
|
|
113
100
|
} else if (!this.contactSensorService) {
|
|
114
101
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Contact Sensor Service`);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
102
|
+
const contactSensorService = `${accessory.displayName} Contact Sensor`;
|
|
103
|
+
(this.contactSensorService = this.accessory.getService(this.platform.Service.ContactSensor)
|
|
104
|
+
|| this.accessory.addService(this.platform.Service.ContactSensor)), contactSensorService;
|
|
118
105
|
|
|
119
106
|
this.contactSensorService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Contact Sensor`);
|
|
120
107
|
if (!this.contactSensorService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -125,8 +112,9 @@ export class Lock {
|
|
|
125
112
|
}
|
|
126
113
|
|
|
127
114
|
// Battery Service
|
|
128
|
-
|
|
129
|
-
|
|
115
|
+
const batteryService = `${accessory.displayName} Battery`;
|
|
116
|
+
(this.batteryService = this.accessory.getService(this.platform.Service.Battery)
|
|
117
|
+
|| accessory.addService(this.platform.Service.Battery)), batteryService;
|
|
130
118
|
|
|
131
119
|
this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
|
|
132
120
|
if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -173,9 +161,9 @@ export class Lock {
|
|
|
173
161
|
async parseStatus(): Promise<void> {
|
|
174
162
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
175
163
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} parseStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
} else
|
|
164
|
+
/* } else if (this.BLE) {
|
|
165
|
+
await this.BLEparseStatus();*/
|
|
166
|
+
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
179
167
|
await this.openAPIparseStatus();
|
|
180
168
|
} else {
|
|
181
169
|
await this.offlineOff();
|
|
@@ -251,6 +239,7 @@ export class Lock {
|
|
|
251
239
|
|
|
252
240
|
// FirmwareRevision
|
|
253
241
|
this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
|
|
242
|
+
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
254
243
|
}
|
|
255
244
|
|
|
256
245
|
/**
|
|
@@ -380,9 +369,9 @@ export class Lock {
|
|
|
380
369
|
async pushChanges(): Promise<void> {
|
|
381
370
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
382
371
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
} else
|
|
372
|
+
/*} else if (this.BLE) {
|
|
373
|
+
await this.BLEpushChanges();*/
|
|
374
|
+
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
386
375
|
await this.openAPIpushChanges();
|
|
387
376
|
} else {
|
|
388
377
|
await this.offlineOff();
|
|
@@ -542,20 +531,6 @@ export class Lock {
|
|
|
542
531
|
this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
|
|
543
532
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
|
|
544
533
|
}
|
|
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
534
|
}
|
|
560
535
|
|
|
561
536
|
async stopScanning(switchbot: any) {
|
|
@@ -672,38 +647,16 @@ export class Lock {
|
|
|
672
647
|
this.lockService.updateCharacteristic(this.platform.Characteristic.LockCurrentState, e);
|
|
673
648
|
}
|
|
674
649
|
|
|
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
650
|
async context() {
|
|
702
651
|
if (this.LockTargetState === undefined) {
|
|
703
652
|
this.LockTargetState = false;
|
|
704
653
|
} else {
|
|
705
654
|
this.LockTargetState = this.accessory.context.On;
|
|
706
655
|
}
|
|
656
|
+
if (this.FirmwareRevision === undefined) {
|
|
657
|
+
this.FirmwareRevision = this.platform.version;
|
|
658
|
+
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
659
|
+
}
|
|
707
660
|
}
|
|
708
661
|
|
|
709
662
|
async refreshRate(device: device & devicesConfig): Promise<void> {
|