@switchbot/homebridge-switchbot 3.5.0-beta.23 → 3.5.0-beta.25

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 (150) hide show
  1. package/config.schema.json +23 -2
  2. package/dist/device/blindtilt.d.ts +21 -98
  3. package/dist/device/blindtilt.d.ts.map +1 -1
  4. package/dist/device/blindtilt.js +332 -785
  5. package/dist/device/blindtilt.js.map +1 -1
  6. package/dist/device/bot.d.ts +25 -75
  7. package/dist/device/bot.d.ts.map +1 -1
  8. package/dist/device/bot.js +566 -778
  9. package/dist/device/bot.js.map +1 -1
  10. package/dist/device/ceilinglight.d.ts +13 -71
  11. package/dist/device/ceilinglight.d.ts.map +1 -1
  12. package/dist/device/ceilinglight.js +168 -606
  13. package/dist/device/ceilinglight.js.map +1 -1
  14. package/dist/device/colorbulb.d.ts +13 -78
  15. package/dist/device/colorbulb.d.ts.map +1 -1
  16. package/dist/device/colorbulb.js +218 -655
  17. package/dist/device/colorbulb.js.map +1 -1
  18. package/dist/device/contact.d.ts +14 -69
  19. package/dist/device/contact.d.ts.map +1 -1
  20. package/dist/device/contact.js +196 -553
  21. package/dist/device/contact.js.map +1 -1
  22. package/dist/device/curtain.d.ts +17 -90
  23. package/dist/device/curtain.d.ts.map +1 -1
  24. package/dist/device/curtain.js +324 -810
  25. package/dist/device/curtain.js.map +1 -1
  26. package/dist/device/device.d.ts +58 -0
  27. package/dist/device/device.d.ts.map +1 -0
  28. package/dist/device/device.js +629 -0
  29. package/dist/device/device.js.map +1 -0
  30. package/dist/device/hub.d.ts +15 -63
  31. package/dist/device/hub.d.ts.map +1 -1
  32. package/dist/device/hub.js +223 -610
  33. package/dist/device/hub.js.map +1 -1
  34. package/dist/device/humidifier.d.ts +10 -69
  35. package/dist/device/humidifier.d.ts.map +1 -1
  36. package/dist/device/humidifier.js +192 -595
  37. package/dist/device/humidifier.js.map +1 -1
  38. package/dist/device/iosensor.d.ts +11 -68
  39. package/dist/device/iosensor.d.ts.map +1 -1
  40. package/dist/device/iosensor.js +156 -599
  41. package/dist/device/iosensor.js.map +1 -1
  42. package/dist/device/lightstrip.d.ts +10 -72
  43. package/dist/device/lightstrip.d.ts.map +1 -1
  44. package/dist/device/lightstrip.js +204 -591
  45. package/dist/device/lightstrip.js.map +1 -1
  46. package/dist/device/lock.d.ts +15 -66
  47. package/dist/device/lock.d.ts.map +1 -1
  48. package/dist/device/lock.js +199 -566
  49. package/dist/device/lock.js.map +1 -1
  50. package/dist/device/meter.d.ts +13 -67
  51. package/dist/device/meter.d.ts.map +1 -1
  52. package/dist/device/meter.js +152 -592
  53. package/dist/device/meter.js.map +1 -1
  54. package/dist/device/meterplus.d.ts +13 -68
  55. package/dist/device/meterplus.d.ts.map +1 -1
  56. package/dist/device/meterplus.js +151 -599
  57. package/dist/device/meterplus.js.map +1 -1
  58. package/dist/device/motion.d.ts +13 -73
  59. package/dist/device/motion.d.ts.map +1 -1
  60. package/dist/device/motion.js +129 -540
  61. package/dist/device/motion.js.map +1 -1
  62. package/dist/device/plug.d.ts +9 -61
  63. package/dist/device/plug.d.ts.map +1 -1
  64. package/dist/device/plug.js +71 -476
  65. package/dist/device/plug.js.map +1 -1
  66. package/dist/device/robotvacuumcleaner.d.ts +11 -66
  67. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  68. package/dist/device/robotvacuumcleaner.js +122 -471
  69. package/dist/device/robotvacuumcleaner.js.map +1 -1
  70. package/dist/device/waterdetector.d.ts +9 -66
  71. package/dist/device/waterdetector.d.ts.map +1 -1
  72. package/dist/device/waterdetector.js +105 -478
  73. package/dist/device/waterdetector.js.map +1 -1
  74. package/dist/irdevice/airconditioner.d.ts +5 -36
  75. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  76. package/dist/irdevice/airconditioner.js +228 -337
  77. package/dist/irdevice/airconditioner.js.map +1 -1
  78. package/dist/irdevice/airpurifier.d.ts +5 -34
  79. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  80. package/dist/irdevice/airpurifier.js +19 -267
  81. package/dist/irdevice/airpurifier.js.map +1 -1
  82. package/dist/irdevice/camera.d.ts +5 -34
  83. package/dist/irdevice/camera.d.ts.map +1 -1
  84. package/dist/irdevice/camera.js +13 -261
  85. package/dist/irdevice/camera.js.map +1 -1
  86. package/dist/irdevice/fan.d.ts +5 -34
  87. package/dist/irdevice/fan.d.ts.map +1 -1
  88. package/dist/irdevice/fan.js +13 -260
  89. package/dist/irdevice/fan.js.map +1 -1
  90. package/dist/irdevice/irdevice.d.ts +39 -0
  91. package/dist/irdevice/irdevice.d.ts.map +1 -0
  92. package/dist/irdevice/irdevice.js +502 -0
  93. package/dist/irdevice/irdevice.js.map +1 -0
  94. package/dist/irdevice/light.d.ts +5 -34
  95. package/dist/irdevice/light.d.ts.map +1 -1
  96. package/dist/irdevice/light.js +13 -267
  97. package/dist/irdevice/light.js.map +1 -1
  98. package/dist/irdevice/other.d.ts +18 -48
  99. package/dist/irdevice/other.d.ts.map +1 -1
  100. package/dist/irdevice/other.js +349 -551
  101. package/dist/irdevice/other.js.map +1 -1
  102. package/dist/irdevice/tv.d.ts +7 -40
  103. package/dist/irdevice/tv.d.ts.map +1 -1
  104. package/dist/irdevice/tv.js +79 -325
  105. package/dist/irdevice/tv.js.map +1 -1
  106. package/dist/irdevice/vacuumcleaner.d.ts +6 -36
  107. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  108. package/dist/irdevice/vacuumcleaner.js +38 -288
  109. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  110. package/dist/irdevice/waterheater.d.ts +6 -36
  111. package/dist/irdevice/waterheater.d.ts.map +1 -1
  112. package/dist/irdevice/waterheater.js +39 -291
  113. package/dist/irdevice/waterheater.js.map +1 -1
  114. package/dist/settings.d.ts +15 -2
  115. package/dist/settings.d.ts.map +1 -1
  116. package/dist/utils.d.ts +68 -0
  117. package/dist/utils.d.ts.map +1 -1
  118. package/dist/utils.js +71 -0
  119. package/dist/utils.js.map +1 -1
  120. package/package.json +9 -9
  121. package/src/device/blindtilt.ts +356 -809
  122. package/src/device/bot.ts +601 -865
  123. package/src/device/ceilinglight.ts +182 -628
  124. package/src/device/colorbulb.ts +235 -683
  125. package/src/device/contact.ts +220 -575
  126. package/src/device/curtain.ts +344 -836
  127. package/src/device/device.ts +655 -0
  128. package/src/device/hub.ts +246 -636
  129. package/src/device/humidifier.ts +224 -645
  130. package/src/device/iosensor.ts +181 -625
  131. package/src/device/lightstrip.ts +230 -622
  132. package/src/device/lock.ts +236 -607
  133. package/src/device/meter.ts +177 -616
  134. package/src/device/meterplus.ts +175 -624
  135. package/src/device/motion.ts +147 -563
  136. package/src/device/plug.ts +81 -505
  137. package/src/device/robotvacuumcleaner.ts +139 -494
  138. package/src/device/waterdetector.ts +126 -506
  139. package/src/irdevice/airconditioner.ts +228 -353
  140. package/src/irdevice/airpurifier.ts +23 -282
  141. package/src/irdevice/camera.ts +18 -277
  142. package/src/irdevice/fan.ts +18 -275
  143. package/src/irdevice/irdevice.ts +518 -0
  144. package/src/irdevice/light.ts +18 -283
  145. package/src/irdevice/other.ts +394 -621
  146. package/src/irdevice/tv.ts +97 -344
  147. package/src/irdevice/vacuumcleaner.ts +46 -310
  148. package/src/irdevice/waterheater.ts +47 -315
  149. package/src/settings.ts +20 -3
  150. package/src/utils.ts +71 -0
