@switchbot/homebridge-switchbot 1.8.0 → 1.8.1-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/devices/bots.d.ts +15 -15
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +162 -159
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.d.ts +5 -5
- package/dist/devices/colorbulb.d.ts.map +1 -1
- package/dist/devices/colorbulb.js +69 -66
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.d.ts +8 -8
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +81 -78
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +7 -7
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +105 -113
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.d.ts +5 -5
- package/dist/devices/humidifiers.d.ts.map +1 -1
- package/dist/devices/humidifiers.js +75 -79
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/meters.d.ts +4 -4
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +63 -60
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +6 -6
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +81 -78
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.d.ts +4 -4
- package/dist/devices/plugs.d.ts.map +1 -1
- package/dist/devices/plugs.js +63 -60
- package/dist/devices/plugs.js.map +1 -1
- package/dist/irdevices/airconditioners.d.ts +2 -2
- package/dist/irdevices/airconditioners.d.ts.map +1 -1
- package/dist/irdevices/airconditioners.js +30 -27
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.d.ts +2 -2
- package/dist/irdevices/airpurifiers.d.ts.map +1 -1
- package/dist/irdevices/airpurifiers.js +30 -27
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.d.ts +2 -2
- package/dist/irdevices/cameras.d.ts.map +1 -1
- package/dist/irdevices/cameras.js +30 -27
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.d.ts +2 -2
- package/dist/irdevices/fans.d.ts.map +1 -1
- package/dist/irdevices/fans.js +30 -27
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.d.ts +2 -2
- package/dist/irdevices/lights.d.ts.map +1 -1
- package/dist/irdevices/lights.js +30 -27
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.d.ts +3 -3
- package/dist/irdevices/others.d.ts.map +1 -1
- package/dist/irdevices/others.js +41 -38
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.d.ts +2 -2
- package/dist/irdevices/tvs.d.ts.map +1 -1
- package/dist/irdevices/tvs.js +30 -27
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts +2 -2
- package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.js +30 -27
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.d.ts +2 -2
- package/dist/irdevices/waterheaters.d.ts.map +1 -1
- package/dist/irdevices/waterheaters.js +30 -27
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/package.json +71 -71
- package/src/devices/bots.ts +169 -166
- package/src/devices/colorbulb.ts +68 -65
- package/src/devices/contact.ts +82 -79
- package/src/devices/curtains.ts +103 -111
- package/src/devices/humidifiers.ts +74 -78
- package/src/devices/meters.ts +62 -59
- package/src/devices/motion.ts +80 -77
- package/src/devices/plugs.ts +62 -59
- package/src/irdevices/airconditioners.ts +29 -26
- package/src/irdevices/airpurifiers.ts +29 -26
- package/src/irdevices/cameras.ts +29 -26
- package/src/irdevices/fans.ts +29 -26
- package/src/irdevices/lights.ts +29 -26
- package/src/irdevices/others.ts +40 -37
- package/src/irdevices/tvs.ts +29 -26
- package/src/irdevices/vacuumcleaners.ts +29 -26
- package/src/irdevices/waterheaters.ts +29 -26
package/src/devices/curtains.ts
CHANGED
|
@@ -60,10 +60,10 @@ export class Curtain {
|
|
|
60
60
|
public device: device & devicesConfig,
|
|
61
61
|
) {
|
|
62
62
|
// default placeholders
|
|
63
|
-
this.logs();
|
|
64
|
-
this.scan();
|
|
63
|
+
this.logs(device);
|
|
64
|
+
this.scan(device);
|
|
65
65
|
this.setMinMax();
|
|
66
|
-
this.refreshRate();
|
|
66
|
+
this.refreshRate(device);
|
|
67
67
|
this.config(device);
|
|
68
68
|
this.CurrentPosition = 0;
|
|
69
69
|
this.TargetPosition = 0;
|
|
@@ -107,7 +107,7 @@ export class Curtain {
|
|
|
107
107
|
this.service
|
|
108
108
|
.getCharacteristic(this.platform.Characteristic.CurrentPosition)
|
|
109
109
|
.setProps({
|
|
110
|
-
minStep: this.minStep(),
|
|
110
|
+
minStep: this.minStep(device),
|
|
111
111
|
minValue: 0,
|
|
112
112
|
maxValue: 100,
|
|
113
113
|
validValueRanges: [0, 100],
|
|
@@ -119,7 +119,7 @@ export class Curtain {
|
|
|
119
119
|
this.service
|
|
120
120
|
.getCharacteristic(this.platform.Characteristic.TargetPosition)
|
|
121
121
|
.setProps({
|
|
122
|
-
minStep: this.minStep(),
|
|
122
|
+
minStep: this.minStep(device),
|
|
123
123
|
validValueRanges: [0, 100],
|
|
124
124
|
})
|
|
125
125
|
.onSet(this.TargetPositionSet.bind(this));
|
|
@@ -209,112 +209,6 @@ export class Curtain {
|
|
|
209
209
|
});
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
config(device: device & devicesConfig) {
|
|
213
|
-
const config: any = device.curtain;
|
|
214
|
-
if (device.ble !== undefined) {
|
|
215
|
-
config['ble'] = device.ble;
|
|
216
|
-
}
|
|
217
|
-
if (device.logging !== undefined) {
|
|
218
|
-
config['logging'] = device.logging;
|
|
219
|
-
}
|
|
220
|
-
if (device.refreshRate !== undefined) {
|
|
221
|
-
config['refreshRate'] = device.refreshRate;
|
|
222
|
-
}
|
|
223
|
-
if (device.scanDuration !== undefined) {
|
|
224
|
-
config['scanDuration'] = device.scanDuration;
|
|
225
|
-
}
|
|
226
|
-
if (config !== undefined) {
|
|
227
|
-
this.warnLog(`Curtain: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
refreshRate() {
|
|
232
|
-
// refreshRate
|
|
233
|
-
if (this.device.refreshRate) {
|
|
234
|
-
this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
|
|
235
|
-
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
236
|
-
this.warnLog(`Curtain: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
237
|
-
}
|
|
238
|
-
} else if (this.platform.config.options!.refreshRate) {
|
|
239
|
-
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
|
|
240
|
-
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
241
|
-
this.warnLog(`Curtain: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
// updateRate
|
|
245
|
-
if (this.device?.curtain?.updateRate) {
|
|
246
|
-
this.updateRate = this.device?.curtain?.updateRate;
|
|
247
|
-
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
248
|
-
this.warnLog(`Curtain: ${this.accessory.displayName} Using Device Config Curtain refreshRate: ${this.deviceRefreshRate}`);
|
|
249
|
-
}
|
|
250
|
-
} else {
|
|
251
|
-
this.updateRate = 5;
|
|
252
|
-
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
253
|
-
this.warnLog(`Curtain: ${this.accessory.displayName} Using Default Curtain Refresh Rate.`);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
scan() {
|
|
259
|
-
if (this.device.scanDuration) {
|
|
260
|
-
this.scanDuration = this.accessory.context.scanDuration = this.device.scanDuration;
|
|
261
|
-
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
262
|
-
this.warnLog(`Curtain: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
263
|
-
}
|
|
264
|
-
} else {
|
|
265
|
-
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
266
|
-
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
267
|
-
this.warnLog(`Curtain: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
logs() {
|
|
273
|
-
if (this.platform.debugMode) {
|
|
274
|
-
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
275
|
-
this.warnLog(`Curtain: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
276
|
-
} else if (this.device.logging) {
|
|
277
|
-
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
278
|
-
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
279
|
-
this.warnLog(`Curtain: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
280
|
-
}
|
|
281
|
-
} else if (this.platform.config.options?.logging) {
|
|
282
|
-
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
283
|
-
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
284
|
-
this.warnLog(`Curtain: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
285
|
-
}
|
|
286
|
-
} else {
|
|
287
|
-
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
private minStep(): number {
|
|
292
|
-
if (this.device.curtain?.set_minStep) {
|
|
293
|
-
this.set_minStep = this.device.curtain?.set_minStep;
|
|
294
|
-
} else {
|
|
295
|
-
this.set_minStep = 1;
|
|
296
|
-
}
|
|
297
|
-
return this.set_minStep;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
private minLux(): number {
|
|
301
|
-
if (this.device.curtain?.set_minLux) {
|
|
302
|
-
this.set_minLux = this.device.curtain?.set_minLux;
|
|
303
|
-
} else {
|
|
304
|
-
this.set_minLux = 1;
|
|
305
|
-
}
|
|
306
|
-
return this.set_minLux;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
private maxLux(): number {
|
|
310
|
-
if (this.device.curtain?.set_maxLux) {
|
|
311
|
-
this.set_maxLux = this.device.curtain?.set_maxLux;
|
|
312
|
-
} else {
|
|
313
|
-
this.set_maxLux = 6001;
|
|
314
|
-
}
|
|
315
|
-
return this.set_maxLux;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
212
|
/**
|
|
319
213
|
* Parse the device status from the SwitchBot api
|
|
320
214
|
*/
|
|
@@ -823,6 +717,104 @@ export class Curtain {
|
|
|
823
717
|
}
|
|
824
718
|
}
|
|
825
719
|
|
|
720
|
+
config(device: device & devicesConfig) {
|
|
721
|
+
let config = {};
|
|
722
|
+
if (device.curtain) {
|
|
723
|
+
config = device.curtain;
|
|
724
|
+
}
|
|
725
|
+
if (device.ble) {
|
|
726
|
+
config['ble'] = device.ble;
|
|
727
|
+
}
|
|
728
|
+
if (device.logging !== undefined) {
|
|
729
|
+
config['logging'] = device.logging;
|
|
730
|
+
}
|
|
731
|
+
if (device.refreshRate !== undefined) {
|
|
732
|
+
config['refreshRate'] = device.refreshRate;
|
|
733
|
+
}
|
|
734
|
+
if (device.scanDuration !== undefined) {
|
|
735
|
+
config['scanDuration'] = device.scanDuration;
|
|
736
|
+
}
|
|
737
|
+
if (config !== undefined) {
|
|
738
|
+
this.warnLog(`Curtain: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
refreshRate(device: device & devicesConfig) {
|
|
743
|
+
// refreshRate
|
|
744
|
+
if (device.refreshRate) {
|
|
745
|
+
this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
|
|
746
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
747
|
+
} else if (this.platform.config.options!.refreshRate) {
|
|
748
|
+
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
|
|
749
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
750
|
+
}
|
|
751
|
+
// updateRate
|
|
752
|
+
if (device?.curtain?.updateRate) {
|
|
753
|
+
this.updateRate = device?.curtain?.updateRate;
|
|
754
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} Using Device Config Curtain refreshRate: ${this.deviceRefreshRate}`);
|
|
755
|
+
} else {
|
|
756
|
+
this.updateRate = 5;
|
|
757
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} Using Default Curtain Refresh Rate.`);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
scan(device: device & devicesConfig) {
|
|
762
|
+
if (device.scanDuration) {
|
|
763
|
+
this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
|
|
764
|
+
if (device.ble) {
|
|
765
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
766
|
+
}
|
|
767
|
+
} else {
|
|
768
|
+
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
769
|
+
if (this.device.ble) {
|
|
770
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
logs(device: device & devicesConfig) {
|
|
776
|
+
if (this.platform.debugMode) {
|
|
777
|
+
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
778
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
779
|
+
} else if (device.logging) {
|
|
780
|
+
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
781
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
782
|
+
} else if (this.platform.config.options?.logging) {
|
|
783
|
+
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
784
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
785
|
+
} else {
|
|
786
|
+
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
787
|
+
this.debugLog(`Curtain: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
private minStep(device: device & devicesConfig): number {
|
|
792
|
+
if (device.curtain?.set_minStep) {
|
|
793
|
+
this.set_minStep = device.curtain?.set_minStep;
|
|
794
|
+
} else {
|
|
795
|
+
this.set_minStep = 1;
|
|
796
|
+
}
|
|
797
|
+
return this.set_minStep;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
private minLux(): number {
|
|
801
|
+
if (this.device.curtain?.set_minLux) {
|
|
802
|
+
this.set_minLux = this.device.curtain?.set_minLux;
|
|
803
|
+
} else {
|
|
804
|
+
this.set_minLux = 1;
|
|
805
|
+
}
|
|
806
|
+
return this.set_minLux;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
private maxLux(): number {
|
|
810
|
+
if (this.device.curtain?.set_maxLux) {
|
|
811
|
+
this.set_maxLux = this.device.curtain?.set_maxLux;
|
|
812
|
+
} else {
|
|
813
|
+
this.set_maxLux = 6001;
|
|
814
|
+
}
|
|
815
|
+
return this.set_maxLux;
|
|
816
|
+
}
|
|
817
|
+
|
|
826
818
|
/**
|
|
827
819
|
* Logging for Device
|
|
828
820
|
*/
|
|
@@ -56,9 +56,9 @@ export class Humidifier {
|
|
|
56
56
|
public device: device & devicesConfig,
|
|
57
57
|
) {
|
|
58
58
|
// default placeholders
|
|
59
|
-
this.logs();
|
|
60
|
-
this.scan();
|
|
61
|
-
this.refreshRate();
|
|
59
|
+
this.logs(device);
|
|
60
|
+
this.scan(device);
|
|
61
|
+
this.refreshRate(device);
|
|
62
62
|
this.config(device);
|
|
63
63
|
this.CurrentRelativeHumidity = 0;
|
|
64
64
|
this.TargetHumidifierDehumidifierState = this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER;
|
|
@@ -198,81 +198,6 @@ export class Humidifier {
|
|
|
198
198
|
});
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
config(device: device & devicesConfig) {
|
|
202
|
-
const config: any = device.humidifier;
|
|
203
|
-
if (device.ble !== undefined) {
|
|
204
|
-
config['ble'] = device.ble;
|
|
205
|
-
}
|
|
206
|
-
if (device.logging !== undefined) {
|
|
207
|
-
config['logging'] = device.logging;
|
|
208
|
-
}
|
|
209
|
-
if (device.refreshRate !== undefined) {
|
|
210
|
-
config['refreshRate'] = device.refreshRate;
|
|
211
|
-
}
|
|
212
|
-
if (device.scanDuration !== undefined) {
|
|
213
|
-
config['scanDuration'] = device.scanDuration;
|
|
214
|
-
}
|
|
215
|
-
if (config !== undefined) {
|
|
216
|
-
this.warnLog(`Humidifier: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
refreshRate() {
|
|
221
|
-
if (this.device.refreshRate) {
|
|
222
|
-
this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
|
|
223
|
-
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
224
|
-
this.warnLog(`Humidifier: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
225
|
-
}
|
|
226
|
-
} else if (this.platform.config.options!.refreshRate) {
|
|
227
|
-
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
|
|
228
|
-
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
229
|
-
this.warnLog(`Humidifier: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
scan() {
|
|
235
|
-
if (this.device.scanDuration) {
|
|
236
|
-
this.scanDuration = this.accessory.context.scanDuration = this.device.scanDuration;
|
|
237
|
-
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
238
|
-
this.warnLog(`Humidifier: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
239
|
-
}
|
|
240
|
-
} else {
|
|
241
|
-
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
242
|
-
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
243
|
-
this.warnLog(`Humidifier: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
logs() {
|
|
249
|
-
if (this.platform.debugMode) {
|
|
250
|
-
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
251
|
-
this.warnLog(`Humidifier: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
252
|
-
} else if (this.device.logging) {
|
|
253
|
-
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
254
|
-
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
255
|
-
this.warnLog(`Humidifier: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
256
|
-
}
|
|
257
|
-
} else if (this.platform.config.options?.logging) {
|
|
258
|
-
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
259
|
-
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
260
|
-
this.warnLog(`Humidifier: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
261
|
-
}
|
|
262
|
-
} else {
|
|
263
|
-
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
private minStep(): number | undefined {
|
|
268
|
-
if (this.device.humidifier?.set_minStep) {
|
|
269
|
-
this.set_minStep = this.device.humidifier?.set_minStep;
|
|
270
|
-
} else {
|
|
271
|
-
this.set_minStep = 1;
|
|
272
|
-
}
|
|
273
|
-
return this.set_minStep;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
201
|
/**
|
|
277
202
|
* Parse the device status from the SwitchBot api
|
|
278
203
|
*/
|
|
@@ -786,6 +711,77 @@ export class Humidifier {
|
|
|
786
711
|
this.doHumidifierUpdate.next();
|
|
787
712
|
}
|
|
788
713
|
|
|
714
|
+
config(device: device & devicesConfig) {
|
|
715
|
+
let config = {};
|
|
716
|
+
if (device.humidifier) {
|
|
717
|
+
config = device.humidifier;
|
|
718
|
+
}
|
|
719
|
+
if (device.ble !== undefined) {
|
|
720
|
+
config['ble'] = device.ble;
|
|
721
|
+
}
|
|
722
|
+
if (device.logging !== undefined) {
|
|
723
|
+
config['logging'] = device.logging;
|
|
724
|
+
}
|
|
725
|
+
if (device.refreshRate !== undefined) {
|
|
726
|
+
config['refreshRate'] = device.refreshRate;
|
|
727
|
+
}
|
|
728
|
+
if (device.scanDuration !== undefined) {
|
|
729
|
+
config['scanDuration'] = device.scanDuration;
|
|
730
|
+
}
|
|
731
|
+
if (config !== undefined) {
|
|
732
|
+
this.warnLog(`Humidifier: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
refreshRate(device: device & devicesConfig) {
|
|
737
|
+
if (device.refreshRate) {
|
|
738
|
+
this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
|
|
739
|
+
this.debugLog(`Humidifier: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
740
|
+
} else if (this.platform.config.options!.refreshRate) {
|
|
741
|
+
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
|
|
742
|
+
this.debugLog(`Humidifier: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
scan(device: device & devicesConfig) {
|
|
747
|
+
if (device.scanDuration) {
|
|
748
|
+
this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
|
|
749
|
+
if (device.ble) {
|
|
750
|
+
this.debugLog(`Humidifier: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
751
|
+
}
|
|
752
|
+
} else {
|
|
753
|
+
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
754
|
+
if (this.device.ble) {
|
|
755
|
+
this.debugLog(`Humidifier: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
logs(device: device & devicesConfig) {
|
|
761
|
+
if (this.platform.debugMode) {
|
|
762
|
+
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
763
|
+
this.debugLog(`Humidifier: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
764
|
+
} else if (device.logging) {
|
|
765
|
+
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
766
|
+
this.debugLog(`Humidifier: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
767
|
+
} else if (this.platform.config.options?.logging) {
|
|
768
|
+
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
769
|
+
this.debugLog(`Humidifier: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
770
|
+
} else {
|
|
771
|
+
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
772
|
+
this.debugLog(`Humidifier: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
private minStep(): number | undefined {
|
|
777
|
+
if (this.device.humidifier?.set_minStep) {
|
|
778
|
+
this.set_minStep = this.device.humidifier?.set_minStep;
|
|
779
|
+
} else {
|
|
780
|
+
this.set_minStep = 1;
|
|
781
|
+
}
|
|
782
|
+
return this.set_minStep;
|
|
783
|
+
}
|
|
784
|
+
|
|
789
785
|
/**
|
|
790
786
|
* Logging for Device
|
|
791
787
|
*/
|
package/src/devices/meters.ts
CHANGED
|
@@ -174,65 +174,6 @@ export class Meter {
|
|
|
174
174
|
});
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
config(device: device & devicesConfig) {
|
|
178
|
-
const config: any = device.meter;
|
|
179
|
-
if (device.ble !== undefined) {
|
|
180
|
-
config['ble'] = device.ble;
|
|
181
|
-
}
|
|
182
|
-
if (device.logging !== undefined) {
|
|
183
|
-
config['logging'] = device.logging;
|
|
184
|
-
}
|
|
185
|
-
if (device.refreshRate !== undefined) {
|
|
186
|
-
config['refreshRate'] = device.refreshRate;
|
|
187
|
-
}
|
|
188
|
-
if (device.scanDuration !== undefined) {
|
|
189
|
-
config['scanDuration'] = device.scanDuration;
|
|
190
|
-
}
|
|
191
|
-
if (config !== undefined) {
|
|
192
|
-
this.warnLog(`Meter: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
refreshRate(device: device & devicesConfig) {
|
|
197
|
-
if (device.refreshRate) {
|
|
198
|
-
this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
|
|
199
|
-
this.debugLog(`Meter: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
200
|
-
} else if (this.platform.config.options!.refreshRate) {
|
|
201
|
-
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
|
|
202
|
-
this.debugLog(`Meter: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
scan(device: device & devicesConfig) {
|
|
207
|
-
if (device.scanDuration) {
|
|
208
|
-
this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
|
|
209
|
-
if (device.ble) {
|
|
210
|
-
this.debugLog(`Meter: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
211
|
-
}
|
|
212
|
-
} else {
|
|
213
|
-
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
214
|
-
if (this.device.ble) {
|
|
215
|
-
this.debugLog(`Meter: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
logs(device: device & devicesConfig) {
|
|
221
|
-
if (this.platform.debugMode) {
|
|
222
|
-
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
223
|
-
this.debugLog(`Meter: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
224
|
-
} else if (device.logging) {
|
|
225
|
-
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
226
|
-
this.debugLog(`Meter: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
227
|
-
} else if (this.platform.config.options?.logging) {
|
|
228
|
-
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
229
|
-
this.debugLog(`Meter: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
230
|
-
} else {
|
|
231
|
-
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
232
|
-
this.debugLog(`Meter: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
177
|
/**
|
|
237
178
|
* Parse the device status from the SwitchBot api
|
|
238
179
|
*/
|
|
@@ -449,6 +390,68 @@ export class Meter {
|
|
|
449
390
|
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
450
391
|
}
|
|
451
392
|
|
|
393
|
+
config(device: device & devicesConfig) {
|
|
394
|
+
let config = {};
|
|
395
|
+
if (device.meter) {
|
|
396
|
+
config = device.meter;
|
|
397
|
+
}
|
|
398
|
+
if (device.ble !== undefined) {
|
|
399
|
+
config['ble'] = device.ble;
|
|
400
|
+
}
|
|
401
|
+
if (device.logging !== undefined) {
|
|
402
|
+
config['logging'] = device.logging;
|
|
403
|
+
}
|
|
404
|
+
if (device.refreshRate !== undefined) {
|
|
405
|
+
config['refreshRate'] = device.refreshRate;
|
|
406
|
+
}
|
|
407
|
+
if (device.scanDuration !== undefined) {
|
|
408
|
+
config['scanDuration'] = device.scanDuration;
|
|
409
|
+
}
|
|
410
|
+
if (config !== undefined) {
|
|
411
|
+
this.warnLog(`Meter: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
refreshRate(device: device & devicesConfig) {
|
|
416
|
+
if (device.refreshRate) {
|
|
417
|
+
this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
|
|
418
|
+
this.debugLog(`Meter: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
419
|
+
} else if (this.platform.config.options!.refreshRate) {
|
|
420
|
+
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
|
|
421
|
+
this.debugLog(`Meter: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
scan(device: device & devicesConfig) {
|
|
426
|
+
if (device.scanDuration) {
|
|
427
|
+
this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
|
|
428
|
+
if (device.ble) {
|
|
429
|
+
this.debugLog(`Meter: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
|
|
430
|
+
}
|
|
431
|
+
} else {
|
|
432
|
+
this.scanDuration = this.accessory.context.scanDuration = 1;
|
|
433
|
+
if (this.device.ble) {
|
|
434
|
+
this.debugLog(`Meter: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
logs(device: device & devicesConfig) {
|
|
440
|
+
if (this.platform.debugMode) {
|
|
441
|
+
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
442
|
+
this.debugLog(`Meter: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
443
|
+
} else if (device.logging) {
|
|
444
|
+
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
445
|
+
this.debugLog(`Meter: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
446
|
+
} else if (this.platform.config.options?.logging) {
|
|
447
|
+
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
448
|
+
this.debugLog(`Meter: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
449
|
+
} else {
|
|
450
|
+
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
451
|
+
this.debugLog(`Meter: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
452
455
|
/**
|
|
453
456
|
* Logging for Device
|
|
454
457
|
*/
|