@switchbot/homebridge-switchbot 1.12.7-beta.5 → 1.12.7-beta.6

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.
@@ -62,7 +62,7 @@ export class Lock {
62
62
 
63
63
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
64
64
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
65
- // accessory.getService('NAME') ?? accessory.addService(this.platform.Service.Lightbulb, 'NAME', 'USER_DEFINED_SUBTYPE');
65
+ // accessory.getService('NAME') ?? accessory.addService(this.platform.Service.LockMechanism, 'NAME', 'USER_DEFINED_SUBTYPE');
66
66
 
67
67
  // set the service name, this is what is displayed as the default name on the Home app
68
68
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
@@ -119,26 +119,6 @@ export class Lock {
119
119
  }
120
120
 
121
121
  async refreshStatus(): Promise<void> {
122
- const switchbot = await this.platform.connectBLE();
123
- // Convert to BLE Address
124
- this.device.bleMac = this.device
125
- .deviceId!.match(/.{1,2}/g)!
126
- .join(':')
127
- .toLowerCase();
128
- this.debugLog(`Curtain: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
129
- (async () => {
130
- // Start to monitor advertisement packets
131
- await switchbot.startScan({
132
- model: 'o',
133
- });
134
- // Set an event handler
135
- switchbot.onadvertisement = (ad: any) => {
136
- this.warnLog(JSON.stringify(ad, null, ' '));
137
- };
138
- await switchbot.wait(10000);
139
- // Stop to monitor
140
- switchbot.stopScan();
141
- })();
142
122
  try {
143
123
  this.deviceStatus = (await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`)).data;
144
124
  this.debugLog(`Lock: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
@@ -59,7 +59,7 @@ export class Plug {
59
59
 
60
60
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
61
61
  // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
62
- // accessory.getService('NAME') ?? accessory.addService(this.platform.Service.Lightbulb, 'NAME', 'USER_DEFINED_SUBTYPE');
62
+ // accessory.getService('NAME') ?? accessory.addService(this.platform.Service.Outlet, 'NAME', 'USER_DEFINED_SUBTYPE');
63
63
 
64
64
  // set the service name, this is what is displayed as the default name on the Home app
65
65
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
package/src/platform.ts CHANGED
@@ -495,7 +495,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
495
495
  this.debugLog(`Device: ${device.deviceName} OpenAPI Connection Enabled`);
496
496
  } else {
497
497
  this.registeringDevice = false;
498
- this.debugLog(`Device: ${device.deviceName} Neither OpenAPI and BLE Enabled`);
498
+ this.debugLog(`Device: ${device.deviceName} OpenAPI and BLE Are Not Enabled`);
499
499
  }
500
500
  return this.registeringDevice;
501
501
  }
@@ -871,7 +871,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
871
871
 
872
872
  if (existingAccessory) {
873
873
  // the accessory already exists
874
- if (!device.hide_device && device.enableCloudService) {
874
+ if (this.registerDevice(device)) {
875
875
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
876
876
 
877
877
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
@@ -889,7 +889,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
889
889
  } else {
890
890
  this.unregisterPlatformAccessories(existingAccessory);
891
891
  }
892
- } else if (!device.hide_device && device.enableCloudService) {
892
+ } else if (this.registerDevice(device)) {
893
893
  // the accessory does not yet exist, so we need to create it
894
894
  this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
895
895
 
@@ -926,7 +926,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
926
926
 
927
927
  if (existingAccessory) {
928
928
  // the accessory already exists
929
- if (!device.hide_device || device.enableCloudService) {
929
+ if (this.registerDevice(device)) {
930
930
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
931
931
 
932
932
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
@@ -944,7 +944,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
944
944
  } else {
945
945
  this.unregisterPlatformAccessories(existingAccessory);
946
946
  }
947
- } else if (!device.hide_device || device.enableCloudService) {
947
+ } else if (this.registerDevice(device)) {
948
948
  // the accessory does not yet exist, so we need to create it
949
949
  this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
950
950
 
@@ -981,7 +981,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
981
981
 
982
982
  if (existingAccessory) {
983
983
  // the accessory already exists
984
- if (!device.hide_device && device.enableCloudService) {
984
+ if (this.registerDevice(device)) {
985
985
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
986
986
 
987
987
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
@@ -999,7 +999,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
999
999
  } else {
1000
1000
  this.unregisterPlatformAccessories(existingAccessory);
1001
1001
  }
1002
- } else if (!device.hide_device && device.enableCloudService) {
1002
+ } else if (this.registerDevice(device)) {
1003
1003
  // the accessory does not yet exist, so we need to create it
1004
1004
  this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1005
1005