@@ -1,6 +1,8 @@
1
- import { hostname } from 'os';
2
- import { sleep } from '../utils.js';
3
- import asyncmqtt from 'async-mqtt';
1
+ /* Copyright(C) 2021-2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
2
+ *
3
+ * waterdetector.ts: @switchbot/homebridge-switchbot.
4
+ */
5
+ import { deviceBase } from './device.js';
4
6
  import { interval, Subject } from 'rxjs';
5
7
  import { skipWhile } from 'rxjs/operators';
6
8
  import { Devices } from '../settings.js';
@@ -9,74 +11,39 @@ import { Devices } from '../settings.js';
9
11
  * An instance of this class is created for each accessory your platform registers
10
12
  * Each accessory may expose multiple services of different service types.
11
13
  */
12
- export class WaterDetector {
14
+ export class WaterDetector extends deviceBase {
13
15
  platform;
14
- accessory;
15
- device;
16
- api;
17
- log;
18
- config;
19
- hap;
20
16
  // Services
21
- leakService;
22
- batteryService;
23
- // Characteristic Values
24
- StatusActive;
25
- LeakDetected;
26
- BatteryLevel;
27
- ChargingState;
28
- StatusLowBattery;
29
- FirmwareRevision;
30
- // OpenAPI Status
31
- OpenAPI_BatteryLevel;
32
- OpenAPI_FirmwareRevision;
33
- OpenAPI_LeakDetected;
34
- // BLE Status
35
- BLE_BatteryLevel;
36
- BLE_LeakDetected; //serviceData['status'];
37
- // BLE Others
38
- BLE_IsConnected;
39
- //MQTT stuff
40
- mqttClient = null;
41
- // EVE history service handler
42
- historyService;
43
- // Config
44
- scanDuration;
45
- deviceLogging;
46
- deviceRefreshRate;
47
- maxRetries;
48
- delayBetweenRetries;
17
+ Battery;
18
+ LeakSensor;
49
19
  // Updates
50
20
  WaterDetectorUpdateInProgress;
51
21
  doWaterDetectorUpdate;
52
- // Connection
53
- OpenAPI;
54
- BLE;
55
22
  constructor(platform, accessory, device) {
23
+ super(platform, accessory, device);
56
24
  this.platform = platform;
57
- this.accessory = accessory;
58
- this.device = device;
59
- this.api = this.platform.api;
60
- this.log = this.platform.log;
61
- this.config = this.platform.config;
62
- this.hap = this.api.hap;
63
- // Connection
64
- this.BLE = this.device.connectionType === 'BLE' || this.device.connectionType === 'BLE/OpenAPI';
65
- this.OpenAPI = this.device.connectionType === 'OpenAPI' || this.device.connectionType === 'BLE/OpenAPI';
66
25
  // default placeholders
67
- this.deviceLogs(device);
68
- this.scan(device);
69
- this.refreshRate(device);
70
- this.deviceContext();
71
26
  this.setupHistoryService(device);
72
- this.setupMqtt(device);
73
- this.deviceRetry(device);
74
- this.deviceConfig(device);
75
27
  // this is subject we use to track when we need to POST changes to the SwitchBot API
76
28
  this.doWaterDetectorUpdate = new Subject();
77
29
  this.WaterDetectorUpdateInProgress = false;
78
30
  // Retrieve initial values and updateHomekit
79
31
  this.refreshStatus();
32
+ // Initialize Battery property
33
+ this.Battery = {
34
+ Service: this.accessory.getService(this.hap.Service.Battery) || this.accessory.addService(this.hap.Service.Battery),
35
+ BatteryLevel: this.accessory.context.BatteryLevel || 100,
36
+ StatusLowBattery: this.accessory.context.StatusLowBattery || this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
37
+ ChargingState: this.accessory.context.ChargingState || this.hap.Characteristic.ChargingState.NOT_CHARGEABLE,
38
+ };
39
+ // Initialize Leak Sensor property
40
+ if (!this.device.waterdetector?.hide_leak) {
41
+ this.LeakSensor = {
42
+ Service: this.accessory.getService(this.hap.Service.LeakSensor) || this.accessory.addService(this.hap.Service.LeakSensor),
43
+ StatusActive: this.accessory.context.StatusActive || false,
44
+ LeakDetected: this.accessory.context.LeakDetected || this.hap.Characteristic.LeakDetected.LEAK_NOT_DETECTED,
45
+ };
46
+ }
80
47
  // set accessory information
81
48
  accessory
82
49
  .getService(this.hap.Service.AccessoryInformation)
@@ -87,31 +54,25 @@ export class WaterDetector {
87
54
  // Leak Sensor Service
88
55
  if (device.waterdetector?.hide_leak) {
89
56
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leak Sensor Service`);
90
- this.leakService = this.accessory.getService(this.hap.Service.LeakSensor);
91
- accessory.removeService(this.leakService);
57
+ this.LeakSensor.Service = this.accessory.getService(this.hap.Service.LeakSensor);
58
+ accessory.removeService(this.LeakSensor.Service);
92
59
  }
93
- else if (!this.leakService) {
60
+ else if (!this.LeakSensor.Service) {
94
61
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Leak Sensor Service`);
95
- const leakService = `${accessory.displayName} Leak Sensor`;
96
- (this.leakService = this.accessory.getService(this.hap.Service.LeakSensor)
97
- || this.accessory.addService(this.hap.Service.LeakSensor)), leakService;
98
- this.leakService.setCharacteristic(this.hap.Characteristic.Name, `${accessory.displayName} Leak Sensor`);
99
- if (!this.leakService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
100
- this.leakService.addCharacteristic(this.hap.Characteristic.ConfiguredName, `${accessory.displayName} Leak Sensor`);
101
- }
62
+ const LeakSensorService = `${accessory.displayName} Leak Sensor`;
63
+ (this.LeakSensor.Service = this.accessory.getService(this.hap.Service.LeakSensor)
64
+ || this.accessory.addService(this.hap.Service.LeakSensor)), LeakSensorService;
65
+ this.LeakSensor.Service.setCharacteristic(this.hap.Characteristic.Name, LeakSensorService);
102
66
  }
103
67
  else {
104
68
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Leak Sensor Service Not Added`);
105
69
  }
106
70
  // Battery Service
107
- const batteryService = `${accessory.displayName} Battery`;
108
- (this.batteryService = this.accessory.getService(this.hap.Service.Battery)
109
- || accessory.addService(this.hap.Service.Battery)), batteryService;
110
- this.batteryService.setCharacteristic(this.hap.Characteristic.Name, `${accessory.displayName} Battery`);
111
- if (!this.batteryService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
112
- this.batteryService.addCharacteristic(this.hap.Characteristic.ConfiguredName, `${accessory.displayName} Battery`);
113
- }
114
- this.batteryService.setCharacteristic(this.hap.Characteristic.ChargingState, this.hap.Characteristic.ChargingState.NOT_CHARGEABLE);
71
+ const BatteryService = `${accessory.displayName} Battery`;
72
+ (this.Battery.Service = this.accessory.getService(this.hap.Service.Battery)
73
+ || accessory.addService(this.hap.Service.Battery)), BatteryService;
74
+ this.Battery.Service.setCharacteristic(this.hap.Characteristic.Name, BatteryService);
75
+ this.Battery.Service.setCharacteristic(this.hap.Characteristic.ChargingState, this.hap.Characteristic.ChargingState.NOT_CHARGEABLE);
115
76
  // Retrieve initial values and updateHomekit
116
77
  this.updateHomeKitCharacteristics();
117
78
  // Start an update interval
@@ -121,18 +82,18 @@ export class WaterDetector {
121
82
  await this.refreshStatus();
122
83
  });
123
84
  //regisiter webhook event handler
124
- if (this.device.webhook) {
85
+ if (this.device.webhook && !this.device.waterdetector?.hide_leak) {
125
86
  this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} is listening webhook.`);
126
87
  this.platform.webhookEventHandler[this.device.deviceId] = async (context) => {
127
88
  try {
128
89
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} received Webhook: ${JSON.stringify(context)}`);
129
90
  const { status } = context;
130
- const { LeakDetected } = this;
91
+ const { LeakDetected } = this.LeakSensor;
131
92
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ` +
132
93
  '(status) = ' +
133
94
  `Webhook:(${status}), ` +
134
95
  `current:(${LeakDetected})`);
135
- this.LeakDetected = status;
96
+ this.LeakSensor.LeakDetected = status;
136
97
  this.updateHomeKitCharacteristics();
137
98
  }
138
99
  catch (e) {
@@ -142,65 +103,47 @@ export class WaterDetector {
142
103
  };
143
104
  }
144
105
  }
145
- /**
146
- * Parse the device status from the SwitchBot api
147
- */
148
- async parseStatus() {
149
- if (!this.device.enableCloudService && this.OpenAPI) {
150
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} parseStatus enableCloudService: ${this.device.enableCloudService}`);
151
- }
152
- else if (this.BLE) {
153
- await this.BLEparseStatus();
154
- }
155
- else if (this.OpenAPI && this.platform.config.credentials?.token) {
156
- await this.openAPIparseStatus();
157
- }
158
- else {
159
- await this.offlineOff();
160
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` + ` ${this.device.connectionType}, parseStatus will not happen.`);
161
- }
162
- }
163
- async BLEparseStatus() {
106
+ async BLEparseStatus(serviceData) {
164
107
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLEparseStatus`);
165
108
  // Battery
166
- this.BatteryLevel = Number(this.BLE_BatteryLevel);
167
- if (this.BatteryLevel < 15) {
168
- this.StatusLowBattery = this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
109
+ this.Battery.BatteryLevel = Number(serviceData.battery);
110
+ if (this.Battery.BatteryLevel < 15) {
111
+ this.Battery.StatusLowBattery = this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
169
112
  }
170
113
  else {
171
- this.StatusLowBattery = this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
114
+ this.Battery.StatusLowBattery = this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
172
115
  }
173
- this.debugLog(`${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}, StatusLowBattery: ${this.StatusLowBattery}`);
116
+ this.debugLog(`${this.accessory.displayName} BatteryLevel: ${this.Battery.BatteryLevel}, StatusLowBattery: ${this.Battery.StatusLowBattery}`);
174
117
  // LeakDetected
175
- this.LeakDetected = this.BLE_LeakDetected;
176
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LeakDetected: ${this.LeakDetected}`);
118
+ if (this.device.waterdetector?.hide_leak) {
119
+ this.LeakSensor.LeakDetected = serviceData.status;
120
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LeakDetected: ${this.LeakSensor.LeakDetected}`);
121
+ }
177
122
  }
178
- async openAPIparseStatus() {
123
+ async openAPIparseStatus(deviceStatus) {
179
124
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIparseStatus`);
180
125
  // StatusLowBattery
181
- this.BatteryLevel = Number(this.OpenAPI_BatteryLevel);
182
- if (this.BatteryLevel < 10) {
183
- this.StatusLowBattery = this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
126
+ this.Battery.BatteryLevel = Number(deviceStatus.body.battery);
127
+ if (this.Battery.BatteryLevel < 10) {
128
+ this.Battery.StatusLowBattery = this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW;
184
129
  }
185
130
  else {
186
- this.StatusLowBattery = this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
131
+ this.Battery.StatusLowBattery = this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
187
132
  }
188
- this.debugLog(`${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}, StatusLowBattery: ${this.StatusLowBattery}`);
133
+ this.debugLog(`${this.accessory.displayName} BatteryLevel: ${this.Battery.BatteryLevel}, StatusLowBattery: ${this.Battery.StatusLowBattery}`);
189
134
  // BatteryLevel
190
- if (Number.isNaN(this.BatteryLevel)) {
191
- this.BatteryLevel = 100;
135
+ if (Number.isNaN(this.Battery.BatteryLevel)) {
136
+ this.Battery.BatteryLevel = 100;
192
137
  }
193
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
138
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.Battery.BatteryLevel}`);
194
139
  // LeakDetected
195
- this.LeakDetected = this.OpenAPI_LeakDetected;
196
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LeakDetected: ${this.LeakDetected}`);
140
+ if (!this.device.waterdetector?.hide_leak) {
141
+ this.LeakSensor.LeakDetected = deviceStatus.body.status;
142
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LeakDetected: ${this.LeakSensor.LeakDetected}`);
143
+ }
197
144
  // FirmwareRevision
198
- this.FirmwareRevision = this.OpenAPI_FirmwareRevision;
199
- this.accessory.context.FirmwareRevision = this.FirmwareRevision;
145
+ this.accessory.context.FirmwareRevision = deviceStatus.body.version;
200
146
  }
201
- /**
202
- * Asks the SwitchBot API for the latest device information
203
- */
204
147
  async refreshStatus() {
205
148
  if (!this.device.enableCloudService && this.OpenAPI) {
206
149
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus enableCloudService: ${this.device.enableCloudService}`);
@@ -230,38 +173,34 @@ export class WaterDetector {
230
173
  // Start to monitor advertisement packets
231
174
  (async () => {
232
175
  // Start to monitor advertisement packets
233
- await switchbot.startScan({
234
- model: 'l',
235
- id: this.device.bleMac,
236
- });
176
+ await switchbot.startScan({ model: this.device.bleModel, id: this.device.bleMac });
237
177
  // Set an event handler
238
178
  switchbot.onadvertisement = (ad) => {
239
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ${JSON.stringify(ad, null, ' ')}`);
240
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} address: ${ad.address}, model: ${ad.serviceData.model}`);
241
- if (this.device.bleMac === ad.address && ad.serviceData.model === 'l') {
179
+ if (this.device.bleMac === ad.address && ad.model === this.device.bleModel) {
180
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ${JSON.stringify(ad, null, ' ')}`);
181
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} address: ${ad.address}, model: ${ad.model}`);
242
182
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
243
- this.BLE_LeakDetected = ad.serviceData.status;
244
- this.BLE_BatteryLevel = ad.serviceData.battery;
245
183
  }
246
184
  else {
247
185
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
248
186
  }
249
187
  };
250
- // Wait 1 seconds
188
+ // Wait 10 seconds
251
189
  await switchbot.wait(this.scanDuration * 1000);
252
190
  // Stop to monitor
253
191
  await switchbot.stopScan();
254
192
  // Update HomeKit
255
- await this.BLEparseStatus();
193
+ await this.BLEparseStatus(switchbot.onadvertisement.serviceData);
256
194
  await this.updateHomeKitCharacteristics();
257
195
  })();
196
+ if (switchbot === undefined) {
197
+ await this.BLERefreshConnection(switchbot);
198
+ }
258
199
  }
