@switchbot/homebridge-switchbot 3.1.1-beta.9 → 3.1.2
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 +51 -31
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +2 -1
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +2 -1
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +2 -1
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +2 -1
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +2 -1
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +6 -2
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +2 -1
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +2 -1
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +2 -1
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +2 -1
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +2 -1
- package/dist/device/meter.js.map +1 -1
- 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.map +1 -1
- package/dist/device/motion.js +2 -1
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +2 -1
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +2 -1
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/platform.d.ts +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +7 -5
- package/dist/platform.js.map +1 -1
- package/package.json +7 -7
- package/src/device/blindtilt.ts +2 -1
- package/src/device/bot.ts +2 -1
- package/src/device/ceilinglight.ts +2 -1
- package/src/device/colorbulb.ts +2 -1
- package/src/device/contact.ts +2 -1
- package/src/device/curtain.ts +7 -2
- package/src/device/humidifier.ts +2 -1
- package/src/device/iosensor.ts +2 -1
- package/src/device/lightstrip.ts +2 -1
- package/src/device/lock.ts +2 -1
- package/src/device/meter.ts +2 -1
- package/src/device/meterplus.ts +2 -1
- package/src/device/motion.ts +2 -1
- package/src/device/plug.ts +2 -1
- package/src/device/robotvacuumcleaner.ts +2 -1
- package/src/platform.ts +9 -6
- package/.github/npm-version-script.cjs +0 -81
package/src/device/humidifier.ts
CHANGED
|
@@ -798,7 +798,8 @@ export class Humidifier {
|
|
|
798
798
|
}
|
|
799
799
|
|
|
800
800
|
async BLERefreshConnection(switchbot: any): Promise<void> {
|
|
801
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot
|
|
801
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot:`
|
|
802
|
+
+ ` ${JSON.stringify(switchbot)}`);
|
|
802
803
|
if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
|
|
803
804
|
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Refresh Status`);
|
|
804
805
|
await this.openAPIRefreshStatus();
|
package/src/device/iosensor.ts
CHANGED
|
@@ -559,7 +559,8 @@ export class IOSensor {
|
|
|
559
559
|
}
|
|
560
560
|
|
|
561
561
|
async BLERefreshConnection(switchbot: any): Promise<void> {
|
|
562
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot
|
|
562
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot:`
|
|
563
|
+
+ ` ${JSON.stringify(switchbot)}`);
|
|
563
564
|
if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
|
|
564
565
|
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Refresh Status`);
|
|
565
566
|
await this.openAPIRefreshStatus();
|
package/src/device/lightstrip.ts
CHANGED
|
@@ -943,7 +943,8 @@ export class StripLight {
|
|
|
943
943
|
}
|
|
944
944
|
|
|
945
945
|
async BLERefreshConnection(switchbot: any): Promise<void> {
|
|
946
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot
|
|
946
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot:`
|
|
947
|
+
+ ` ${JSON.stringify(switchbot)}`);
|
|
947
948
|
if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
|
|
948
949
|
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Refresh Status`);
|
|
949
950
|
await this.openAPIRefreshStatus();
|
package/src/device/lock.ts
CHANGED
|
@@ -678,7 +678,8 @@ export class Lock {
|
|
|
678
678
|
}
|
|
679
679
|
|
|
680
680
|
async BLERefreshConnection(switchbot: any): Promise<void> {
|
|
681
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot
|
|
681
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot:`
|
|
682
|
+
+ ` ${JSON.stringify(switchbot)}`);
|
|
682
683
|
if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
|
|
683
684
|
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Refresh Status`);
|
|
684
685
|
await this.openAPIRefreshStatus();
|
package/src/device/meter.ts
CHANGED
|
@@ -552,7 +552,8 @@ export class Meter {
|
|
|
552
552
|
}
|
|
553
553
|
|
|
554
554
|
async BLERefreshConnection(switchbot: any): Promise<void> {
|
|
555
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot
|
|
555
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot:`
|
|
556
|
+
+ ` ${JSON.stringify(switchbot)}`);
|
|
556
557
|
if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
|
|
557
558
|
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Refresh Status`);
|
|
558
559
|
await this.openAPIRefreshStatus();
|
package/src/device/meterplus.ts
CHANGED
|
@@ -557,7 +557,8 @@ export class MeterPlus {
|
|
|
557
557
|
}
|
|
558
558
|
|
|
559
559
|
async BLERefreshConnection(switchbot: any): Promise<void> {
|
|
560
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot
|
|
560
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot:`
|
|
561
|
+
+ ` ${JSON.stringify(switchbot)}`);
|
|
561
562
|
if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
|
|
562
563
|
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Refresh Status`);
|
|
563
564
|
await this.openAPIRefreshStatus();
|
package/src/device/motion.ts
CHANGED
|
@@ -462,7 +462,8 @@ export class Motion {
|
|
|
462
462
|
}
|
|
463
463
|
|
|
464
464
|
async BLERefreshConnection(switchbot: any): Promise<void> {
|
|
465
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot
|
|
465
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot:`
|
|
466
|
+
+ ` ${JSON.stringify(switchbot)}`);
|
|
466
467
|
if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
|
|
467
468
|
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Refresh Status`);
|
|
468
469
|
await this.openAPIRefreshStatus();
|
package/src/device/plug.ts
CHANGED
|
@@ -497,7 +497,8 @@ export class Plug {
|
|
|
497
497
|
}
|
|
498
498
|
|
|
499
499
|
async BLERefreshConnection(switchbot: any): Promise<void> {
|
|
500
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot
|
|
500
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot:`
|
|
501
|
+
+ ` ${JSON.stringify(switchbot)}`);
|
|
501
502
|
if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
|
|
502
503
|
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Refresh Status`);
|
|
503
504
|
await this.openAPIRefreshStatus();
|
|
@@ -659,7 +659,8 @@ export class RobotVacuumCleaner {
|
|
|
659
659
|
}
|
|
660
660
|
|
|
661
661
|
async BLERefreshConnection(switchbot: any): Promise<void> {
|
|
662
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot
|
|
662
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot:`
|
|
663
|
+
+ ` ${JSON.stringify(switchbot)}`);
|
|
663
664
|
if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
|
|
664
665
|
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Refresh Status`);
|
|
665
666
|
await this.openAPIRefreshStatus();
|
package/src/platform.ts
CHANGED
|
@@ -39,6 +39,10 @@ import asyncmqtt from 'async-mqtt';
|
|
|
39
39
|
import crypto, { randomUUID } from 'crypto';
|
|
40
40
|
import { readFileSync, writeFileSync } from 'fs';
|
|
41
41
|
import hbLib from 'homebridge-lib';
|
|
42
|
+
import noble from '@abandonware/noble';
|
|
43
|
+
import SwitchBotBLE from 'node-switchbot';
|
|
44
|
+
/*import SwitchBotBLE from '/Users/Shared/GitHub/OpenWonderLabs/node-switchbot/dist/switchbot.js';*/
|
|
45
|
+
|
|
42
46
|
|
|
43
47
|
|
|
44
48
|
/**
|
|
@@ -2309,7 +2313,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2309
2313
|
break;
|
|
2310
2314
|
default:
|
|
2311
2315
|
this.debugWarnLog(`deviceName: ${device.deviceName} deviceId: ${device.deviceId}, blindTiltDevicesIds: ${device.blindTiltDevicesIds}, master:`
|
|
2312
|
-
|
|
2316
|
+
+ ` ${device.master}, group: ${device.group}, disable_group: ${device.curtain?.disable_group}, connectionType: ${device.connectionType}`);
|
|
2313
2317
|
}
|
|
2314
2318
|
|
|
2315
2319
|
let registerCurtain: boolean;
|
|
@@ -2519,15 +2523,14 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2519
2523
|
}
|
|
2520
2524
|
|
|
2521
2525
|
// BLE Connection
|
|
2522
|
-
connectBLE() {
|
|
2523
|
-
|
|
2526
|
+
async connectBLE() {
|
|
2527
|
+
const { SwitchBot } = SwitchBotBLE;
|
|
2524
2528
|
let switchbot: any;
|
|
2525
2529
|
try {
|
|
2526
|
-
|
|
2527
|
-
queueScheduler.schedule(() => (switchbot = new Switchbot()));
|
|
2530
|
+
queueScheduler.schedule(() => (switchbot = new SwitchBot({ 'noble': noble })));
|
|
2528
2531
|
} catch (e: any) {
|
|
2529
2532
|
switchbot = false;
|
|
2530
|
-
this.errorLog(`Was 'node-switchbot' found: ${switchbot}`);
|
|
2533
|
+
this.errorLog(`Was 'node-switchbot' found: ${switchbot}, Error: ${e}`);
|
|
2531
2534
|
}
|
|
2532
2535
|
return switchbot;
|
|
2533
2536
|
}
|
|
@@ -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.cjs <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));
|