@switchbot/homebridge-switchbot 4.1.3-beta.3 → 4.1.3

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 (54) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +4 -4
  3. package/dist/device/blindtilt.d.ts.map +1 -1
  4. package/dist/device/blindtilt.js +3 -2
  5. package/dist/device/blindtilt.js.map +1 -1
  6. package/dist/device/bot.d.ts.map +1 -1
  7. package/dist/device/bot.js +11 -8
  8. package/dist/device/bot.js.map +1 -1
  9. package/dist/device/contact.d.ts.map +1 -1
  10. package/dist/device/contact.js +11 -8
  11. package/dist/device/contact.js.map +1 -1
  12. package/dist/device/curtain.d.ts.map +1 -1
  13. package/dist/device/curtain.js +2 -1
  14. package/dist/device/curtain.js.map +1 -1
  15. package/dist/device/iosensor.d.ts.map +1 -1
  16. package/dist/device/iosensor.js +11 -8
  17. package/dist/device/iosensor.js.map +1 -1
  18. package/dist/device/lock.d.ts.map +1 -1
  19. package/dist/device/lock.js +11 -8
  20. package/dist/device/lock.js.map +1 -1
  21. package/dist/device/meter.d.ts.map +1 -1
  22. package/dist/device/meter.js +11 -8
  23. package/dist/device/meter.js.map +1 -1
  24. package/dist/device/meterplus.d.ts.map +1 -1
  25. package/dist/device/meterplus.js +11 -8
  26. package/dist/device/meterplus.js.map +1 -1
  27. package/dist/device/meterpro.d.ts.map +1 -1
  28. package/dist/device/meterpro.js +11 -8
  29. package/dist/device/meterpro.js.map +1 -1
  30. package/dist/device/motion.d.ts.map +1 -1
  31. package/dist/device/motion.js +11 -8
  32. package/dist/device/motion.js.map +1 -1
  33. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  34. package/dist/device/robotvacuumcleaner.js +11 -8
  35. package/dist/device/robotvacuumcleaner.js.map +1 -1
  36. package/dist/device/waterdetector.d.ts.map +1 -1
  37. package/dist/device/waterdetector.js +9 -8
  38. package/dist/device/waterdetector.js.map +1 -1
  39. package/docs/functions/default.html +1 -1
  40. package/docs/index.html +4 -4
  41. package/package.json +1 -1
  42. package/src/device/blindtilt.ts +3 -4
  43. package/src/device/bot.ts +11 -10
  44. package/src/device/contact.ts +11 -8
  45. package/src/device/curtain.ts +2 -1
  46. package/src/device/iosensor.ts +11 -12
  47. package/src/device/lock.ts +11 -10
  48. package/src/device/meter.ts +11 -10
  49. package/src/device/meterplus.ts +11 -8
  50. package/src/device/meterpro.ts +11 -8
  51. package/src/device/motion.ts +11 -10
  52. package/src/device/robotvacuumcleaner.ts +11 -9
  53. package/src/device/waterdetector.ts +9 -8
  54. package/.github/npm-version-script.cjs +0 -81
@@ -1 +1 @@
1
- <!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>default | @switchbot/homebridge-switchbot</title><meta name="description" content="Documentation for @switchbot/homebridge-switchbot"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@switchbot/homebridge-switchbot</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">@switchbot/homebridge-switchbot</a></li><li><a href="default.html">default</a></li></ul><h1>Function default</h1></div><section class="tsd-panel"><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="default" class="tsd-anchor"></a><span class="tsd-kind-call-signature">default</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">api</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span><a href="#default" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">api</span>: <span class="tsd-signature-type">API</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/OpenWonderLabs/homebridge-switchbot/blob/ebf590a7c7b218e9a9b9124a9b16a90045eadfdc/src/index.ts#L11">index.ts:11</a></li></ul></aside></li></ul></section></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>@switchbot/homebridge-switchbot</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer></footer><div class="overlay"></div></body></html>
1
+ <!DOCTYPE html><html class="default" lang="en"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>default | @switchbot/homebridge-switchbot</title><meta name="description" content="Documentation for @switchbot/homebridge-switchbot"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@switchbot/homebridge-switchbot</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">@switchbot/homebridge-switchbot</a></li><li><a href="default.html">default</a></li></ul><h1>Function default</h1></div><section class="tsd-panel"><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="default" class="tsd-anchor"></a><span class="tsd-kind-call-signature">default</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">api</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span><a href="#default" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">api</span>: <span class="tsd-signature-type">API</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/OpenWonderLabs/homebridge-switchbot/blob/1b9e752ca7b712fe6d46effa37a8fdf0210381a0/src/index.ts#L11">index.ts:11</a></li></ul></aside></li></ul></section></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>@switchbot/homebridge-switchbot</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer></footer><div class="overlay"></div></body></html>
package/docs/index.html CHANGED
@@ -278,7 +278,7 @@ Without this step, then you will receive the following error when the swichbot p
278
278
  </li>