259
200
  async openAPIRefreshStatus() {
260
201
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus`);
261
202
  try {
262
- const { body, statusCode } = await this.platform.retryRequest(this.maxRetries, this.delayBetweenRetries, `${Devices}/${this.device.deviceId}/status`, {
263
- headers: this.platform.generateHeaders(),
264
- });
203
+ const { body, statusCode } = await this.platform.retryRequest(this.deviceMaxRetries, this.deviceDelayBetweenRetries, `${Devices}/${this.device.deviceId}/status`, { headers: this.platform.generateHeaders() });
265
204
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
266
205
  const deviceStatus = await body.json();
267
206
  this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
@@ -269,10 +208,7 @@ export class WaterDetector {
269
208
  if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
270
209
  this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
271
210
  + `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
272
- this.OpenAPI_LeakDetected = deviceStatus.body.status;
273
- this.OpenAPI_BatteryLevel = deviceStatus.body.battery;
274
- this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
275
- this.openAPIparseStatus();
211
+ this.openAPIparseStatus(deviceStatus);
276
212
  this.updateHomeKitCharacteristics();
277
213
  }
278
214
  else {
@@ -293,128 +229,56 @@ export class WaterDetector {
293
229
  const mqttmessage = [];
294
230
  const entry = { time: Math.round(new Date().valueOf() / 1000) };
295
231
  if (!this.device.waterdetector?.hide_leak) {
296
- if (this.LeakDetected === undefined) {
297
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LeakDetected: ${this.LeakDetected}`);
232
+ if (this.LeakSensor.LeakDetected === undefined) {
233
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LeakDetected: ${this.LeakSensor.LeakDetected}`);
298
234
  }
299
235
  else {
300
236
  if (this.device.mqttURL) {
301
- mqttmessage.push(`"LeakDetected": ${this.LeakDetected}`);
237
+ mqttmessage.push(`"LeakDetected": ${this.LeakSensor.LeakDetected}`);
302
238
  }
303
239
  if (this.device.history) {
304
- entry['leak'] = this.LeakDetected;
240
+ entry['leak'] = this.LeakSensor.LeakDetected;
305
241
  }
306
- this.accessory.context.LeakDetected = this.LeakDetected;
307
- this.leakService?.updateCharacteristic(this.hap.Characteristic.LeakDetected, this.LeakDetected);
308
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic LeakDetected: ${this.LeakDetected}`);
242
+ this.accessory.context.LeakDetected = this.LeakSensor.LeakDetected;
243
+ this.LeakSensor.Service.updateCharacteristic(this.hap.Characteristic.LeakDetected, this.LeakSensor.LeakDetected);
244
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic LeakDetected: ${this.LeakSensor.LeakDetected}`);
309
245
  }
310
246
  }
