@switchbot/homebridge-switchbot 3.1.1-beta.9 → 3.1.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.
Files changed (68) hide show
  1. package/CHANGELOG.md +43 -31
  2. package/dist/device/blindtilt.d.ts.map +1 -1
  3. package/dist/device/blindtilt.js +2 -1
  4. package/dist/device/blindtilt.js.map +1 -1
  5. package/dist/device/bot.d.ts.map +1 -1
  6. package/dist/device/bot.js +2 -1
  7. package/dist/device/bot.js.map +1 -1
  8. package/dist/device/ceilinglight.d.ts.map +1 -1
  9. package/dist/device/ceilinglight.js +2 -1
  10. package/dist/device/ceilinglight.js.map +1 -1
  11. package/dist/device/colorbulb.d.ts.map +1 -1
  12. package/dist/device/colorbulb.js +2 -1
  13. package/dist/device/colorbulb.js.map +1 -1
  14. package/dist/device/contact.d.ts.map +1 -1
  15. package/dist/device/contact.js +2 -1
  16. package/dist/device/contact.js.map +1 -1
  17. package/dist/device/curtain.d.ts.map +1 -1
  18. package/dist/device/curtain.js +6 -2
  19. package/dist/device/curtain.js.map +1 -1
  20. package/dist/device/humidifier.d.ts.map +1 -1
  21. package/dist/device/humidifier.js +2 -1
  22. package/dist/device/humidifier.js.map +1 -1
  23. package/dist/device/iosensor.d.ts.map +1 -1
  24. package/dist/device/iosensor.js +2 -1
  25. package/dist/device/iosensor.js.map +1 -1
  26. package/dist/device/lightstrip.d.ts.map +1 -1
  27. package/dist/device/lightstrip.js +2 -1
  28. package/dist/device/lightstrip.js.map +1 -1
  29. package/dist/device/lock.d.ts.map +1 -1
  30. package/dist/device/lock.js +2 -1
  31. package/dist/device/lock.js.map +1 -1
  32. package/dist/device/meter.d.ts.map +1 -1
  33. package/dist/device/meter.js +2 -1
  34. package/dist/device/meter.js.map +1 -1
  35. package/dist/device/meterplus.d.ts.map +1 -1
  36. package/dist/device/meterplus.js +2 -1
  37. package/dist/device/meterplus.js.map +1 -1
  38. package/dist/device/motion.d.ts.map +1 -1
  39. package/dist/device/motion.js +2 -1
  40. package/dist/device/motion.js.map +1 -1
  41. package/dist/device/plug.d.ts.map +1 -1
  42. package/dist/device/plug.js +2 -1
  43. package/dist/device/plug.js.map +1 -1
  44. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  45. package/dist/device/robotvacuumcleaner.js +2 -1
  46. package/dist/device/robotvacuumcleaner.js.map +1 -1
  47. package/dist/platform.d.ts +1 -1
  48. package/dist/platform.d.ts.map +1 -1
  49. package/dist/platform.js +9 -10
  50. package/dist/platform.js.map +1 -1
  51. package/package.json +7 -7
  52. package/src/device/blindtilt.ts +2 -1
  53. package/src/device/bot.ts +2 -1
  54. package/src/device/ceilinglight.ts +2 -1
  55. package/src/device/colorbulb.ts +2 -1
  56. package/src/device/contact.ts +2 -1
  57. package/src/device/curtain.ts +7 -2
  58. package/src/device/humidifier.ts +2 -1
  59. package/src/device/iosensor.ts +2 -1
  60. package/src/device/lightstrip.ts +2 -1
  61. package/src/device/lock.ts +2 -1
  62. package/src/device/meter.ts +2 -1
  63. package/src/device/meterplus.ts +2 -1
  64. package/src/device/motion.ts +2 -1
  65. package/src/device/plug.ts +2 -1
  66. package/src/device/robotvacuumcleaner.ts +2 -1
  67. package/src/platform.ts +9 -8
  68. package/.github/npm-version-script.cjs +0 -81
@@ -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: ${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();
@@ -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: ${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();
@@ -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: ${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();
@@ -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: ${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();
@@ -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: ${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();
@@ -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: ${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();
@@ -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: ${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();
@@ -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: ${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: ${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,9 @@ 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 { SwitchBot } from 'node-switchbot';
43
+ /*import { SwitchBot } from '/Users/Shared/GitHub/OpenWonderLabs/node-switchbot/dist/switchbot.js';*/
44
+
42
45
 
43
46
 
44
47
  /**
@@ -2519,16 +2522,14 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
2519
2522
  }
2520
2523
 
2521
2524
  // BLE Connection
2522
- connectBLE() {
2523
- let Switchbot: new () => any;
2525
+ async connectBLE() {
2524
2526
  let switchbot: any;
2525
- try {
2526
- Switchbot = require('node-switchbot');
2527
- queueScheduler.schedule(() => (switchbot = new Switchbot()));
2528
- } catch (e: any) {
2527
+ //try {
2528
+ queueScheduler.schedule(() => (switchbot = new SwitchBot()));
2529
+ /*} catch (e: any) {
2529
2530
  switchbot = false;
2530
- this.errorLog(`Was 'node-switchbot' found: ${switchbot}`);
2531
- }
2531
+ this.errorLog(`Was 'node-switchbot' found: ${switchbot}, Error: ${e}`);
2532
+ }*/
2532
2533
  return switchbot;
2533
2534
  }
2534
2535
 
@@ -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));