@switchbot/homebridge-switchbot 3.5.1-beta.0 → 3.5.1-beta.10

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 (197) hide show
  1. package/README.md +16 -0
  2. package/dist/device/blindtilt.d.ts +15 -6
  3. package/dist/device/blindtilt.d.ts.map +1 -1
  4. package/dist/device/blindtilt.js +224 -370
  5. package/dist/device/blindtilt.js.map +1 -1
  6. package/dist/device/bot.d.ts +9 -4
  7. package/dist/device/bot.d.ts.map +1 -1
  8. package/dist/device/bot.js +197 -221
  9. package/dist/device/bot.js.map +1 -1
  10. package/dist/device/ceilinglight.d.ts +10 -5
  11. package/dist/device/ceilinglight.d.ts.map +1 -1
  12. package/dist/device/ceilinglight.js +214 -292
  13. package/dist/device/ceilinglight.js.map +1 -1
  14. package/dist/device/colorbulb.d.ts +10 -5
  15. package/dist/device/colorbulb.d.ts.map +1 -1
  16. package/dist/device/colorbulb.js +335 -421
  17. package/dist/device/colorbulb.js.map +1 -1
  18. package/dist/device/contact.d.ts +9 -4
  19. package/dist/device/contact.d.ts.map +1 -1
  20. package/dist/device/contact.js +121 -200
  21. package/dist/device/contact.js.map +1 -1
  22. package/dist/device/curtain.d.ts +20 -7
  23. package/dist/device/curtain.d.ts.map +1 -1
  24. package/dist/device/curtain.js +229 -403
  25. package/dist/device/curtain.js.map +1 -1
  26. package/dist/device/device.d.ts +41 -22
  27. package/dist/device/device.d.ts.map +1 -1
  28. package/dist/device/device.js +212 -181
  29. package/dist/device/device.js.map +1 -1
  30. package/dist/device/fan.d.ts +9 -4
  31. package/dist/device/fan.d.ts.map +1 -1
  32. package/dist/device/fan.js +204 -249
  33. package/dist/device/fan.js.map +1 -1
  34. package/dist/device/hub.d.ts +9 -5
  35. package/dist/device/hub.d.ts.map +1 -1
  36. package/dist/device/hub.js +107 -233
  37. package/dist/device/hub.js.map +1 -1
  38. package/dist/device/humidifier.d.ts +12 -4
  39. package/dist/device/humidifier.d.ts.map +1 -1
  40. package/dist/device/humidifier.js +193 -235
  41. package/dist/device/humidifier.js.map +1 -1
  42. package/dist/device/iosensor.d.ts +9 -4
  43. package/dist/device/iosensor.d.ts.map +1 -1
  44. package/dist/device/iosensor.js +92 -159
  45. package/dist/device/iosensor.js.map +1 -1
  46. package/dist/device/lightstrip.d.ts +10 -5
  47. package/dist/device/lightstrip.d.ts.map +1 -1
  48. package/dist/device/lightstrip.js +288 -370
  49. package/dist/device/lightstrip.js.map +1 -1
  50. package/dist/device/lock.d.ts +10 -5
  51. package/dist/device/lock.d.ts.map +1 -1
  52. package/dist/device/lock.js +172 -219
  53. package/dist/device/lock.js.map +1 -1
  54. package/dist/device/meter.d.ts +9 -4
  55. package/dist/device/meter.d.ts.map +1 -1
  56. package/dist/device/meter.js +94 -160
  57. package/dist/device/meter.js.map +1 -1
  58. package/dist/device/meterplus.d.ts +9 -4
  59. package/dist/device/meterplus.d.ts.map +1 -1
  60. package/dist/device/meterplus.js +95 -157
  61. package/dist/device/meterplus.js.map +1 -1
  62. package/dist/device/motion.d.ts +9 -4
  63. package/dist/device/motion.d.ts.map +1 -1
  64. package/dist/device/motion.js +85 -144
  65. package/dist/device/motion.js.map +1 -1
  66. package/dist/device/plug.d.ts +9 -4
  67. package/dist/device/plug.d.ts.map +1 -1
  68. package/dist/device/plug.js +100 -127
  69. package/dist/device/plug.js.map +1 -1
  70. package/dist/device/robotvacuumcleaner.d.ts +9 -6
  71. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  72. package/dist/device/robotvacuumcleaner.js +172 -259
  73. package/dist/device/robotvacuumcleaner.js.map +1 -1
  74. package/dist/device/waterdetector.d.ts +12 -4
  75. package/dist/device/waterdetector.d.ts.map +1 -1
  76. package/dist/device/waterdetector.js +106 -131
  77. package/dist/device/waterdetector.js.map +1 -1
  78. package/dist/irdevice/airconditioner.d.ts +2 -1
  79. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  80. package/dist/irdevice/airconditioner.js +2 -3
  81. package/dist/irdevice/airconditioner.js.map +1 -1
  82. package/dist/irdevice/airpurifier.d.ts +2 -1
  83. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  84. package/dist/irdevice/airpurifier.js +2 -3
  85. package/dist/irdevice/airpurifier.js.map +1 -1
  86. package/dist/irdevice/camera.d.ts +2 -1
  87. package/dist/irdevice/camera.d.ts.map +1 -1
  88. package/dist/irdevice/camera.js +2 -3
  89. package/dist/irdevice/camera.js.map +1 -1
  90. package/dist/irdevice/fan.d.ts +2 -1
  91. package/dist/irdevice/fan.d.ts.map +1 -1
  92. package/dist/irdevice/fan.js +2 -3
  93. package/dist/irdevice/fan.js.map +1 -1
  94. package/dist/irdevice/irdevice.d.ts +3 -1
  95. package/dist/irdevice/irdevice.d.ts.map +1 -1
  96. package/dist/irdevice/irdevice.js +5 -1
  97. package/dist/irdevice/irdevice.js.map +1 -1
  98. package/dist/irdevice/light.d.ts +2 -1
  99. package/dist/irdevice/light.d.ts.map +1 -1
  100. package/dist/irdevice/light.js +2 -3
  101. package/dist/irdevice/light.js.map +1 -1
  102. package/dist/irdevice/other.d.ts +2 -1
  103. package/dist/irdevice/other.d.ts.map +1 -1
  104. package/dist/irdevice/other.js +2 -3
  105. package/dist/irdevice/other.js.map +1 -1
  106. package/dist/irdevice/tv.d.ts +2 -1
  107. package/dist/irdevice/tv.d.ts.map +1 -1
  108. package/dist/irdevice/tv.js +2 -3
  109. package/dist/irdevice/tv.js.map +1 -1
  110. package/dist/irdevice/vacuumcleaner.d.ts +2 -1
  111. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  112. package/dist/irdevice/vacuumcleaner.js +2 -3
  113. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  114. package/dist/irdevice/waterheater.d.ts +2 -1
  115. package/dist/irdevice/waterheater.d.ts.map +1 -1
  116. package/dist/irdevice/waterheater.js +2 -3
  117. package/dist/irdevice/waterheater.js.map +1 -1
  118. package/dist/platform.d.ts +14 -14
  119. package/dist/platform.d.ts.map +1 -1
  120. package/dist/platform.js +102 -86
  121. package/dist/platform.js.map +1 -1
  122. package/dist/settings.d.ts +49 -190
  123. package/dist/settings.d.ts.map +1 -1
  124. package/dist/settings.js +19 -0
  125. package/dist/settings.js.map +1 -1
  126. package/dist/types/bledevicestatus.d.ts +279 -0
  127. package/dist/types/bledevicestatus.d.ts.map +1 -0
  128. package/dist/types/bledevicestatus.js +2 -0
  129. package/dist/types/bledevicestatus.js.map +1 -0
  130. package/dist/types/devicelist.d.ts +89 -0
  131. package/dist/types/devicelist.d.ts.map +1 -0
  132. package/dist/types/devicelist.js +6 -0
  133. package/dist/types/devicelist.js.map +1 -0
  134. package/dist/types/deviceresponse.d.ts +13 -0
  135. package/dist/types/deviceresponse.d.ts.map +1 -0
  136. package/dist/types/deviceresponse.js +2 -0
  137. package/dist/types/deviceresponse.js.map +1 -0
  138. package/dist/types/devicestatus.d.ts +149 -0
  139. package/dist/types/devicestatus.d.ts.map +1 -0
  140. package/dist/types/devicestatus.js +3 -0
  141. package/dist/types/devicestatus.js.map +1 -0
  142. package/dist/types/devicewebhookstatus.d.ts +156 -0
  143. package/dist/types/devicewebhookstatus.d.ts.map +1 -0
  144. package/dist/types/devicewebhookstatus.js +2 -0
  145. package/dist/types/devicewebhookstatus.js.map +1 -0
  146. package/dist/types/irdevicelist.d.ts +10 -0
  147. package/dist/types/irdevicelist.d.ts.map +1 -0
  148. package/dist/types/irdevicelist.js +2 -0
  149. package/dist/types/irdevicelist.js.map +1 -0
  150. package/dist/types/pushbody.d.ts +6 -0
  151. package/dist/types/pushbody.d.ts.map +1 -0
  152. package/dist/types/pushbody.js +2 -0
  153. package/dist/types/pushbody.js.map +1 -0
  154. package/dist/utils.d.ts +25 -0
  155. package/dist/utils.d.ts.map +1 -1
  156. package/dist/utils.js +28 -0
  157. package/dist/utils.js.map +1 -1
  158. package/package.json +11 -11
  159. package/src/device/blindtilt.ts +254 -376
  160. package/src/device/bot.ts +209 -224
  161. package/src/device/ceilinglight.ts +227 -297
  162. package/src/device/colorbulb.ts +345 -435
  163. package/src/device/contact.ts +139 -200
  164. package/src/device/curtain.ts +254 -414
  165. package/src/device/device.ts +221 -190
  166. package/src/device/fan.ts +222 -253
  167. package/src/device/hub.ts +127 -248
  168. package/src/device/humidifier.ts +217 -246
  169. package/src/device/iosensor.ts +115 -168
  170. package/src/device/lightstrip.ts +303 -380
  171. package/src/device/lock.ts +188 -224
  172. package/src/device/meter.ts +117 -179
  173. package/src/device/meterplus.ts +118 -176
  174. package/src/device/motion.ts +100 -146
  175. package/src/device/plug.ts +111 -131
  176. package/src/device/robotvacuumcleaner.ts +191 -258
  177. package/src/device/waterdetector.ts +124 -141
  178. package/src/irdevice/airconditioner.ts +4 -4
  179. package/src/irdevice/airpurifier.ts +4 -4
  180. package/src/irdevice/camera.ts +4 -4
  181. package/src/irdevice/fan.ts +4 -4
  182. package/src/irdevice/irdevice.ts +8 -2
  183. package/src/irdevice/light.ts +4 -4
  184. package/src/irdevice/other.ts +4 -4
  185. package/src/irdevice/tv.ts +4 -4
  186. package/src/irdevice/vacuumcleaner.ts +4 -4
  187. package/src/irdevice/waterheater.ts +4 -4
  188. package/src/platform.ts +104 -87
  189. package/src/settings.ts +30 -238
  190. package/src/types/bledevicestatus.ts +305 -0
  191. package/src/types/devicelist.ts +124 -0
  192. package/src/types/deviceresponse.ts +15 -0
  193. package/src/types/devicestatus.ts +178 -0
  194. package/src/types/devicewebhookstatus.ts +196 -0
  195. package/src/types/irdevicelist.ts +15 -0
  196. package/src/types/pushbody.ts +9 -0
  197. package/src/utils.ts +33 -0