311
- if (this.BatteryLevel === undefined) {
312
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
247
+ if (this.Battery.BatteryLevel === undefined) {
248
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.Battery.BatteryLevel}`);
313
249
  }
314
250
  else {
315
251
  if (this.device.mqttURL) {
316
- mqttmessage.push(`"battery": ${this.BatteryLevel}`);
252
+ mqttmessage.push(`"battery": ${this.Battery.BatteryLevel}`);
317
253
  }
318
- this.accessory.context.BatteryLevel = this.BatteryLevel;
319
- this.batteryService?.updateCharacteristic(this.hap.Characteristic.BatteryLevel, this.BatteryLevel);
320
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
254
+ this.accessory.context.BatteryLevel = this.Battery.BatteryLevel;
255
+ this.Battery.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, this.Battery.BatteryLevel);
256
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.Battery.BatteryLevel}`);
321
257
  }
322
- if (this.StatusLowBattery === undefined) {
323
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
258
+ if (this.Battery.StatusLowBattery === undefined) {
259
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatusLowBattery: ${this.Battery.StatusLowBattery}`);
324
260
  }
325
261
  else {
326
262
  if (this.device.mqttURL) {
327
- mqttmessage.push(`"lowBattery": ${this.StatusLowBattery}`);
263
+ mqttmessage.push(`"lowBattery": ${this.Battery.StatusLowBattery}`);
328
264
  }
329
- this.accessory.context.StatusLowBattery = this.StatusLowBattery;
330
- this.batteryService?.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, this.StatusLowBattery);
331
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
265
+ this.accessory.context.StatusLowBattery = this.Battery.StatusLowBattery;
266
+ this.Battery.Service.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, this.Battery.StatusLowBattery);
267
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
268
+ + ` StatusLowBattery: ${this.Battery.StatusLowBattery}`);
332
269
  }
333
270
  if (this.device.mqttURL) {
334
271
  this.mqttPublish(`{${mqttmessage.join(',')}}`);
335
272
  }
336
- if (Number(this.LeakDetected) > 0) {
337
- // reject unreliable data
338
- if (this.device.history) {
339
- this.historyService?.addEntry(entry);
340
- }
341
- }
342
- }
343
- /*
344
- * Publish MQTT message for topics of
345
- * 'homebridge-switchbot/meter/xx:xx:xx:xx:xx:xx'
346
- */
347
- mqttPublish(message) {
348
- const mac = this.device.deviceId
349
- ?.toLowerCase()
350
- .match(/[\s\S]{1,2}/g)
351
- ?.join(':');
352
- const options = this.device.mqttPubOptions || {};
353
- this.mqttClient?.publish(`homebridge-switchbot/meter/${mac}`, `${message}`, options);
354
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} MQTT message: ${message} options:${JSON.stringify(options)}`);
355
- }
356
- /*
357
- * Setup MQTT hadler if URL is specified.
358
- */
359
- async setupMqtt(device) {
360
- if (device.mqttURL) {
361
- try {
362
- const { connectAsync } = asyncmqtt;
363
- this.mqttClient = await connectAsync(device.mqttURL, device.mqttOptions || {});
364
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} MQTT connection has been established successfully.`);
365
- this.mqttClient.on('error', (e) => {
366
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Failed to publish MQTT messages. ${e}`);
367
- });
368
- }
369
- catch (e) {
370
- this.mqttClient = null;
371
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Failed to establish MQTT connection. ${e}`);
273
+ if (!this.device.waterdetector?.hide_leak) {
274
+ if (Number(this.LeakSensor.LeakDetected) > 0) {
275
+ // reject unreliable data
276
+ if (this.device.history) {
277
+ this.historyService?.addEntry(entry);
278
+ }
372
279
  }
373
280
  }
374
281
  }
375
- /*
376
- * Setup EVE history graph feature if enabled.
377
- */
378
- async setupHistoryService(device) {
379
- const mac = this.device
380
- .deviceId.match(/.{1,2}/g)
381
- .join(':')
382
- .toLowerCase();
383
- this.historyService = device.history
384
- ? new this.platform.fakegatoAPI('room', this.accessory, {
385
- log: this.platform.log,
386
- storage: 'fs',
387
- filename: `${hostname().split('.')[0]}_${mac}_persist.json`,
388
- })
389
- : null;
390
- }
391
- async stopScanning(switchbot) {
392
- switchbot.stopScan();
393
- if (this.BLE_IsConnected) {
394
- await this.BLEparseStatus();
395
- await this.updateHomeKitCharacteristics();
396
- }
397
- else {
398
- await this.BLERefreshConnection(switchbot);
399
- }
400
- }
401
- async getCustomBLEAddress(switchbot) {
402
- if (this.device.customBLEaddress && this.deviceLogging.includes('debug')) {
403
- (async () => {
404
- // Start to monitor advertisement packets
405
- await switchbot.startScan({
406
- model: 'i',
407
- });
408
- // Set an event handler
409
- switchbot.onadvertisement = (ad) => {
410
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} ad: ${JSON.stringify(ad, null, ' ')}`);
411
- };
412
- await sleep(10000);
413
- // Stop to monitor
414
- switchbot.stopScan();
415
- })();
416
- }
417
- }
418
282
  async BLERefreshConnection(switchbot) {
419
283
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot:`
420
284
  + ` ${JSON.stringify(switchbot)}`);
@@ -423,254 +287,17 @@ export class WaterDetector {
423
287
  await this.openAPIRefreshStatus();
424
288
  }
425
289
  }
426
- async scan(device) {
427
- if (device.scanDuration) {
428
- this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
429
- if (this.BLE) {
430
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
431
- }
432
- }
433
- else {
434
- this.scanDuration = this.accessory.context.scanDuration = 1;
435
- if (this.BLE) {
436
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
437
- }
438
- }
439
- }
440
- async statusCode(statusCode) {
441
- switch (statusCode) {
442
- case 151:
443
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Command not supported by this deviceType, statusCode: ${statusCode}`);
444
- break;
445
- case 152:
446
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device not found, statusCode: ${statusCode}`);
447
- break;
448
- case 160:
449
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Command is not supported, statusCode: ${statusCode}`);
450
- break;
451
- case 161:
452
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device is offline, statusCode: ${statusCode}`);
453
- this.offlineOff();
454
- break;
455
- case 171:
456
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
457
- `Hub: ${this.device.hubDeviceId}`);
458
- this.offlineOff();
459
- break;
460
- case 190:
461
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` +
462
- ` Or command format is invalid, statusCode: ${statusCode}`);
463
- break;
464
- case 100:
465
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Command successfully sent, statusCode: ${statusCode}`);
466
- break;
467
- case 200:
468
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
469
- break;
470
- case 400:
471
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Bad Request, The client has issued an invalid request. `
472
- + `This is commonly used to specify validation errors in a request payload, statusCode: ${statusCode}`);
473
- break;
474
- case 401:
475
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Unauthorized, Authorization for the API is required, `
476
- + `but the request has not been authenticated, statusCode: ${statusCode}`);
477
- break;
478
- case 403:
479
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Forbidden, The request has been authenticated but does not `
480
- + `have appropriate permissions, or a requested resource is not found, statusCode: ${statusCode}`);
481
- break;
482
- case 404:
483
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Not Found, Specifies the requested path does not exist, `
484
- + `statusCode: ${statusCode}`);
485
- break;
486
- case 406:
487
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Not Acceptable, The client has requested a MIME type via `
488
- + `the Accept header for a value not supported by the server, statusCode: ${statusCode}`);
489
- break;
490
- case 415:
491
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Unsupported Media Type, The client has defined a contentType `
492
- + `header that is not supported by the server, statusCode: ${statusCode}`);
493
- break;
494
- case 422:
495
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Unprocessable Entity, The client has made a valid request, `
496
- + `but the server cannot process it. This is often used for APIs for which certain limits have been exceeded, statusCode: ${statusCode}`);
497
- break;
498
- case 429:
499
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Too Many Requests, The client has exceeded the number of `
500
- + `requests allowed for a given time window, statusCode: ${statusCode}`);
501
- break;
502
- case 500:
503
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Internal Server Error, An unexpected error on the SmartThings `
504
- + `servers has occurred. These errors should be rare, statusCode: ${statusCode}`);
505
- break;
506
- default:
507
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode: ` +
508
- `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
509
- }
510
- }
511
290
  async offlineOff() {
512
- if (this.device.offline) {
513
- await this.deviceContext();
514
- await this.updateHomeKitCharacteristics();
291
+ if (this.device.offline && !this.device.waterdetector?.hide_leak) {
292
+ this.LeakSensor.Service.updateCharacteristic(this.hap.Characteristic.LeakDetected, this.hap.Characteristic.LeakDetected.LEAK_NOT_DETECTED);
515
293
  }
516
294
  }
517
295
  async apiError(e) {
518
296
  if (!this.device.waterdetector?.hide_leak) {
519
- this.leakService?.updateCharacteristic(this.hap.Characteristic.LeakDetected, e);
520
- }
521
- this.batteryService?.updateCharacteristic(this.hap.Characteristic.BatteryLevel, e);
522
- this.batteryService?.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, e);
523
- }
524
- async deviceContext() {
525
- if (this.LeakDetected === undefined) {
526
- this.LeakDetected = 0;
527
- }
528
- else {
529
- this.LeakDetected = this.accessory.context.LeakDetected;
530
- }
531
- if (this.BatteryLevel === undefined) {
532
- this.BatteryLevel = 100;
533
- }
534
- else {
535
- this.BatteryLevel = this.accessory.context.BatteryLevel;
536
- }
537
- if (this.StatusLowBattery === undefined) {
538
- this.StatusLowBattery = this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
539
- this.accessory.context.StatusLowBattery = this.StatusLowBattery;
540
- }
541
- else {
542
- this.StatusLowBattery = this.accessory.context.StatusLowBattery;
543
- }
544
- if (this.FirmwareRevision === undefined) {
545
- this.FirmwareRevision = this.platform.version;
546
- this.accessory.context.FirmwareRevision = this.FirmwareRevision;
547
- }
548
- }
549
- async refreshRate(device) {
550
- if (device.refreshRate) {
551
- this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
552
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
553
- }
554
- else if (this.platform.config.options.refreshRate) {
555
- this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options.refreshRate;
556
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
557
- }
558
- }
559
- async deviceRetry(device) {
560
- if (!device.maxRetries) {
561
- this.maxRetries = 5; // Maximum number of retries
562
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Max Retries Not Set, Using: ${this.maxRetries}`);
563
- }
564
- else {
565
- this.maxRetries = device.maxRetries;
566
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Max Retries: ${this.maxRetries}`);
567
- }
568
- if (!device.delayBetweenRetries) {
569
- this.delayBetweenRetries = 3000; // Delay between retries in milliseconds
570
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Delay Between Retries Not Set, Using: ${this.delayBetweenRetries}`);
571
- }
572
- else {
573
- this.delayBetweenRetries = device.delayBetweenRetries * 1000;
574
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Delay Between Retries: ${this.delayBetweenRetries}`);
575
- }
576
- }
577
- async deviceConfig(device) {
578
- let config = {};
579
- if (device.waterdetector) {
580
- config = device.waterdetector;
581
- }
582
- if (device.connectionType !== undefined) {
583
- config['connectionType'] = device.connectionType;
584
- }
585
- if (device.external !== undefined) {
586
- config['external'] = device.external;
587
- }
588
- if (device.mqttURL !== undefined) {
589
- config['mqttURL'] = device.mqttURL;
590
- }
591
- if (device.logging !== undefined) {
592
- config['logging'] = device.logging;
593
- }
594
- if (device.refreshRate !== undefined) {
595
- config['refreshRate'] = device.refreshRate;
596
- }
597
- if (device.scanDuration !== undefined) {
598
- config['scanDuration'] = device.scanDuration;
599
- }
600
- if (device.webhook !== undefined) {
601
- config['webhook'] = device.webhook;
297
+ this.LeakSensor.Service.updateCharacteristic(this.hap.Characteristic.LeakDetected, e);
602
298
  }
603
- if (Object.entries(config).length !== 0) {
604
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
605
- }
606
- }
607
- async deviceLogs(device) {
608
- if (this.platform.debugMode) {
609
- this.deviceLogging = this.accessory.context.logging = 'debugMode';
610
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
611
- }
612
- else if (device.logging) {
613
- this.deviceLogging = this.accessory.context.logging = device.logging;
614
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
615
- }
616
- else if (this.platform.config.options?.logging) {
617
- this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
618
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
619
- }
620
- else {
621
- this.deviceLogging = this.accessory.context.logging = 'standard';
622
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
623
- }
624
- }
625
- /**
626
- * Logging for Device
627
- */
628
- successLog(...log) {
629
- if (this.enablingDeviceLogging()) {
630
- this.platform.log.success(String(...log));
631
- }
632
- }
633
- infoLog(...log) {
634
- if (this.enablingDeviceLogging()) {
635
- this.platform.log.info(String(...log));
636
- }
637
- }
638
- warnLog(...log) {
639
- if (this.enablingDeviceLogging()) {
640
- this.platform.log.warn(String(...log));
641
- }
642
- }
643
- debugWarnLog(...log) {
644
- if (this.enablingDeviceLogging()) {
645
- if (this.deviceLogging?.includes('debug')) {
646
- this.platform.log.warn('[DEBUG]', String(...log));
647
- }
648
- }
649
- }
650
- errorLog(...log) {
651
- if (this.enablingDeviceLogging()) {
652
- this.platform.log.error(String(...log));
653
- }
654
- }
655
- debugErrorLog(...log) {
656
- if (this.enablingDeviceLogging()) {
657
- if (this.deviceLogging?.includes('debug')) {
658
- this.platform.log.error('[DEBUG]', String(...log));
659
- }
660
- }
661
- }
662
- debugLog(...log) {
663
- if (this.enablingDeviceLogging()) {
664
- if (this.deviceLogging === 'debug') {
665
- this.platform.log.info('[DEBUG]', String(...log));
666
- }
667
- else {
668
- this.platform.log.debug(String(...log));
669
- }
670
- }
671
- }
672
- enablingDeviceLogging() {
673
- return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
299
+ this.Battery.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, e);
300
+ this.Battery.Service.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, e);
674
301
  }
675
302
  }
676
303
  //# sourceMappingURL=waterdetector.js.map