@switchbot/homebridge-switchbot 2.9.0-beta.8 → 2.9.0
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 +1 -1
- package/config.schema.json +21 -5
- package/dist/device/blindtilt.d.ts +1 -1
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +38 -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 +64 -17
- 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 +34 -17
- 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 +31 -17
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +41 -17
- package/dist/device/contact.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 +38 -17
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts +8 -9
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +172 -55
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +37 -17
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +41 -18
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +34 -17
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +38 -17
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +1 -9
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +47 -32
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +4 -7
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +69 -50
- 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 +38 -17
- 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 +35 -17
- 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 +35 -17
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +28 -14
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +28 -14
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +28 -14
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +28 -14
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +28 -14
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +39 -15
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +28 -14
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +28 -14
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +28 -14
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +4 -0
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +1 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +11 -11
- package/src/device/blindtilt.ts +38 -18
- package/src/device/bot.ts +55 -18
- package/src/device/ceilinglight.ts +34 -19
- package/src/device/colorbulb.ts +31 -18
- package/src/device/contact.ts +41 -19
- package/src/device/curtain.ts +38 -18
- package/src/device/hub.ts +188 -65
- package/src/device/humidifier.ts +37 -19
- package/src/device/iosensor.ts +41 -20
- package/src/device/lightstrip.ts +34 -18
- package/src/device/lock.ts +39 -20
- package/src/device/meter.ts +48 -40
- package/src/device/meterplus.ts +74 -60
- package/src/device/motion.ts +38 -20
- package/src/device/plug.ts +35 -19
- package/src/device/robotvacuumcleaner.ts +35 -18
- package/src/irdevice/airconditioner.ts +28 -15
- package/src/irdevice/airpurifier.ts +30 -15
- package/src/irdevice/camera.ts +30 -15
- package/src/irdevice/fan.ts +30 -15
- package/src/irdevice/light.ts +30 -15
- package/src/irdevice/other.ts +40 -16
- package/src/irdevice/tv.ts +30 -15
- package/src/irdevice/vacuumcleaner.ts +30 -15
- package/src/irdevice/waterheater.ts +30 -15
- package/src/platform.ts +4 -0
- package/src/settings.ts +1 -0
- package/.github/npm-version-script.js +0 -81
|
@@ -38,10 +38,20 @@ export class VacuumCleaner {
|
|
|
38
38
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
39
39
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
40
40
|
.setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
|
|
41
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
.
|
|
41
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
|
|
42
|
+
|
|
43
|
+
if (accessory.context.FirmwareRevision) {
|
|
44
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
45
|
+
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
|
|
46
|
+
accessory
|
|
47
|
+
.getService(this.platform.Service.AccessoryInformation)!
|
|
48
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
49
|
+
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
50
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
51
|
+
.updateValue(accessory.context.FirmwareRevision);
|
|
52
|
+
} else {
|
|
53
|
+
this.setFirmwareRevision(accessory, device);
|
|
54
|
+
}
|
|
45
55
|
|
|
46
56
|
// get the Television service if it exists, otherwise create a new Television service
|
|
47
57
|
// you can create multiple services for each accessory
|
|
@@ -255,21 +265,26 @@ export class VacuumCleaner {
|
|
|
255
265
|
this.switchService.updateCharacteristic(this.platform.Characteristic.On, e);
|
|
256
266
|
}
|
|
257
267
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
);
|
|
262
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
263
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
async setFirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig) {
|
|
264
271
|
if (device.firmware) {
|
|
265
|
-
this.
|
|
266
|
-
|
|
272
|
+
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
273
|
+
accessory.context.FirmwareRevision = device.firmware;
|
|
267
274
|
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
275
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
268
276
|
} else {
|
|
269
|
-
this.
|
|
277
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
278
|
+
accessory.context.FirmwareRevision = this.platform.version;
|
|
279
|
+
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
280
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
270
281
|
}
|
|
271
|
-
this.
|
|
272
|
-
|
|
282
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
|
|
283
|
+
accessory
|
|
284
|
+
.getService(this.platform.Service.AccessoryInformation)!
|
|
285
|
+
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
286
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
287
|
+
.updateValue(this.FirmwareRevision);
|
|
273
288
|
}
|
|
274
289
|
|
|
275
290
|
async context() {
|
|
@@ -38,10 +38,20 @@ export class WaterHeater {
|
|
|
38
38
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
39
39
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
40
40
|
.setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
|
|
41
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
.
|
|
41
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
|
|
42
|
+
|
|
43
|
+
if (accessory.context.FirmwareRevision) {
|
|
44
|
+
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
45
|
+
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
|
|
46
|
+
accessory
|
|
47
|
+
.getService(this.platform.Service.AccessoryInformation)!
|
|
48
|
+
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
49
|
+
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
50
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
51
|
+
.updateValue(accessory.context.FirmwareRevision);
|
|
52
|
+
} else {
|
|
53
|
+
this.setFirmwareRevision(accessory, device);
|
|
54
|
+
}
|
|
45
55
|
|
|
46
56
|
// get the Television service if it exists, otherwise create a new Television service
|
|
47
57
|
// you can create multiple services for each accessory
|
|
@@ -264,21 +274,26 @@ export class WaterHeater {
|
|
|
264
274
|
this.valveService.updateCharacteristic(this.platform.Characteristic.Active, e);
|
|
265
275
|
}
|
|
266
276
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
);
|
|
271
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
272
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
async setFirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig) {
|
|
273
280
|
if (device.firmware) {
|
|
274
|
-
this.
|
|
275
|
-
|
|
281
|
+
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
282
|
+
accessory.context.FirmwareRevision = device.firmware;
|
|
276
283
|
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
284
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
277
285
|
} else {
|
|
278
|
-
this.
|
|
286
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
287
|
+
accessory.context.FirmwareRevision = this.platform.version;
|
|
288
|
+
this.FirmwareRevision = accessory.context.FirmwareRevision;
|
|
289
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version, FirmwareRevision: ${this.FirmwareRevision}`);
|
|
279
290
|
}
|
|
280
|
-
this.
|
|
281
|
-
|
|
291
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} setFirmwareRevision: ${this.FirmwareRevision}`);
|
|
292
|
+
accessory
|
|
293
|
+
.getService(this.platform.Service.AccessoryInformation)!
|
|
294
|
+
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision)
|
|
295
|
+
.getCharacteristic(this.platform.Characteristic.FirmwareRevision)
|
|
296
|
+
.updateValue(this.FirmwareRevision);
|
|
282
297
|
}
|
|
283
298
|
|
|
284
299
|
async context(): Promise<void> {
|
package/src/platform.ts
CHANGED
|
@@ -415,6 +415,10 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
415
415
|
for (const device of devices) {
|
|
416
416
|
device.deviceType = device.configDeviceType;
|
|
417
417
|
device.deviceName = device.configDeviceName;
|
|
418
|
+
if (!device.deviceType) {
|
|
419
|
+
device.deviceType = device.configDeviceType;
|
|
420
|
+
this.errorLog(`API has displaying no deviceType: ${device.deviceType}, So using configDeviceType: ${device.configDeviceType}`);
|
|
421
|
+
}
|
|
418
422
|
if (device.deviceType) {
|
|
419
423
|
this.createDevice(device);
|
|
420
424
|
}
|
package/src/settings.ts
CHANGED
|
@@ -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));
|