@@ -3,8 +3,8 @@
3
3
  * lock.ts: @switchbot/homebridge-switchbot.
4
4
  */
5
5
  import { deviceBase } from './device.js';
6
- import { interval, Subject } from 'rxjs';
7
- import { debounceTime, skipWhile, take, tap } from 'rxjs/operators';
6
+ import { SwitchBotBLEModel, SwitchBotBLEModelName } from 'node-switchbot';
7
+ import { Subject, debounceTime, interval, skipWhile, take, tap } from 'rxjs';
8
8
  export class Lock extends deviceBase {
9
9
  platform;
10
10
  // Services
@@ -114,14 +114,14 @@ export class Lock extends deviceBase {
114
114
  this.refreshStatus();
115
115
  // Update Homekit
116
116
  this.updateHomeKitCharacteristics();
117
+ //regisiter webhook event handler
118
+ this.registerWebhook();
117
119
  // Start an update interval
118
120
  interval(this.deviceRefreshRate * 1000)
119
121
  .pipe(skipWhile(() => this.lockUpdateInProgress))
120
122
  .subscribe(async () => {
121
123
  await this.refreshStatus();
122
124
  });
123
- //regisiter webhook event handler
124
- this.registerWebhook(accessory, device);
125
125
  // Watch for Lock change events
126
126
  // We put in a debounce of 100ms so we don't make duplicate calls
127
127
  this.doLockUpdate
@@ -133,86 +133,64 @@ export class Lock extends deviceBase {
133
133
  await this.pushChanges();
134
134
  }
135
135
  catch (e) {
136
- this.apiError(e);
137
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType} Connection,`
138
- + ` Error Message: ${JSON.stringify(e.message)}`);
136
+ await this.apiError(e);
137
+ await this.errorLog(`failed pushChanges with ${device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
139
138
  }
140
139
  this.lockUpdateInProgress = false;
141
140
  });