279
279
  <li><a href="https://us.switch-bot.com/products/switchbot-water-leak-detector" target="_blank" class="external">SwitchBot Water Leak Detector</a>
280
280
  <ul>
281
- <li>Supports OpenAPI Connection Only</li>
281
+ <li>Supports OpenAPI &amp; Bluetooth Low Energy (BLE) Connections</li>
282
282
  </ul>
283
283
  </li>
284
284
  </ul>
@@ -364,10 +364,10 @@ Without this step, then you will receive the following error when the swichbot p
364
364
  </li>
365
365
  </ul>
366
366
  <a id="md:switchbot-apis" class="tsd-anchor"></a><h2 class="tsd-anchor-link">SwitchBot APIs<a href="#md:switchbot-apis" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><ul>
367
- <li><a href="https://github.com/OpenWonderLabs/SwitchBotAPI" target="_blank" class="external">OpenWonderLabs/SwitchBotAPI</a></li>
368
- <li><a href="https://github.com/OpenWonderLabs/SwitchBotAPI-BLE" target="_blank" class="external">OpenWonderLabs/SwitchBotAPI-BLE</a>
367
+ <li><a href="https://github.com/OpenWonderLabs/node-switchbot" target="_blank" class="external">OpenWonderLabs/node-switchbot</a>
369
368
  <ul>
370
- <li><a href="https://github.com/OpenWonderLabs/node-switchbot" target="_blank" class="external">OpenWonderLabs/node-switchbot</a></li>
369
+ <li><a href="https://github.com/OpenWonderLabs/SwitchBotAPI" target="_blank" class="external">OpenWonderLabs/SwitchBotAPI</a></li>
370
+ <li><a href="https://github.com/OpenWonderLabs/SwitchBotAPI-BLE" target="_blank" class="external">OpenWonderLabs/SwitchBotAPI-BLE</a></li>
371
371
  </ul>
372
372
  </li>
373
373
  </ul>
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@switchbot/homebridge-switchbot",
3
3
  "displayName": "SwitchBot",
4
4
  "type": "module",
5
- "version": "4.1.3-beta.3",
5
+ "version": "4.1.3",
6
6
  "description": "The SwitchBot plugin allows you to access your SwitchBot device(s) from HomeKit.",
7
7
  "author": "SwitchBot <support@wondertechlabs.com> (https://github.com/SwitchBot)",
