@switchbot/homebridge-switchbot 2.5.3-beta.9 → 2.5.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/.github/ISSUE_TEMPLATE/bug-report.yml +7 -7
- package/CHANGELOG.md +13 -0
- package/config.schema.json +6 -2
- package/dist/device/blindtilt.d.ts +1 -1
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +15 -17
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +12 -14
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +10 -12
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +16 -18
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/curtain.d.ts +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +34 -37
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/humidifier.js +2 -2
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +94 -0
- package/dist/device/iosensor.d.ts.map +1 -0
- package/dist/device/iosensor.js +692 -0
- package/dist/device/iosensor.js.map +1 -0
- package/dist/device/meter.js +1 -1
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +1 -0
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +2 -1
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +7 -9
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +10 -12
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +10 -12
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/striplight.d.ts +1 -1
- package/dist/device/striplight.d.ts.map +1 -1
- package/dist/device/striplight.js +14 -16
- package/dist/device/striplight.js.map +1 -1
- package/dist/irdevice/airpurifier.js +1 -1
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/platform.d.ts +1 -0
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +58 -0
- package/dist/platform.js.map +1 -1
- package/homebridge-ui/public/index.html +1 -1
- package/package.json +13 -13
- package/src/device/blindtilt.ts +15 -17
- package/src/device/bot.ts +12 -14
- package/src/device/ceilinglight.ts +10 -12
- package/src/device/colorbulb.ts +16 -18
- package/src/device/curtain.ts +35 -39
- package/src/device/humidifier.ts +2 -2
- package/src/device/iosensor.ts +747 -0
- package/src/device/meter.ts +1 -1
- package/src/device/meterplus.ts +3 -1
- package/src/device/motion.ts +7 -9
- package/src/device/plug.ts +10 -12
- package/src/device/robotvacuumcleaner.ts +10 -12
- package/src/device/striplight.ts +14 -16
- package/src/irdevice/airpurifier.ts +1 -1
- package/src/platform.ts +61 -0
- package/src/settings.ts +3 -3
- package/.github/npm-version-script.js +0 -81
package/src/device/meter.ts
CHANGED
|
@@ -438,7 +438,7 @@ export class Meter {
|
|
|
438
438
|
if (this.device.mqttURL) {
|
|
439
439
|
this.mqttPublish(`{${mqttmessage.join(',')}}`);
|
|
440
440
|
}
|
|
441
|
-
if (this.CurrentRelativeHumidity > 0) {
|
|
441
|
+
if (Number(this.CurrentRelativeHumidity) > 0) {
|
|
442
442
|
// reject unreliable data
|
|
443
443
|
if (this.device.history) {
|
|
444
444
|
this.historyService?.addEntry(entry);
|
package/src/device/meterplus.ts
CHANGED
|
@@ -32,6 +32,7 @@ export class MeterPlus {
|
|
|
32
32
|
StatusLowBattery?: CharacteristicValue;
|
|
33
33
|
|
|
34
34
|
// OpenAPI Others
|
|
35
|
+
Battery: deviceStatus['battery'];
|
|
35
36
|
Temperature: deviceStatus['temperature'];
|
|
36
37
|
Humidity: deviceStatus['humidity'];
|
|
37
38
|
deviceStatus!: any; //deviceStatusResponse;
|
|
@@ -358,6 +359,7 @@ export class MeterPlus {
|
|
|
358
359
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus: ${superStringify(this.deviceStatus)}`);
|
|
359
360
|
this.Humidity = this.deviceStatus.body.humidity!;
|
|
360
361
|
this.Temperature = this.deviceStatus.body.temperature!;
|
|
362
|
+
this.Battery = this.deviceStatus.body.battery!;
|
|
361
363
|
this.parseStatus();
|
|
362
364
|
this.updateHomeKitCharacteristics();
|
|
363
365
|
} catch (e: any) {
|
|
@@ -438,7 +440,7 @@ export class MeterPlus {
|
|
|
438
440
|
if (this.device.mqttURL) {
|
|
439
441
|
this.mqttPublish(`{${mqttmessage.join(',')}}`);
|
|
440
442
|
}
|
|
441
|
-
if (this.CurrentRelativeHumidity > 0) {
|
|
443
|
+
if (Number(this.CurrentRelativeHumidity) > 0) {
|
|
442
444
|
// reject unreliable data
|
|
443
445
|
if (this.device.history) {
|
|
444
446
|
this.historyService?.addEntry(entry);
|
package/src/device/motion.ts
CHANGED
|
@@ -265,7 +265,7 @@ export class Motion {
|
|
|
265
265
|
})
|
|
266
266
|
.then(async () => {
|
|
267
267
|
return await this.retry({
|
|
268
|
-
max:
|
|
268
|
+
max: this.maxRetry(),
|
|
269
269
|
fn: async () => {
|
|
270
270
|
// Set an event hander
|
|
271
271
|
this.scanning = true;
|
|
@@ -456,25 +456,23 @@ export class Motion {
|
|
|
456
456
|
}
|
|
457
457
|
|
|
458
458
|
async retry({ max, fn }: { max: number; fn: { (): any; (): Promise<any> } }): Promise<null> {
|
|
459
|
-
return fn().catch(async (
|
|
459
|
+
return fn().catch(async (e: any) => {
|
|
460
460
|
if (max === 0) {
|
|
461
|
-
throw
|
|
461
|
+
throw e;
|
|
462
462
|
}
|
|
463
|
-
this.infoLog(
|
|
463
|
+
this.infoLog(e);
|
|
464
464
|
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Retrying`);
|
|
465
465
|
await sleep(1000);
|
|
466
466
|
return this.retry({ max: max - 1, fn });
|
|
467
467
|
});
|
|
468
468
|
}
|
|
469
469
|
|
|
470
|
-
|
|
471
|
-
let maxRetry: number;
|
|
470
|
+
maxRetry(): number {
|
|
472
471
|
if (this.device.maxRetry) {
|
|
473
|
-
|
|
472
|
+
return this.device.maxRetry;
|
|
474
473
|
} else {
|
|
475
|
-
|
|
474
|
+
return 5;
|
|
476
475
|
}
|
|
477
|
-
return maxRetry;
|
|
478
476
|
}
|
|
479
477
|
|
|
480
478
|
minLux(): number {
|
package/src/device/plug.ts
CHANGED
|
@@ -351,12 +351,12 @@ export class Plug {
|
|
|
351
351
|
.then(async (device_list: any) => {
|
|
352
352
|
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
353
353
|
return await this.retry({
|
|
354
|
-
max:
|
|
355
|
-
fn: () => {
|
|
354
|
+
max: this.maxRetry(),
|
|
355
|
+
fn: async () => {
|
|
356
356
|
if (this.On) {
|
|
357
|
-
return device_list[0].turnOn({ id: this.device.bleMac });
|
|
357
|
+
return await device_list[0].turnOn({ id: this.device.bleMac });
|
|
358
358
|
} else {
|
|
359
|
-
return device_list[0].turnOff({ id: this.device.bleMac });
|
|
359
|
+
return await device_list[0].turnOff({ id: this.device.bleMac });
|
|
360
360
|
}
|
|
361
361
|
},
|
|
362
362
|
});
|
|
@@ -522,25 +522,23 @@ export class Plug {
|
|
|
522
522
|
}
|
|
523
523
|
|
|
524
524
|
async retry({ max, fn }: { max: number; fn: { (): any; (): Promise<any> } }): Promise<null> {
|
|
525
|
-
return fn().catch(async (
|
|
525
|
+
return fn().catch(async (e: any) => {
|
|
526
526
|
if (max === 0) {
|
|
527
|
-
throw
|
|
527
|
+
throw e;
|
|
528
528
|
}
|
|
529
|
-
this.infoLog(
|
|
529
|
+
this.infoLog(e);
|
|
530
530
|
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Retrying`);
|
|
531
531
|
await sleep(1000);
|
|
532
532
|
return this.retry({ max: max - 1, fn });
|
|
533
533
|
});
|
|
534
534
|
}
|
|
535
535
|
|
|
536
|
-
|
|
537
|
-
let maxRetry: number;
|
|
536
|
+
maxRetry(): number {
|
|
538
537
|
if (this.device.maxRetry) {
|
|
539
|
-
|
|
538
|
+
return this.device.maxRetry;
|
|
540
539
|
} else {
|
|
541
|
-
|
|
540
|
+
return 5;
|
|
542
541
|
}
|
|
543
|
-
return maxRetry;
|
|
544
542
|
}
|
|
545
543
|
|
|
546
544
|
model(device: device & devicesConfig): string {
|
|
@@ -362,12 +362,12 @@ export class RobotVacuumCleaner {
|
|
|
362
362
|
.then(async (device_list: any) => {
|
|
363
363
|
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
364
364
|
return await this.retry({
|
|
365
|
-
max:
|
|
366
|
-
fn: () => {
|
|
365
|
+
max: this.maxRetry(),
|
|
366
|
+
fn: async () => {
|
|
367
367
|
if (this.On) {
|
|
368
|
-
return device_list[0].turnOn({ id: this.device.bleMac });
|
|
368
|
+
return await device_list[0].turnOn({ id: this.device.bleMac });
|
|
369
369
|
} else {
|
|
370
|
-
return device_list[0].turnOff({ id: this.device.bleMac });
|
|
370
|
+
return await device_list[0].turnOff({ id: this.device.bleMac });
|
|
371
371
|
}
|
|
372
372
|
},
|
|
373
373
|
});
|
|
@@ -646,25 +646,23 @@ export class RobotVacuumCleaner {
|
|
|
646
646
|
}
|
|
647
647
|
|
|
648
648
|
async retry({ max, fn }: { max: number; fn: { (): any; (): Promise<any> } }): Promise<null> {
|
|
649
|
-
return fn().catch(async (
|
|
649
|
+
return fn().catch(async (e: any) => {
|
|
650
650
|
if (max === 0) {
|
|
651
|
-
throw
|
|
651
|
+
throw e;
|
|
652
652
|
}
|
|
653
|
-
this.infoLog(
|
|
653
|
+
this.infoLog(e);
|
|
654
654
|
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Retrying`);
|
|
655
655
|
await sleep(1000);
|
|
656
656
|
return this.retry({ max: max - 1, fn });
|
|
657
657
|
});
|
|
658
658
|
}
|
|
659
659
|
|
|
660
|
-
|
|
661
|
-
let maxRetry: number;
|
|
660
|
+
maxRetry(): number {
|
|
662
661
|
if (this.device.maxRetry) {
|
|
663
|
-
|
|
662
|
+
return this.device.maxRetry;
|
|
664
663
|
} else {
|
|
665
|
-
|
|
664
|
+
return 5;
|
|
666
665
|
}
|
|
667
|
-
return maxRetry;
|
|
668
666
|
}
|
|
669
667
|
|
|
670
668
|
model(device: device & devicesConfig): string {
|
package/src/device/striplight.ts
CHANGED
|
@@ -467,12 +467,12 @@ export class StripLight {
|
|
|
467
467
|
.then(async (device_list: any) => {
|
|
468
468
|
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
469
469
|
return await this.retry({
|
|
470
|
-
max:
|
|
471
|
-
fn: () => {
|
|
470
|
+
max: this.maxRetry(),
|
|
471
|
+
fn: async () => {
|
|
472
472
|
if (this.On) {
|
|
473
|
-
return device_list[0].turnOn({ id: this.device.bleMac });
|
|
473
|
+
return await device_list[0].turnOn({ id: this.device.bleMac });
|
|
474
474
|
} else {
|
|
475
|
-
return device_list[0].turnOff({ id: this.device.bleMac });
|
|
475
|
+
return await device_list[0].turnOff({ id: this.device.bleMac });
|
|
476
476
|
}
|
|
477
477
|
},
|
|
478
478
|
});
|
|
@@ -516,9 +516,9 @@ export class StripLight {
|
|
|
516
516
|
model: 'u',
|
|
517
517
|
id: this.device.bleMac,
|
|
518
518
|
})
|
|
519
|
-
.then((device_list: any) => {
|
|
519
|
+
.then(async (device_list: any) => {
|
|
520
520
|
this.infoLog(`${this.accessory.displayName} Target Brightness: ${this.Brightness}`);
|
|
521
|
-
return device_list[0].setBrightness(this.Brightness);
|
|
521
|
+
return await device_list[0].setBrightness(this.Brightness);
|
|
522
522
|
})
|
|
523
523
|
.then(() => {
|
|
524
524
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Done.`);
|
|
@@ -557,9 +557,9 @@ export class StripLight {
|
|
|
557
557
|
model: 'u',
|
|
558
558
|
id: this.device.bleMac,
|
|
559
559
|
})
|
|
560
|
-
.then((device_list: any) => {
|
|
560
|
+
.then(async (device_list: any) => {
|
|
561
561
|
this.infoLog(`${this.accessory.displayName} Target RGB: ${this.Brightness, red, green, blue}`);
|
|
562
|
-
return device_list[0].setRGB(this.Brightness, red, green, blue);
|
|
562
|
+
return await device_list[0].setRGB(this.Brightness, red, green, blue);
|
|
563
563
|
})
|
|
564
564
|
.then(() => {
|
|
565
565
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Done.`);
|
|
@@ -887,25 +887,23 @@ export class StripLight {
|
|
|
887
887
|
}
|
|
888
888
|
|
|
889
889
|
async retry({ max, fn }: { max: number; fn: { (): any; (): Promise<any> } }): Promise<null> {
|
|
890
|
-
return fn().catch(async (
|
|
890
|
+
return fn().catch(async (e: any) => {
|
|
891
891
|
if (max === 0) {
|
|
892
|
-
throw
|
|
892
|
+
throw e;
|
|
893
893
|
}
|
|
894
|
-
this.infoLog(
|
|
894
|
+
this.infoLog(e);
|
|
895
895
|
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Retrying`);
|
|
896
896
|
await sleep(1000);
|
|
897
897
|
return this.retry({ max: max - 1, fn });
|
|
898
898
|
});
|
|
899
899
|
}
|
|
900
900
|
|
|
901
|
-
|
|
902
|
-
let maxRetry: number;
|
|
901
|
+
maxRetry(): number {
|
|
903
902
|
if (this.device.maxRetry) {
|
|
904
|
-
|
|
903
|
+
return this.device.maxRetry;
|
|
905
904
|
} else {
|
|
906
|
-
|
|
905
|
+
return 5;
|
|
907
906
|
}
|
|
908
|
-
return maxRetry;
|
|
909
907
|
}
|
|
910
908
|
|
|
911
909
|
minStep(device: device & devicesConfig): number {
|
|
@@ -188,7 +188,7 @@ export class AirPurifier {
|
|
|
188
188
|
'commandType': 'command',
|
|
189
189
|
});
|
|
190
190
|
if (this.Active === 1) {
|
|
191
|
-
if ((this.CurrentTemperature
|
|
191
|
+
if ((Number(this.CurrentTemperature)|| 24) < (this.LastTemperature || 30)) {
|
|
192
192
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
193
193
|
} else {
|
|
194
194
|
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
package/src/platform.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { Meter } from './device/meter';
|
|
|
5
5
|
import { Motion } from './device/motion';
|
|
6
6
|
import { Contact } from './device/contact';
|
|
7
7
|
import { Curtain } from './device/curtain';
|
|
8
|
+
import { IOSensor } from './device/iosensor';
|
|
8
9
|
import { MeterPlus } from './device/meterplus';
|
|
9
10
|
import { ColorBulb } from './device/colorbulb';
|
|
10
11
|
import { CeilingLight } from './device/ceilinglight';
|
|
@@ -426,6 +427,10 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
426
427
|
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
427
428
|
this.createMeterPlus(device);
|
|
428
429
|
break;
|
|
430
|
+
case 'WoIOSensor':
|
|
431
|
+
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
432
|
+
this.createIOSensor(device);
|
|
433
|
+
break;
|
|
429
434
|
case 'Motion Sensor':
|
|
430
435
|
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
431
436
|
this.createMotion(device);
|
|
@@ -781,6 +786,62 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
781
786
|
}
|
|
782
787
|
}
|
|
783
788
|
|
|
789
|
+
private async createIOSensor(device: device & devicesConfig) {
|
|
790
|
+
const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
|
|
791
|
+
|
|
792
|
+
// see if an accessory with the same uuid has already been registered and restored from
|
|
793
|
+
// the cached devices we stored in the `configureAccessory` method above
|
|
794
|
+
const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
|
|
795
|
+
|
|
796
|
+
if (existingAccessory) {
|
|
797
|
+
// the accessory already exists
|
|
798
|
+
if (await this.registerDevice(device)) {
|
|
799
|
+
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
800
|
+
existingAccessory.context.model = device.deviceType;
|
|
801
|
+
existingAccessory.context.deviceID = device.deviceId;
|
|
802
|
+
existingAccessory.displayName = device.configDeviceName || device.deviceName;
|
|
803
|
+
existingAccessory.context.firmwareRevision = device.firmware;
|
|
804
|
+
existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
805
|
+
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
806
|
+
existingAccessory.context.connectionType = await this.connectionType(device);
|
|
807
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
808
|
+
// create the accessory handler for the restored accessory
|
|
809
|
+
// this is imported from `platformAccessory.ts`
|
|
810
|
+
new IOSensor(this, existingAccessory, device);
|
|
811
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`);
|
|
812
|
+
} else {
|
|
813
|
+
this.unregisterPlatformAccessories(existingAccessory);
|
|
814
|
+
}
|
|
815
|
+
} else if (await this.registerDevice(device)) {
|
|
816
|
+
// the accessory does not yet exist, so we need to create it
|
|
817
|
+
if (!device.external) {
|
|
818
|
+
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
// create a new accessory
|
|
822
|
+
const accessory = new this.api.platformAccessory(device.deviceName, uuid);
|
|
823
|
+
|
|
824
|
+
// store a copy of the device object in the `accessory.context`
|
|
825
|
+
// the `context` property can be used to store any data about the accessory you may need
|
|
826
|
+
accessory.context.device = device;
|
|
827
|
+
accessory.context.model = device.deviceType;
|
|
828
|
+
accessory.context.deviceID = device.deviceId;
|
|
829
|
+
accessory.context.firmwareRevision = device.firmware;
|
|
830
|
+
accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
|
|
831
|
+
accessory.context.connectionType = await this.connectionType(device);
|
|
832
|
+
// create the accessory handler for the newly create accessory
|
|
833
|
+
// this is imported from `platformAccessory.ts`
|
|
834
|
+
new IOSensor(this, accessory, device);
|
|
835
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`);
|
|
836
|
+
|
|
837
|
+
// publish device externally or link the accessory to your platform
|
|
838
|
+
this.externalOrPlatform(device, accessory);
|
|
839
|
+
this.accessories.push(accessory);
|
|
840
|
+
} else {
|
|
841
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
|
|
784
845
|
private async createMotion(device: device & devicesConfig) {
|
|
785
846
|
const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`);
|
|
786
847
|
|
package/src/settings.ts
CHANGED
|
@@ -259,8 +259,8 @@ calibrate?: boolean; //determines if device has been calibrated or not. (Used by
|
|
|
259
259
|
group?: boolean; //determines if a device is paired with or grouped with another device or not. (Used by the following deviceTypes: Curtain, Blind Tilt)
|
|
260
260
|
moving?: boolean; //determines if a device is moving or not. (Used by the following deviceTypes: Curtain, Blind Tilt)
|
|
261
261
|
slidePosition?: number;//the current position (0-100) the percentage of the distance between the calibrated open position and closed position. (Used by the following deviceTypes: Curtain, Blind Tilt)
|
|
262
|
-
temperature?: number; //temperature in celsius (Used by the following deviceTypes: Meter, Meter Plus, Humidifier)
|
|
263
|
-
humidity?: number; //humidity percentage. (Used by the following deviceTypes: Meter, Meter Plus, Humidifier)
|
|
262
|
+
temperature?: number; //temperature in celsius (Used by the following deviceTypes: Meter, Meter Plus, Humidifier, IOSensor)
|
|
263
|
+
humidity?: number; //humidity percentage. (Used by the following deviceTypes: Meter, Meter Plus, Humidifier, IOSensor)
|
|
264
264
|
lockState?: string; //determines if locked or not. (Used by the following deviceTypes: Lock)
|
|
265
265
|
doorState?: string; //determines if the door is closed or not. (Used by the following deviceTypes: Lock)
|
|
266
266
|
moveDetected?: boolean; //determines if motion is detected. (Used by the following deviceTypes: Motion Sensor, Contact Sensor)
|
|
@@ -274,7 +274,7 @@ electricCurrent?: number; //the current of the device at the moment, measured in
|
|
|
274
274
|
color?: string; //the color value, RGB "255:255:255". (Used by the following deviceTypes: Strip Light, Color Bulb)
|
|
275
275
|
workingStatus?: string; //the working status of the device. StandBy, Clearing, Paused, GotoChargeBase, Charging, ChargeDone, Dormant, InTrouble, InRemoteControl, or InDustCollecting. (Used by the following deviceTypes: Robot Vacuum Cleaner S1, Robot Vacuum Cleaner S1 Plus)
|
|
276
276
|
onlineStatus?: string; //the connection status of the device. online or offline. (Used by the following deviceTypes: Robot Vacuum Cleaner S1, Robot Vacuum Cleaner S1 Plus)
|
|
277
|
-
battery?: number; //the current battery level. (Used by the following deviceTypes: Robot Vacuum Cleaner S1, Robot Vacuum Cleaner S1 Plus, Blind Tilt)
|
|
277
|
+
battery?: number; //the current battery level. (Used by the following deviceTypes: Robot Vacuum Cleaner S1, Robot Vacuum Cleaner S1 Plus, Blind Tilt, IOSensor)
|
|
278
278
|
deviceName?: string; //device name. (Used by the following deviceTypes: Robot Vacuum Cleaner S1 Plus)
|
|
279
279
|
nebulizationEfficiency?: number; //atomization efficiency percentage. (Used by the following deviceTypes: Humidifier)
|
|
280
280
|
auto?: boolean; //determines if a Humidifier is in Auto Mode or not. (Used by the following deviceTypes: Humidifier)
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
#!/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This scripts queries the npm registry to pull out the latest version for a given tag.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const fs = require("fs");
|
|
8
|
-
const semver = require("semver");
|
|
9
|
-
const child_process = require("child_process");
|
|
10
|
-
const assert = require("assert");
|
|
11
|
-
|
|
12
|
-
const BRANCH_VERSION_PATTERN = /^([A-Za-z]*)-(\d+.\d+.\d+)$/
|
|
13
|
-
|
|
14
|
-
// Load the contents of the package.json file
|
|
15
|
-
const packageJSON = JSON.parse(fs.readFileSync("package.json", "utf8"));
|
|
16
|
-
|
|
17
|
-
let refArgument = process.argv[2];
|
|
18
|
-
let tagArgument = process.argv[3] || "latest";
|
|
19
|
-
|
|
20
|
-
if (refArgument == null) {
|
|
21
|
-
console.error("ref argument is missing");
|
|
22
|
-
console.error("Usage: npm-version-script.js <ref> [tag]");
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Queries the NPM registry for the latest version for the provided tag.
|
|
28
|
-
* @param tag The tag to query for.
|
|
29
|
-
* @returns {string} Returns the version.
|
|
30
|
-
*/
|
|
31
|
-
function getTagVersionFromNpm(tag) {
|
|
32
|
-
try {
|
|
33
|
-
return child_process.execSync(`npm info ${packageJSON.name} version --tag="${tag}"`).toString("utf8").trim();
|
|
34
|
-
} catch (e) {
|
|
35
|
-
throw e;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function desiredTargetVersion(ref) {
|
|
40
|
-
// ref is a GitHub action ref string
|
|
41
|
-
if (ref.startsWith("refs/pull/")) {
|
|
42
|
-
throw Error("The version script was executed inside a PR!");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
assert(ref.startsWith("refs/heads/"))
|
|
46
|
-
let branchName = ref.slice("refs/heads/".length);
|
|
47
|
-
|
|
48
|
-
let results = branchName.match(BRANCH_VERSION_PATTERN);
|
|
49
|
-
if (results != null) {
|
|
50
|
-
if (results[1] !== tagArgument) {
|
|
51
|
-
console.warn(`The base branch name (${results[1]}) differs from the tag name ${tagArgument}`);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return results[2];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// legacy mode were we use the `betaVersion` property in the package.json
|
|
58
|
-
if (branchName === "beta" && packageJSON.betaVersion) {
|
|
59
|
-
return packageJSON.betaVersion
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
throw new Error("Malformed branch name for ref: " + ref + ". Can't derive the base version. Use a branch name like: beta-x.x.x!");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// derive the base version from the branch ref
|
|
66
|
-
const baseVersion = desiredTargetVersion(refArgument);
|
|
67
|
-
|
|
68
|
-
// query the npm registry for the latest version of the provided tag name
|
|
69
|
-
const latestReleasedVersion = getTagVersionFromNpm(tagArgument); // e.g. 0.7.0-beta.12
|
|
70
|
-
const latestReleaseBase = semver.inc(latestReleasedVersion, "patch"); // will produce 0.7.0 (removing the preid, needed for the equality check below)
|
|
71
|
-
|
|
72
|
-
let publishTag;
|
|
73
|
-
if (semver.eq(baseVersion, latestReleaseBase)) { // check if we are releasing another version for the latest beta
|
|
74
|
-
publishTag = latestReleasedVersion; // set the current latest beta to be incremented
|
|
75
|
-
} else {
|
|
76
|
-
publishTag = baseVersion; // start of with a new beta version
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// save the package.json
|
|
80
|
-
packageJSON.version = publishTag;
|
|
81
|
-
fs.writeFileSync("package.json", JSON.stringify(packageJSON, null, 2));
|