142
141
  }
143
142
  async BLEparseStatus(serviceData) {
144
- // BLE Status
145
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLEparseStatus`);
146
- switch (serviceData.status) {
147
- case 'locked':
148
- this.LockMechanism.LockCurrentState = this.hap.Characteristic.LockCurrentState.SECURED;
149
- this.LockMechanism.LockTargetState = this.hap.Characteristic.LockTargetState.SECURED;
150
- break;
151
- default:
152
- this.LockMechanism.LockCurrentState = this.hap.Characteristic.LockCurrentState.UNSECURED;
153
- this.LockMechanism.LockTargetState = this.hap.Characteristic.LockTargetState.UNSECURED;
154
- }
155
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
156
- + ` LockTargetState: ${this.LockMechanism.LockTargetState}, LockCurrentState: ${this.LockMechanism.LockCurrentState}`);
143
+ await this.debugLog('BLEparseStatus');
144
+ // LockCurrentState
145
+ this.LockMechanism.LockCurrentState = serviceData.status === 'locked'
146
+ ? this.hap.Characteristic.LockCurrentState.SECURED : this.hap.Characteristic.LockCurrentState.UNSECURED;
147
+ await this.debugLog(`LockCurrentState: ${this.LockMechanism.LockCurrentState}`);
148
+ // LockTargetState
149
+ this.LockMechanism.LockTargetState = serviceData.status === 'locked'
150
+ ? this.hap.Characteristic.LockTargetState.SECURED : this.hap.Characteristic.LockTargetState.UNSECURED;
151
+ await this.debugLog(`LockTargetState: ${this.LockMechanism.LockTargetState}`);
157
152
  // Contact Sensor
158
- if (!this.device.lock?.hide_contactsensor) {
159
- switch (serviceData.door_open) {
160
- case 'opened':
161
- this.ContactSensor.ContactSensorState = this.hap.Characteristic.ContactSensorState.CONTACT_NOT_DETECTED;
162
- break;
163
- default:
164
- this.ContactSensor.ContactSensorState = this.hap.Characteristic.ContactSensorState.CONTACT_DETECTED;
165
- }
166
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ContactSensorState: ${this.ContactSensor.ContactSensorState}`);
153
+ if (!this.device.lock?.hide_contactsensor && this.ContactSensor?.Service) {
154
+ this.ContactSensor.ContactSensorState = serviceData.door_open === 'opened'
155
+ ? this.hap.Characteristic.ContactSensorState.CONTACT_NOT_DETECTED : this.hap.Characteristic.ContactSensorState.CONTACT_DETECTED;
156
+ await this.debugLog(`ContactSensorState: ${this.ContactSensor.ContactSensorState}`);
167
157
  }