8
8
  "contributors": [
@@ -350,12 +350,11 @@ export class BlindTilt extends deviceBase {
350
350
  this.getLightLevel(this.serviceData.lightLevel, set_minLux, set_maxLux, spaceBetweenLevels)
351
351
  this.debugLog(`LightLevel: ${this.serviceData.lightLevel}, CurrentAmbientLightLevel: ${this.LightSensor!.CurrentAmbientLightLevel}`)
352
352
  }
353
-
354
- // BatteryLevel
355
- if (this.serviceData?.battery) {
353
+ // Battery Info
354
+ if (this.serviceData.battery) {
355
+ // BatteryLevel
356
356
  this.Battery.BatteryLevel = this.serviceData.battery
357
357
  this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
358
-
359
358
  // StatusLowBattery
360
359
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
361
360
  ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
package/src/device/bot.ts CHANGED
@@ -281,16 +281,17 @@ export class Bot extends deviceBase {
281
281
  const mode = this.serviceData.mode ? 'Switch' : 'Press'
282
282
  this.debugLog(`${mode} Mode, On: ${this.On}`)
283
283
  this.accessory.context.On = this.On
284
-
285
- // BatteryLevel
286
- this.Battery.BatteryLevel = this.serviceData.battery
287
- this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
288
-
289
- // StatusLowBattery
290
- this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
291
- ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
292
- : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
293
- this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
284
+ // Battery Info
285
+ if (this.serviceData.battery) {
286
+ // BatteryLevel
287
+ this.Battery.BatteryLevel = this.serviceData.battery
288
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
289
+ // StatusLowBattery
290
+ this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
291
+ ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
292
+ : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
293
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
294
+ }
294
295
  }
295
296
 
296
297
  /**
@@ -204,14 +204,17 @@ export class Contact extends deviceBase {
204
204
  this.LightSensor.CurrentAmbientLightLevel = this.getLightLevel(lightLevel, set_minLux, set_maxLux, 2)
205
205
  this.debugLog(`LightLevel: ${this.serviceData.lightLevel}, CurrentAmbientLightLevel: ${this.LightSensor.CurrentAmbientLightLevel}`)
206
206
  }
207
- // BatteryLevel
208
- this.Battery.BatteryLevel = this.serviceData.battery
209
- this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
210
- // StatusLowBattery
211
- this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
212
- ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
213
- : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
214
- this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
207
+ // Battery Info
208
+ if (this.serviceData.battery) {
209
+ // BatteryLevel
210
+ this.Battery.BatteryLevel = this.serviceData.battery
211
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
212
+ // StatusLowBattery
213
+ this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
214
+ ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
215
+ : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
216
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
217
+ }
215
218
  }
216
219
 
217
220
  async openAPIparseStatus(): Promise<void> {
@@ -391,8 +391,9 @@ export class Curtain extends deviceBase {
391
391
  this.LightSensor.CurrentAmbientLightLevel = this.getLightLevel(lightLevel, set_minLux, set_maxLux, 19)
392
392
  this.debugLog(`LightLevel: ${this.serviceData.lightLevel}, CurrentAmbientLightLevel: ${this.LightSensor.CurrentAmbientLightLevel}`)
393
393
  }
394
- // BatteryLevel
394
+ // Battery Info
395
395
  if (this.serviceData.battery) {
396
+ // BatteryLevel
396
397
  this.Battery.BatteryLevel = this.serviceData.battery
397
398
  this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
398
399
  // StatusLowBattery
@@ -178,23 +178,22 @@ export class IOSensor extends deviceBase {
178
178
  async BLEparseStatus(): Promise<void> {
179
179
  this.debugLog('BLEparseStatus')
180
180
  this.debugLog(`(battery, temperature, humidity) = BLE:(${this.serviceData.battery}, ${this.serviceData.celsius}, ${this.serviceData.humidity}), current:(${this.Battery.BatteryLevel}, ${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity})`)
181
-
182
- // BatteryLevel
183
- this.Battery.BatteryLevel = this.serviceData.battery
184
- this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
185
-
186
- // StatusLowBattery
187
- this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
188
- ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
189
- : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
190
- this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
191
-
181
+ // Battery Info
182
+ if (this.serviceData.battery) {
183
+ // BatteryLevel
184
+ this.Battery.BatteryLevel = this.serviceData.battery
185
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
186
+ // StatusLowBattery
187
+ this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
188
+ ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
189
+ : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
190
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
191
+ }
192
192
  // CurrentRelativeHumidity
193
193
  if (!(this.device as indoorOutdoorSensorConfig).hide_humidity && this.HumiditySensor?.Service) {
194
194
  this.HumiditySensor.CurrentRelativeHumidity = validHumidity(this.serviceData.humidity, 0, 100)
195
195
  this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}%`)
196
196
  }
197
-
198
197
  // Current Temperature
199
198
  if (!(this.device as indoorOutdoorSensorConfig).hide_temperature && this.TemperatureSensor?.Service) {
200
199
  const CELSIUS = this.serviceData.celsius < 0 ? 0 : this.serviceData.celsius > 100 ? 100 : this.serviceData.celsius
@@ -224,16 +224,17 @@ export class Lock extends deviceBase {
224
224
  : this.hap.Characteristic.ContactSensorState.CONTACT_DETECTED
225
225
  this.debugLog(`ContactSensorState: ${this.ContactSensor.ContactSensorState}`)
226
226
  }
227
-
228
- // BatteryLevel
229
- this.Battery.BatteryLevel = this.serviceData.battery
230
- this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
231
-
232
- // StatusLowBattery
233
- this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
234
- ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
235
- : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
236
- this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
227
+ // Battery Info
228
+ if (this.serviceData.battery) {
229
+ // BatteryLevel
230
+ this.Battery.BatteryLevel = this.serviceData.battery
231
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
232
+ // StatusLowBattery
233
+ this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
234
+ ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
235
+ : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
236
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
237
+ }
237
238
  }
238
239
 
239
240
  async openAPIparseStatus(): Promise<void> {
@@ -184,16 +184,17 @@ export class Meter extends deviceBase {
184
184
  this.TemperatureSensor.CurrentTemperature = CELSIUS
185
185
  this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}°c`)
186
186
  }
187
-
188
- // BatteryLevel
189
- this.Battery.BatteryLevel = this.serviceData.battery
190
- this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
191
-
192
- // StatusLowBattery
193
- this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
194
- ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
195
- : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
196
- this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
187
+ // Battery Info
188
+ if (this.serviceData.battery) {
189
+ // BatteryLevel
190
+ this.Battery.BatteryLevel = this.serviceData.battery
191
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
192
+ // StatusLowBattery
193
+ this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
194
+ ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
195
+ : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
196
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
197
+ }
197
198
  }
198
199
 
199
200
  async openAPIparseStatus(): Promise<void> {
@@ -188,14 +188,17 @@ export class MeterPlus extends deviceBase {
188
188
  this.TemperatureSensor.CurrentTemperature = CELSIUS
189
189
  this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}°c`)
190
190
  }
191
- // BatteryLevel
192
- this.Battery.BatteryLevel = this.serviceData.battery
193
- this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
194
- // StatusLowBattery
195
- this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
196
- ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
197
- : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
198
- this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
191
+ // Battery Info
192
+ if (this.serviceData.battery) {
193
+ // BatteryLevel
194
+ this.Battery.BatteryLevel = this.serviceData.battery
195
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
196
+ // StatusLowBattery
197
+ this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
198
+ ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
199
+ : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
200
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
201
+ }
199
202
  }
200
203
 
201
204
  async openAPIparseStatus(): Promise<void> {
@@ -188,14 +188,17 @@ export class MeterPro extends deviceBase {
188
188
  this.TemperatureSensor.CurrentTemperature = CELSIUS
189
189
  this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}°c`)
190
190
  }
191
- // BatteryLevel
192
- this.Battery.BatteryLevel = this.serviceData.battery
193
- this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
194
- // StatusLowBattery
195
- this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
196
- ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
197
- : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
198
- this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
191
+ // Battery Info
192
+ if (this.serviceData.battery) {
193
+ // BatteryLevel
194
+ this.Battery.BatteryLevel = this.serviceData.battery
195
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
196
+ // StatusLowBattery
197
+ this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
198
+ ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
199
+ : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
200
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
201
+ }
199
202
  }
200
203
 
201
204
  async openAPIparseStatus(): Promise<void> {
@@ -171,16 +171,17 @@ export class Motion extends deviceBase {
171
171
  this.LightSensor.CurrentAmbientLightLevel = this.getLightLevel(lightLevel, set_minLux, set_maxLux, 2)
172
172
  this.debugLog(`LightLevel: ${this.serviceData.lightLevel}, CurrentAmbientLightLevel: ${this.LightSensor.CurrentAmbientLightLevel}`)
173
173
  }
174
-
175
- // BatteryLevel
176
- this.Battery.BatteryLevel = this.serviceData.battery
177
- this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
178
-
179
- // StatusLowBattery
180
- this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
181
- ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
182
- : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
183
- this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
174
+ // Battery Info
175
+ if (this.serviceData.battery) {
176
+ // BatteryLevel
177
+ this.Battery.BatteryLevel = this.serviceData.battery
178
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
179
+ // StatusLowBattery
180
+ this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
181
+ ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
182
+ : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
183
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
184
+ }
184
185
  }
185
186
 
186
187
  async openAPIparseStatus(): Promise<void> {
@@ -170,15 +170,17 @@ export class RobotVacuumCleaner extends deviceBase {
170
170
  this.LightBulb.On = !!['InDustCollecting', 'Clearing'].includes(this.deviceStatus.workingStatus)
171
171
  this.debugLog(`On: ${this.LightBulb.On}`)
172
172
 
173
- // BatteryLevel
174
- this.Battery.BatteryLevel = this.serviceData.battery
175
- this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
176
-
177
- // StatusLowBattery
178
- this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
179
- ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
180
- : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
181
- this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
173
+ // Battery Info
174
+ if (this.serviceData.battery) {
175
+ // BatteryLevel
176
+ this.Battery.BatteryLevel = this.serviceData.battery
177
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
178
+ // StatusLowBattery
179
+ this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
180
+ ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
181
+ : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
182
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
183
+ }
182
184
  }
183
185
 
184
186
  async openAPIparseStatus() {
@@ -158,16 +158,17 @@ export class WaterDetector extends deviceBase {
158
158
  : this.serviceData.leak ? this.hap.Characteristic.LeakDetected.LEAK_DETECTED : this.hap.Characteristic.LeakDetected.LEAK_NOT_DETECTED
159
159
  this.debugLog(`LeakDetected: ${this.LeakSensor.LeakDetected}`)
160
160
  }
161
- // BatteryLevel
162
- this.Battery.BatteryLevel = this.serviceData.battery
163
- this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
164
- // StatusLowBattery
165
- this.Battery.StatusLowBattery = this.serviceData.low_battery
166
- ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
167
- : this.Battery.BatteryLevel < 10
161
+ // Battery Info
162
+ if (this.serviceData.battery) {
163
+ // BatteryLevel
164
+ this.Battery.BatteryLevel = this.serviceData.battery
165
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
166
+ // StatusLowBattery
167
+ this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
168
168
  ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
169
169
  : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
170
- this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
170
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
171
+ }
171
172
  }
172
173
 
173
174
  async openAPIparseStatus(): Promise<void> {
@@ -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));