168
- // Battery
158
+ // BatteryLevel
169
159
  this.Battery.BatteryLevel = Number(serviceData.battery);
170
- if (this.Battery.BatteryLevel < 10) {
171
- this.Battery.StatusLowBattery = this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
172
- }
173
- else {
174
- this.Battery.StatusLowBattery = this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
175
- }
176
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
177
- + ` BatteryLevel: ${this.Battery.BatteryLevel}, StatusLowBattery: ${this.Battery.StatusLowBattery}`);
160
+ await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
161
+ // StatusLowBattery
162
+ this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
163
+ ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
164
+ await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
178
165
  }
179
166
  async openAPIparseStatus(deviceStatus) {
180
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIparseStatus`);
181
- switch (deviceStatus.body.lockState) {
182
- case 'locked':
183
- this.LockMechanism.LockCurrentState = this.hap.Characteristic.LockCurrentState.SECURED;
184
- this.LockMechanism.LockTargetState = this.hap.Characteristic.LockTargetState.SECURED;
185
- break;
186
- default:
187
- this.LockMechanism.LockCurrentState = this.hap.Characteristic.LockCurrentState.UNSECURED;
188
- this.LockMechanism.LockTargetState = this.hap.Characteristic.LockTargetState.UNSECURED;
189
- }
190
- switch (deviceStatus.body.doorState) {
191
- case 'opened':
192
- this.ContactSensor.ContactSensorState = this.hap.Characteristic.ContactSensorState.CONTACT_NOT_DETECTED;
193
- break;
194
- default:
195
- this.ContactSensor.ContactSensorState = this.hap.Characteristic.ContactSensorState.CONTACT_DETECTED;
196
- }
197
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.LockMechanism.LockTargetState}`);
198
- // Battery
199
- this.Battery.BatteryLevel = Number(deviceStatus.body.battery);
200
- if (this.Battery.BatteryLevel < 10) {
201
- this.Battery.StatusLowBattery = this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
202
- }
203
- else {
204
- this.Battery.StatusLowBattery = this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
205
- }
206
- if (Number.isNaN(this.Battery.BatteryLevel)) {
207
- this.Battery.BatteryLevel = 100;
208
- }
209
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.Battery.BatteryLevel},`
210
- + ` StatusLowBattery: ${this.Battery.StatusLowBattery}`);
167
+ await this.debugLog('openAPIparseStatus');
168
+ // LockCurrentState
169
+ this.LockMechanism.LockCurrentState = deviceStatus.lockState === 'locked'
170
+ ? this.hap.Characteristic.LockCurrentState.SECURED : this.hap.Characteristic.LockCurrentState.UNSECURED;
171
+ await this.debugLog(`LockCurrentState: ${this.LockMechanism.LockCurrentState}`);
172
+ // LockTargetState
173
+ this.LockMechanism.LockTargetState = deviceStatus.lockState === 'locked'
174
+ ? this.hap.Characteristic.LockTargetState.SECURED : this.hap.Characteristic.LockTargetState.UNSECURED;
175
+ await this.debugLog(`LockTargetState: ${this.LockMechanism.LockTargetState}`);
176
+ // ContactSensorState
177
+ if (!this.device.lock?.hide_contactsensor && this.ContactSensor?.Service) {
178
+ this.ContactSensor.ContactSensorState = deviceStatus.doorState === 'opened'
179
+ ? this.hap.Characteristic.ContactSensorState.CONTACT_NOT_DETECTED : this.hap.Characteristic.ContactSensorState.CONTACT_DETECTED;
180
+ await this.debugLog(`ContactSensorState: ${this.ContactSensor.ContactSensorState}`);
181
+ }
182
+ // BatteryLevel
183
+ this.Battery.BatteryLevel = Number(deviceStatus.battery);
184
+ await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
185
+ // StatusLowBattery
186
+ this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
187
+ ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
188
+ await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
211
189
  // Firmware Version
212
- const version = deviceStatus.body.version?.toString();
213
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Firmware Version: ${version?.replace(/^V|-.*$/g, '')}`);
214
- if (deviceStatus.body.version) {
215
- const deviceVersion = version?.replace(/^V|-.*$/g, '') ?? '0.0.0';
190
+ if (deviceStatus.version) {
191
+ const version = deviceStatus.version.toString();
192
+ await this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`);
193
+ const deviceVersion = version.replace(/^V|-.*$/g, '') ?? '0.0.0';
216
194
  this.accessory
217
195
  .getService(this.hap.Service.AccessoryInformation)
218
196
  .setCharacteristic(this.hap.Characteristic.HardwareRevision, deviceVersion)
@@ -220,15 +198,27 @@ export class Lock extends deviceBase {
220
198
  .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
221
199
  .updateValue(deviceVersion);
222
200
  this.accessory.context.deviceVersion = deviceVersion;
223
- this.debugSuccessLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceVersion: ${this.accessory.context.deviceVersion}`);
201
+ await this.debugSuccessLog(`deviceVersion: ${this.accessory.context.deviceVersion}`);
224
202
  }
225
203
  }
204
+ async parseStatusWebhook(context) {
205
+ await this.debugLog('parseStatusWebhook');
206
+ await this.debugLog(`(lockState) = Webhook:(${context.lockState}), current:(${this.LockMechanism.LockCurrentState})`);
207
+ // LockCurrentState
208
+ this.LockMechanism.LockCurrentState = context.lockState === 'LOCKED'
209
+ ? this.hap.Characteristic.LockCurrentState.SECURED : this.hap.Characteristic.LockCurrentState.UNSECURED;
210
+ await this.debugLog(`LockCurrentState: ${this.LockMechanism.LockCurrentState}`);
211
+ // LockTargetState
212
+ this.LockMechanism.LockTargetState = context.lockState === 'LOCKED'
213
+ ? this.hap.Characteristic.LockTargetState.SECURED : this.hap.Characteristic.LockTargetState.UNSECURED;
214
+ await this.debugLog(`LockTargetState: ${this.LockMechanism.LockTargetState}`);
215
+ }
226
216
  /**
227
217
  * Asks the SwitchBot API for the latest device information
228
218
  */
229
219
  async refreshStatus() {
230
220
  if (!this.device.enableCloudService && this.OpenAPI) {
231
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus enableCloudService: ${this.device.enableCloudService}`);
221
+ await this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`);
232
222
  }
233
223
  else if (this.BLE) {
234
224
  await this.BLERefreshStatus();
@@ -238,12 +228,11 @@ export class Lock extends deviceBase {
238
228
  }
239
229
  else {
240
230
  await this.offlineOff();
241
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
242
- + ` ${this.device.connectionType}, refreshStatus will not happen.`);
231
+ await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`);
243
232
  }
244
233
  }
245
234
  async BLERefreshStatus() {
246
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLERefreshStatus`);
235
+ await this.debugLog('BLERefreshStatus');
247
236
  const switchbot = await this.switchbotBLE();
248
237
  if (switchbot === undefined) {
249
238
  await this.BLERefreshConnection(switchbot);
@@ -254,58 +243,56 @@ export class Lock extends deviceBase {
254
243
  // Start to monitor advertisement packets
255
244
  const serviceData = await this.monitorAdvertisementPackets(switchbot);
256
245
  // Update HomeKit
257
- if (serviceData.model !== '' && serviceData.modelName !== '') {
246
+ if ((serviceData.model === SwitchBotBLEModel.Lock || SwitchBotBLEModel.LockPro)
247
+ && (serviceData.modelName === SwitchBotBLEModelName.Lock || SwitchBotBLEModelName.LockPro)) {
258
248
  await this.BLEparseStatus(serviceData);
259
249
  await this.updateHomeKitCharacteristics();
260
250
  }
261
251
  else {
262
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed to get serviceData, serviceData: ${serviceData}`);
252
+ await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`);
263
253
  await this.BLERefreshConnection(switchbot);
264
254
  }
265
255
  })();
266
256
  }
267
257
  }
268
258
  async openAPIRefreshStatus() {
269
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus`);
259
+ await this.debugLog('openAPIRefreshStatus');
270
260
  try {
271
261
  const { body, statusCode } = await this.deviceRefreshStatus();
272
262
  const deviceStatus = await body.json();
273
- await this.refreshStatusCodes(statusCode, deviceStatus);
263
+ await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
274
264
  ;
275
- if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
276
- await this.successfulRefreshStatus(statusCode, deviceStatus);
277
- await this.openAPIparseStatus(deviceStatus);
265
+ if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
266
+ await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
267
+ await this.openAPIparseStatus(deviceStatus.body);
278
268
  await this.updateHomeKitCharacteristics();
279
269
  }
280
270
  else {
281
- await this.statusCodes(statusCode, deviceStatus);
271
+ await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
272
+ await this.debugWarnLog(statusCode, deviceStatus);
282
273
  }
283
274
  }
284
275
  catch (e) {
285
- this.apiError(e);
286
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}`
287
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
276
+ await this.apiError(e);
277
+ await this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
288
278
  }
289
279
  }
290
- async registerWebhook(accessory, device) {
291
- if (device.webhook) {
292
- this.debugLog(`${device.deviceType}: ${accessory.displayName} is listening webhook.`);
293
- this.platform.webhookEventHandler[device.deviceId] = async (context) => {
280
+ async registerWebhook() {
281
+ if (this.device.webhook) {
282
+ await this.debugLog('is listening webhook.');
283
+ this.platform.webhookEventHandler[this.device.deviceId] = async (context) => {
294
284
  try {
295
- this.debugLog(`${device.deviceType}: ${accessory.displayName} received Webhook: ${JSON.stringify(context)}`);
296
- const { lockState } = context;
297
- const { LockCurrentState } = this.LockMechanism;
298
- this.debugLog(`${device.deviceType}: ${accessory.displayName} (lockState) = Webhook:(${lockState}), current:(${LockCurrentState})`);
299
- this.LockMechanism.LockCurrentState = lockState === 'LOCKED' ? 1 : 0;
300
- this.updateHomeKitCharacteristics();
285
+ await this.debugLog(`received Webhook: ${JSON.stringify(context)}`);
286
+ await this.parseStatusWebhook(context);
287
+ await this.updateHomeKitCharacteristics();
301
288
  }
302
289
  catch (e) {
303
- this.errorLog(`${device.deviceType}: ${accessory.displayName} failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e}`);
290
+ await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e}`);
304
291
  }
305
292
  };
306
293
  }
307
294
  else {
308
- this.debugLog(`${device.deviceType}: ${accessory.displayName} is not listening webhook.`);
295
+ await this.debugLog('is not listening webhook.');
309
296
  }
310
297
  }
311
298
  /**
@@ -316,7 +303,7 @@ export class Lock extends deviceBase {
316
303
  */
317
304
  async pushChanges() {
318
305
  if (!this.device.enableCloudService && this.OpenAPI) {
319
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
306
+ await this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`);
320
307
  }
321
308
  else if (this.BLE) {
322
309
  await this.BLEpushChanges();
@@ -326,8 +313,7 @@ export class Lock extends deviceBase {
326
313
  }
327
314
  else {
328
315
  await this.offlineOff();
329
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
330
- + ` ${this.device.connectionType}, pushChanges will not happen.`);
316
+ await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, pushChanges will not happen.`);
331
317
  }
332
318
  // Refresh the status from the API
333
319
  interval(15000)
@@ -338,60 +324,63 @@ export class Lock extends deviceBase {
338
324
  });
339
325
  }
340
326
  async BLEpushChanges() {
341
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLEpushChanges`);
327
+ await this.debugLog('BLEpushChanges');
342
328
  if (this.LockMechanism.LockTargetState !== this.accessory.context.LockTargetState) {
343
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLEpushChanges LockTargetState: ${this.LockMechanism.LockTargetState}`
344
- + ` LockTargetStateCached: ${this.accessory.context.LockTargetState}`);
345
- const switchbot = await this.platform.connectBLE();
346
- // Convert to BLE Address
329
+ const switchbot = await this.platform.connectBLE(this.accessory, this.device);
347
330
  await this.convertBLEAddress();
348
- switchbot
349
- .discover({
350
- model: '',
351
- id: this.device.bleMac,
352
- })
353
- .then(() => {
354
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Done.`);
355
- this.successLog(`${this.device.deviceType}: ${this.accessory.displayName} `
356
- + `LockTargetState: ${this.LockMechanism.LockTargetState} sent over BLE, sent successfully`);
357
- this.LockMechanism.LockTargetState = this.hap.Characteristic.LockTargetState.SECURED;
358
- })
359
- .catch(async (e) => {
360
- this.apiError(e);
361
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed BLEpushChanges with ${this.device.connectionType}`
362
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
331
+ if (switchbot !== false) {
332
+ switchbot
333
+ .discover({ model: this.device.bleModel, id: this.device.bleMac })
334
+ .then(async (device_list) => {
335
+ return await this.retryBLE({
336
+ max: await this.maxRetryBLE(),
337
+ fn: async () => {
338
+ if (this.LockMechanism.LockTargetState === this.hap.Characteristic.LockTargetState.SECURED) {
339
+ return await device_list[0].lock({ id: this.device.bleMac });
340
+ }
341
+ else {
342
+ return await device_list[0].unlock({ id: this.device.bleMac });
343
+ }
344
+ },
345
+ });
346
+ })
347
+ .then(async () => {
348
+ await this.successLog(`LockTargetState: ${this.LockMechanism.LockTargetState} sent over SwitchBot BLE, sent successfully`);
349
+ await this.updateHomeKitCharacteristics();
350
+ })
351
+ .catch(async (e) => {
352
+ await this.apiError(e);
353
+ await this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
354
+ await this.BLEPushConnection();
355
+ });
356
+ }
357
+ else {
358
+ await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
363
359
  await this.BLEPushConnection();
364
- });
360
+ }
365
361
  }
366
362
  else {
367
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No BLEpushChanges.`
368
- + `LockTargetState: ${this.LockMechanism.LockTargetState}, `
369
- + `LockTargetStateCached: ${this.accessory.context.LockTargetState}`);
363
+ await this.debugLog(`No changes (BLEpushChanges), LockTargetState: ${this.LockMechanism.LockTargetState},`
364
+ + ` LockCurrentState: ${this.LockMechanism.LockCurrentState}`);
370
365
  }
371
366
  }
372
367
  async openAPIpushChanges(LatchUnlock) {
373
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIpushChanges`);
368
+ await this.debugLog('openAPIpushChanges');
374
369
  if ((this.LockMechanism.LockTargetState !== this.accessory.context.LockTargetState) || LatchUnlock) {
375
370
  // Determine the command based on the LockTargetState or the forceUnlock parameter
376
- let command = '';
377
- if (LatchUnlock) {
378
- command = 'unlock';
379
- }
380
- else {
381
- command = this.LockMechanism.LockTargetState ? 'lock' : 'unlock';
382
- }
371
+ const command = LatchUnlock ? 'unlock' : this.LockMechanism.LockTargetState ? 'lock' : 'unlock';
383
372
  const bodyChange = JSON.stringify({
384
373
  command: `${command}`,
385
374
  parameter: 'default',
386
375
  commandType: 'command',
387
376
  });
388
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
377
+ await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
389
378
  try {
390
379
  const { body, statusCode } = await this.pushChangeRequest(bodyChange);
391
380
  const deviceStatus = await body.json();
392
- await this.pushStatusCodes(statusCode, deviceStatus);
393
- if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
394
- await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
381
+ await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
382
+ if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
383
+ await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
395
384
  await this.updateHomeKitCharacteristics();
396
385
  }
397
386
  else {
@@ -400,25 +389,24 @@ export class Lock extends deviceBase {
400
389
  }
401
390
  }
402
391
  catch (e) {
403
- this.apiError(e);
404
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIpushChanges with ${this.device.connectionType}`
405
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
392
+ await this.apiError(e);
393
+ await this.errorLog(`failed openAPIpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
406
394
  }
407
395
  }
408
396
  else {
409
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No openAPIpushChanges, LockTargetState: `
410
- + `${this.LockMechanism.LockTargetState}, LockTargetStateCached: ${this.accessory.context.LockTargetState}`);
397
+ await this.debugLog(`No changes (openAPIpushChanges), LockCurrentState: ${this.LockMechanism.LockCurrentState},`
398
+ + ` TargetPosition: ${this.LockMechanism.LockTargetState}`);
411
399
  }
412
400
  }
413
401
  /**
414
402
  * Handle requests to set the value of the "On" characteristic
415
403
  */
416
404
  async LockTargetStateSet(value) {
417
- if (this.LockMechanism.LockTargetState === this.accessory.context.LockTargetState) {
418
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No Changes, Set LockTargetState: ${value}`);
405
+ if (this.LockMechanism.LockTargetState !== this.accessory.context.LockTargetState) {
406
+ await this.infoLog(`Set LockTargetState: ${value}`);
419
407
  }
420
408
  else {
421
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set LockTargetState: ${value}`);
409
+ await this.debugLog(`No Changes, LockTargetState: ${value}`);
422
410
  }
423
411
  this.LockMechanism.LockTargetState = value;
424
412
  this.doLockUpdate.next();
@@ -427,116 +415,81 @@ export class Lock extends deviceBase {
427
415
  * Handle requests to set the value of the "On" characteristic
428
416
  */
429
417
  async OnSet(value) {
430
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Latch Button Set On: ${value}`);
418
+ await this.debugLog(`Latch Button Set On: ${value}`);
431
419
  if (value) {
432
- this.debugLog('Attempting to open the latch');
433
- this.openAPIpushChanges(value).then(() => {
434
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Latch opened successfully`);
435
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
436
- + ` SwitchService is: ${this.Switch.Service ? 'available' : 'not available'}`);
420
+ await this.debugLog('Attempting to open the latch');
421
+ this.openAPIpushChanges(value).then(async () => {
422
+ await this.debugLog('Latch opened successfully');
423
+ await this.debugLog(`SwitchService is: ${this.Switch?.Service ? 'available' : 'not available'}`);
437
424
  // simulate button press to turn the switch back off
438
- if (this.Switch.Service) {
425
+ if (this.Switch?.Service) {
439
426
  const SwitchService = this.Switch.Service;
440
427
  // Simulate a button press by waiting a short period before turning the switch off
441
- setTimeout(() => {
428
+ setTimeout(async () => {
442
429
  SwitchService.getCharacteristic(this.hap.Characteristic.On).updateValue(false);
443
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Latch button switched off automatically.`);
430
+ await this.debugLog('Latch button switched off automatically.');
444
431
  }, 500); // 500 ms delay
445
432
  }
446
- }).catch((e) => {
433
+ }).catch(async (e) => {
447
434
  // Log the error if the operation failed
448
- this.debugLog(`Error opening latch: ${e}`);
435
+ await this.debugLog(`Error opening latch: ${e}`);
449
436
  // Ensure we turn the switch back off even in case of an error
450
- if (this.Switch.Service) {
437
+ if (this.Switch?.Service) {
451
438
  this.Switch.Service.getCharacteristic(this.hap.Characteristic.On).updateValue(false);
452
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Latch button switched off after an error.`);
439
+ await this.debugLog('Latch button switched off after an error.');
453
440
  }
454
441
  });
455
442
  }
456
443
  else {
457
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Switch is off, nothing to do`);
444
+ await this.debugLog('Switch is off, nothing to do');
458
445
  }
459
446
  this.Switch.On = value;
460
447
  this.doLockUpdate.next();
461
448
  }
462
449
  async updateHomeKitCharacteristics() {
463
- if (!this.device.lock?.hide_contactsensor) {
464
- if (this.ContactSensor.ContactSensorState === undefined) {
465
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ContactSensorState: ${this.ContactSensor.ContactSensorState}`);
466
- }
467
- else {
468
- this.accessory.context.ContactSensorState = this.ContactSensor.ContactSensorState;
469
- this.ContactSensor.Service.updateCharacteristic(this.hap.Characteristic.ContactSensorState, this.ContactSensor.ContactSensorState);
470
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
471
- + ` ContactSensorState: ${this.ContactSensor.ContactSensorState}`);
472
- }
473
- }
474
- if (this.LockMechanism.LockTargetState === undefined) {
475
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LockTargetState: ${this.LockMechanism.LockTargetState}`);
476
- }
477
- else {
478
- this.accessory.context.LockTargetState = this.LockMechanism.LockTargetState;
479
- this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.LockMechanism.LockTargetState);
480
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
481
- + ` LockTargetState: ${this.LockMechanism.LockTargetState}`);
482
- }
483
- if (this.LockMechanism.LockCurrentState === undefined) {
484
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LockCurrentState: ${this.LockMechanism.LockCurrentState}`);
485
- }
486
- else {
487
- this.accessory.context.LockCurrentState = this.LockMechanism.LockCurrentState;
488
- this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.LockMechanism.LockCurrentState);
489
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
490
- + ` LockCurrentState: ${this.LockMechanism.LockCurrentState}`);
491
- }
492
- if (this.Battery.BatteryLevel === undefined) {
493
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.Battery.BatteryLevel}`);
494
- }
495
- else {
496
- this.accessory.context.BatteryLevel = this.Battery.BatteryLevel;
497
- this.Battery.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, this.Battery.BatteryLevel);
498
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
499
- + ` BatteryLevel: ${this.Battery.BatteryLevel}`);
500
- }
501
- if (this.Battery.StatusLowBattery === undefined) {
502
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatusLowBattery: ${this.Battery.StatusLowBattery}`);
503
- }
504
- else {
505
- this.accessory.context.StatusLowBattery = this.Battery.StatusLowBattery;
506
- this.Battery.Service.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, this.Battery.StatusLowBattery);
507
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
508
- + ` StatusLowBattery: ${this.Battery.StatusLowBattery}`);
509
- }
450
+ // LockCurrentState
451
+ await this.updateCharacteristic(this.LockMechanism.Service, this.hap.Characteristic.LockTargetState, this.LockMechanism.LockTargetState, 'LockTargetState');
452
+ // LockCurrentState
453
+ await this.updateCharacteristic(this.LockMechanism.Service, this.hap.Characteristic.LockCurrentState, this.LockMechanism.LockCurrentState, 'LockCurrentState');
454
+ // ContactSensorState
455
+ if (!this.device.lock?.hide_contactsensor && this.ContactSensor?.Service) {
456
+ await this.updateCharacteristic(this.ContactSensor.Service, this.hap.Characteristic.ContactSensorState, this.ContactSensor.ContactSensorState, 'ContactSensorState');
457
+ }
458
+ // BatteryLevel
459
+ await this.updateCharacteristic(this.Battery.Service, this.hap.Characteristic.BatteryLevel, this.Battery.BatteryLevel, 'BatteryLevel');
460
+ // StatusLowBattery
461
+ await this.updateCharacteristic(this.Battery.Service, this.hap.Characteristic.StatusLowBattery, this.Battery.StatusLowBattery, 'StatusLowBattery');
510
462
  }
511
463
  async BLEPushConnection() {
512
464
  if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
513
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Push Changes`);
465
+ await this.warnLog('Using OpenAPI Connection to Push Changes');
514
466
  await this.openAPIpushChanges();
515
467
  }
516
468
  }
517
469
  async BLERefreshConnection(switchbot) {
518
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot:`
519
- + ` ${JSON.stringify(switchbot)}`);
470
+ await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchbot)}`);
520
471
  if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
521
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Refresh Status`);
472
+ await this.warnLog('Using OpenAPI Connection to Refresh Status');
522
473
  await this.openAPIRefreshStatus();
523
474
  }
524
475
  }
525
476
  async offlineOff() {
526
477
  if (this.device.offline) {
527
- if (!this.device.lock?.hide_contactsensor) {
528
- this.ContactSensor.Service.updateCharacteristic(this.hap.Characteristic.ContactSensorState, this.hap.Characteristic.ContactSensorState.CONTACT_DETECTED);
529
- }
530
478
  this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.SECURED);
531
479
  this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.SECURED);
480
+ if (!this.device.lock?.hide_contactsensor && this.ContactSensor?.Service) {
481
+ this.ContactSensor.Service.updateCharacteristic(this.hap.Characteristic.ContactSensorState, this.hap.Characteristic.ContactSensorState.CONTACT_DETECTED);
482
+ }
532
483
  }
533
484
  }
534
485
  async apiError(e) {
535
- if (!this.device.lock?.hide_contactsensor) {
536
- this.ContactSensor.Service.updateCharacteristic(this.hap.Characteristic.ContactSensorState, e);
537
- }
538
486
  this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, e);
539
487
  this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, e);
488
+ if (!this.device.lock?.hide_contactsensor && this.ContactSensor?.Service) {
489
+ this.ContactSensor.Service.updateCharacteristic(this.hap.Characteristic.ContactSensorState, e);
490
+ }
491
+ this.Battery.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, e);
492
+ this.Battery.Service.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, e);
540
493
  }
541
494
  }
542
495
  //# sourceMappingURL=lock.js.map