@switchbot/homebridge-switchbot 3.7.1-beta.2 → 3.7.1-beta.21

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 (199) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +14 -0
  3. package/assets/security-privacy-bluetooth.png +0 -0
  4. package/config.schema.json +74 -2
  5. package/dist/device/blindtilt.d.ts +21 -9
  6. package/dist/device/blindtilt.d.ts.map +1 -1
  7. package/dist/device/blindtilt.js +167 -96
  8. package/dist/device/blindtilt.js.map +1 -1
  9. package/dist/device/bot-old.d.ts +132 -0
  10. package/dist/device/bot-old.d.ts.map +1 -0
  11. package/dist/device/bot-old.js +1482 -0
  12. package/dist/device/bot-old.js.map +1 -0
  13. package/dist/device/bot.d.ts +10 -9
  14. package/dist/device/bot.d.ts.map +1 -1
  15. package/dist/device/bot.js +186 -187
  16. package/dist/device/bot.js.map +1 -1
  17. package/dist/device/ceilinglight.d.ts +14 -13
  18. package/dist/device/ceilinglight.d.ts.map +1 -1
  19. package/dist/device/ceilinglight.js +87 -97
  20. package/dist/device/ceilinglight.js.map +1 -1
  21. package/dist/device/colorbulb.d.ts +13 -12
  22. package/dist/device/colorbulb.d.ts.map +1 -1
  23. package/dist/device/colorbulb.js +92 -105
  24. package/dist/device/colorbulb.js.map +1 -1
  25. package/dist/device/contact.d.ts +6 -5
  26. package/dist/device/contact.d.ts.map +1 -1
  27. package/dist/device/contact.js +71 -68
  28. package/dist/device/contact.js.map +1 -1
  29. package/dist/device/curtain.d.ts +17 -5
  30. package/dist/device/curtain.d.ts.map +1 -1
  31. package/dist/device/curtain.js +184 -118
  32. package/dist/device/curtain.js.map +1 -1
  33. package/dist/device/device.d.ts +18 -18
  34. package/dist/device/device.d.ts.map +1 -1
  35. package/dist/device/device.js +33 -36
  36. package/dist/device/device.js.map +1 -1
  37. package/dist/device/fan.d.ts +9 -8
  38. package/dist/device/fan.d.ts.map +1 -1
  39. package/dist/device/fan.js +94 -101
  40. package/dist/device/fan.js.map +1 -1
  41. package/dist/device/hub.d.ts +6 -5
  42. package/dist/device/hub.d.ts.map +1 -1
  43. package/dist/device/hub.js +69 -65
  44. package/dist/device/hub.js.map +1 -1
  45. package/dist/device/humidifier.d.ts +6 -5
  46. package/dist/device/humidifier.d.ts.map +1 -1
  47. package/dist/device/humidifier.js +89 -104
  48. package/dist/device/humidifier.js.map +1 -1
  49. package/dist/device/iosensor.d.ts +6 -5
  50. package/dist/device/iosensor.d.ts.map +1 -1
  51. package/dist/device/iosensor.js +72 -66
  52. package/dist/device/iosensor.js.map +1 -1
  53. package/dist/device/lightstrip.d.ts +7 -6
  54. package/dist/device/lightstrip.d.ts.map +1 -1
  55. package/dist/device/lightstrip.js +85 -99
  56. package/dist/device/lightstrip.js.map +1 -1
  57. package/dist/device/lock.d.ts +10 -9
  58. package/dist/device/lock.d.ts.map +1 -1
  59. package/dist/device/lock.js +89 -79
  60. package/dist/device/lock.js.map +1 -1
  61. package/dist/device/meter.d.ts +6 -5
  62. package/dist/device/meter.d.ts.map +1 -1
  63. package/dist/device/meter.js +72 -65
  64. package/dist/device/meter.js.map +1 -1
  65. package/dist/device/meterplus.d.ts +6 -5
  66. package/dist/device/meterplus.d.ts.map +1 -1
  67. package/dist/device/meterplus.js +72 -64
  68. package/dist/device/meterplus.js.map +1 -1
  69. package/dist/device/motion.d.ts +6 -5
  70. package/dist/device/motion.d.ts.map +1 -1
  71. package/dist/device/motion.js +65 -58
  72. package/dist/device/motion.js.map +1 -1
  73. package/dist/device/plug.d.ts +13 -12
  74. package/dist/device/plug.d.ts.map +1 -1
  75. package/dist/device/plug.js +68 -52
  76. package/dist/device/plug.js.map +1 -1
  77. package/dist/device/robotvacuumcleaner.d.ts +12 -11
  78. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  79. package/dist/device/robotvacuumcleaner.js +93 -82
  80. package/dist/device/robotvacuumcleaner.js.map +1 -1
  81. package/dist/device/waterdetector.d.ts +6 -5
  82. package/dist/device/waterdetector.d.ts.map +1 -1
  83. package/dist/device/waterdetector.js +73 -63
  84. package/dist/device/waterdetector.js.map +1 -1
  85. package/dist/homebridge-ui/server.js +2 -2
  86. package/dist/homebridge-ui/server.js.map +1 -1
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/index.js +0 -4
  89. package/dist/index.js.map +1 -1
  90. package/dist/irdevice/airconditioner.d.ts +8 -8
  91. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  92. package/dist/irdevice/airconditioner.js +61 -105
  93. package/dist/irdevice/airconditioner.js.map +1 -1
  94. package/dist/irdevice/airpurifier.d.ts +10 -10
  95. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  96. package/dist/irdevice/airpurifier.js +22 -42
  97. package/dist/irdevice/airpurifier.js.map +1 -1
  98. package/dist/irdevice/camera.d.ts +9 -9
  99. package/dist/irdevice/camera.d.ts.map +1 -1
  100. package/dist/irdevice/camera.js +15 -25
  101. package/dist/irdevice/camera.js.map +1 -1
  102. package/dist/irdevice/fan.d.ts +8 -8
  103. package/dist/irdevice/fan.d.ts.map +1 -1
  104. package/dist/irdevice/fan.js +21 -40
  105. package/dist/irdevice/fan.js.map +1 -1
  106. package/dist/irdevice/irdevice.d.ts +11 -11
  107. package/dist/irdevice/irdevice.d.ts.map +1 -1
  108. package/dist/irdevice/irdevice.js +14 -22
  109. package/dist/irdevice/irdevice.js.map +1 -1
  110. package/dist/irdevice/light.d.ts +9 -9
  111. package/dist/irdevice/light.d.ts.map +1 -1
  112. package/dist/irdevice/light.js +24 -47
  113. package/dist/irdevice/light.js.map +1 -1
  114. package/dist/irdevice/other.d.ts +9 -9
  115. package/dist/irdevice/other.d.ts.map +1 -1
  116. package/dist/irdevice/other.js +40 -83
  117. package/dist/irdevice/other.js.map +1 -1
  118. package/dist/irdevice/tv.d.ts +9 -9
  119. package/dist/irdevice/tv.d.ts.map +1 -1
  120. package/dist/irdevice/tv.js +29 -54
  121. package/dist/irdevice/tv.js.map +1 -1
  122. package/dist/irdevice/vacuumcleaner.d.ts +5 -5
  123. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  124. package/dist/irdevice/vacuumcleaner.js +11 -21
  125. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  126. package/dist/irdevice/waterheater.d.ts +5 -5
  127. package/dist/irdevice/waterheater.d.ts.map +1 -1
  128. package/dist/irdevice/waterheater.js +11 -22
  129. package/dist/irdevice/waterheater.js.map +1 -1
  130. package/dist/platform.d.ts +24 -23
  131. package/dist/platform.d.ts.map +1 -1
  132. package/dist/platform.js +509 -723
  133. package/dist/platform.js.map +1 -1
  134. package/dist/settings.d.ts +5 -2
  135. package/dist/settings.d.ts.map +1 -1
  136. package/dist/settings.js.map +1 -1
  137. package/dist/types/bledevicestatus.d.ts +9 -9
  138. package/dist/types/bledevicestatus.d.ts.map +1 -1
  139. package/dist/types/devicelist.d.ts +6 -6
  140. package/dist/types/devicelist.d.ts.map +1 -1
  141. package/dist/types/deviceresponse.d.ts +4 -4
  142. package/dist/types/deviceresponse.d.ts.map +1 -1
  143. package/dist/types/devicestatus.d.ts +2 -2
  144. package/dist/types/devicestatus.d.ts.map +1 -1
  145. package/dist/types/devicewebhookstatus.d.ts +5 -5
  146. package/dist/types/devicewebhookstatus.d.ts.map +1 -1
  147. package/dist/types/irdevicelist.d.ts +4 -4
  148. package/dist/types/irdevicelist.d.ts.map +1 -1
  149. package/dist/types/pushbody.d.ts +2 -2
  150. package/dist/types/pushbody.d.ts.map +1 -1
  151. package/dist/utils.d.ts +4 -4
  152. package/dist/utils.d.ts.map +1 -1
  153. package/dist/utils.js +9 -13
  154. package/dist/utils.js.map +1 -1
  155. package/eslint.config.js +48 -93
  156. package/package.json +64 -57
  157. package/src/device/blindtilt.ts +537 -456
  158. package/src/device/bot-old.ts +1540 -0
  159. package/src/device/bot.ts +732 -725
  160. package/src/device/ceilinglight.ts +359 -368
  161. package/src/device/colorbulb.ts +441 -453
  162. package/src/device/contact.ts +229 -226
  163. package/src/device/curtain.ts +526 -444
  164. package/src/device/device.ts +206 -208
  165. package/src/device/fan.ts +336 -345
  166. package/src/device/hub.ts +213 -214
  167. package/src/device/humidifier.ts +326 -347
  168. package/src/device/iosensor.ts +211 -209
  169. package/src/device/lightstrip.ts +391 -404
  170. package/src/device/lock.ts +292 -282
  171. package/src/device/meter.ts +212 -210
  172. package/src/device/meterplus.ts +212 -209
  173. package/src/device/motion.ts +198 -190
  174. package/src/device/plug.ts +203 -182
  175. package/src/device/robotvacuumcleaner.ts +280 -269
  176. package/src/device/waterdetector.ts +198 -189
  177. package/src/homebridge-ui/server.ts +16 -15
  178. package/src/index.ts +5 -6
  179. package/src/irdevice/airconditioner.ts +277 -326
  180. package/src/irdevice/airpurifier.ts +124 -143
  181. package/src/irdevice/camera.ts +58 -64
  182. package/src/irdevice/fan.ts +106 -123
  183. package/src/irdevice/irdevice.ts +116 -119
  184. package/src/irdevice/light.ts +119 -143
  185. package/src/irdevice/other.ts +417 -461
  186. package/src/irdevice/tv.ts +155 -177
  187. package/src/irdevice/vacuumcleaner.ts +54 -60
  188. package/src/irdevice/waterheater.ts +56 -63
  189. package/src/platform.ts +1491 -1681
  190. package/src/settings.ts +172 -169
  191. package/src/types/bledevicestatus.ts +252 -256
  192. package/src/types/devicelist.ts +79 -79
  193. package/src/types/deviceresponse.ts +12 -13
  194. package/src/types/devicestatus.ts +124 -124
  195. package/src/types/devicewebhookstatus.ts +126 -131
  196. package/src/types/irdevicelist.ts +10 -10
  197. package/src/types/pushbody.ts +5 -5
  198. package/src/utils.ts +64 -65
  199. package/tsconfig.json +10 -9
@@ -2,19 +2,25 @@
2
2
  *
3
3
  * iosensor.ts: @switchbot/homebridge-switchbot.
4
4
  */
5
- import { Units } from 'homebridge';
6
- import { deviceBase } from './device.js';
7
- import { Subject, interval, skipWhile } from 'rxjs';
8
- import { convertUnits, validHumidity } from '../utils.js';
9
- import { SwitchBotBLEModel, SwitchBotBLEModelName } from 'node-switchbot';
10
-
11
- import type { devicesConfig } from '../settings.js';
12
- import type { device } from '../types/devicelist.js';
13
- import type { SwitchBotPlatform } from '../platform.js';
14
- import type { outdoorMeterServiceData } from '../types/bledevicestatus.js';
15
- import type { outdoorMeterStatus } from '../types/devicestatus.js';
16
- import type { outdoorMeterWebhookContext } from '../types/devicewebhookstatus.js';
17
- import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
5
+ import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'
6
+
7
+ import type { SwitchBotPlatform } from '../platform.js'
8
+ import type { devicesConfig } from '../settings.js'
9
+ import type { outdoorMeterServiceData } from '../types/bledevicestatus.js'
10
+ import type { device } from '../types/devicelist.js'
11
+ import type { outdoorMeterStatus } from '../types/devicestatus.js'
12
+ import type { outdoorMeterWebhookContext } from '../types/devicewebhookstatus.js'
13
+
14
+ import { Units } from 'homebridge'
15
+ /*
16
+ * For Testing Locally:
17
+ * import { SwitchBotBLEModel, SwitchBotBLEModelName } from '/Users/Shared/GitHub/OpenWonderLabs/node-switchbot/dist/index.js';
18
+ */
19
+ import { SwitchBotBLEModel, SwitchBotBLEModelName } from 'node-switchbot'
20
+ import { interval, skipWhile, Subject } from 'rxjs'
21
+
22
+ import { convertUnits, validHumidity } from '../utils.js'
23
+ import { deviceBase } from './device.js'
18
24
 
19
25
  /**
20
26
  * Platform Accessory
@@ -24,244 +30,240 @@ import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge
24
30
  export class IOSensor extends deviceBase {
25
31
  // Services
26
32
  private Battery: {
27
- Name: CharacteristicValue;
28
- Service: Service;
29
- BatteryLevel: CharacteristicValue;
30
- StatusLowBattery: CharacteristicValue;
31
- };
33
+ Name: CharacteristicValue
34
+ Service: Service
35
+ BatteryLevel: CharacteristicValue
36
+ StatusLowBattery: CharacteristicValue
37
+ }
32
38
 
33
39
  private HumiditySensor?: {
34
- Name: CharacteristicValue;
35
- Service: Service;
36
- CurrentRelativeHumidity: CharacteristicValue;
37
- };
40
+ Name: CharacteristicValue
41
+ Service: Service
42
+ CurrentRelativeHumidity: CharacteristicValue
43
+ }
38
44
 
39
45
  private TemperatureSensor?: {
40
- Name: CharacteristicValue;
41
- Service: Service;
42
- CurrentTemperature: CharacteristicValue;
43
- };
46
+ Name: CharacteristicValue
47
+ Service: Service
48
+ CurrentTemperature: CharacteristicValue
49
+ }
44
50
 
45
51
  // OpenAPI
46
- deviceStatus!: outdoorMeterStatus;
52
+ deviceStatus!: outdoorMeterStatus
47
53
 
48
- //Webhook
49
- webhookContext!: outdoorMeterWebhookContext;
54
+ // Webhook
55
+ webhookContext!: outdoorMeterWebhookContext
50
56
 
51
57
  // BLE
52
- serviceData!: outdoorMeterServiceData;
58
+ serviceData!: outdoorMeterServiceData
53
59
 
54
60
  // Updates
55
- ioSensorUpdateInProgress!: boolean;
56
- doIOSensorUpdate: Subject<void>;
61
+ ioSensorUpdateInProgress!: boolean
62
+ doIOSensorUpdate: Subject<void>
57
63
 
58
64
  constructor(
59
65
  readonly platform: SwitchBotPlatform,
60
66
  accessory: PlatformAccessory,
61
67
  device: device & devicesConfig,
62
68
  ) {
63
- super(platform, accessory, device);
69
+ super(platform, accessory, device)
64
70
  // Set category
65
- accessory.category = this.hap.Categories.SENSOR;
71
+ accessory.category = this.hap.Categories.SENSOR
66
72
 
67
73
  // this is subject we use to track when we need to POST changes to the SwitchBot API
68
- this.doIOSensorUpdate = new Subject();
69
- this.ioSensorUpdateInProgress = false;
74
+ this.doIOSensorUpdate = new Subject()
75
+ this.ioSensorUpdateInProgress = false
70
76
 
71
77
  // Initialize Battery Service
72
- accessory.context.Battery = accessory.context.Battery ?? {};
78
+ accessory.context.Battery = accessory.context.Battery ?? {}
73
79
  this.Battery = {
74
80
  Name: `${accessory.displayName} Battery`,
75
81
  Service: accessory.getService(this.hap.Service.Battery) ?? accessory.addService(this.hap.Service.Battery) as Service,
76
82
  BatteryLevel: accessory.context.BatteryLevel ?? 100,
77
83
  StatusLowBattery: accessory.context.StatusLowBattery ?? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
78
- };
79
- accessory.context.Battery = this.Battery as object;
84
+ }
85
+ accessory.context.Battery = this.Battery as object
80
86
 
81
87
  // Initialize Battery Characteristics
82
- this.Battery.Service
83
- .setCharacteristic(this.hap.Characteristic.Name, this.Battery.Name)
84
- .setCharacteristic(this.hap.Characteristic.ChargingState, this.hap.Characteristic.ChargingState.NOT_CHARGEABLE)
85
- .getCharacteristic(this.hap.Characteristic.BatteryLevel)
86
- .onGet(() => {
87
- return this.Battery.BatteryLevel;
88
- });
89
-
90
- this.Battery.Service
91
- .getCharacteristic(this.hap.Characteristic.StatusLowBattery)
92
- .onGet(() => {
93
- return this.Battery.StatusLowBattery;
94
- });
95
- accessory.context.BatteryName = this.Battery.Name;
88
+ this.Battery.Service.setCharacteristic(this.hap.Characteristic.Name, this.Battery.Name).setCharacteristic(this.hap.Characteristic.ChargingState, this.hap.Characteristic.ChargingState.NOT_CHARGEABLE).getCharacteristic(this.hap.Characteristic.BatteryLevel).onGet(() => {
89
+ return this.Battery.BatteryLevel
90
+ })
91
+
92
+ this.Battery.Service.getCharacteristic(this.hap.Characteristic.StatusLowBattery).onGet(() => {
93
+ return this.Battery.StatusLowBattery
94
+ })
95
+ accessory.context.BatteryName = this.Battery.Name
96
96
 
97
97
  // InitializeTemperature Sensor Service
98
98
  if (device.iosensor?.hide_temperature) {
99
99
  if (this.TemperatureSensor) {
100
- this.debugLog('Removing Temperature Sensor Service');
101
- this.TemperatureSensor.Service = this.accessory.getService(this.hap.Service.TemperatureSensor) as Service;
102
- accessory.removeService(this.TemperatureSensor.Service);
100
+ this.debugLog('Removing Temperature Sensor Service')
101
+ this.TemperatureSensor.Service = this.accessory.getService(this.hap.Service.TemperatureSensor) as Service
102
+ accessory.removeService(this.TemperatureSensor.Service)
103
103
  }
104
104
  } else {
105
- accessory.context.TemperatureSensor = accessory.context.TemperatureSensor ?? {};
105
+ accessory.context.TemperatureSensor = accessory.context.TemperatureSensor ?? {}
106
106
  this.TemperatureSensor = {
107
107
  Name: `${accessory.displayName} Temperature Sensor`,
108
108
  Service: accessory.getService(this.hap.Service.TemperatureSensor) ?? this.accessory.addService(this.hap.Service.TemperatureSensor) as Service,
109
109
  CurrentTemperature: accessory.context.CurrentTemperature ?? 30,
110
- };
111
- accessory.context.TemperatureSensor = this.TemperatureSensor as object;
110
+ }
111
+ accessory.context.TemperatureSensor = this.TemperatureSensor as object
112
112
 
113
113
  // Initialize Temperature Sensor Characteristics
114
- this.TemperatureSensor.Service
115
- .setCharacteristic(this.hap.Characteristic.Name, this.TemperatureSensor.Name)
116
- .getCharacteristic(this.hap.Characteristic.CurrentTemperature)
117
- .setProps({
118
- unit: Units['CELSIUS'],
119
- validValueRanges: [-273.15, 100],
120
- minValue: -273.15,
121
- maxValue: 100,
122
- minStep: 0.1,
123
- })
124
- .onGet(() => {
125
- return this.TemperatureSensor!.CurrentTemperature;
126
- });
114
+ this.TemperatureSensor.Service.setCharacteristic(this.hap.Characteristic.Name, this.TemperatureSensor.Name).getCharacteristic(this.hap.Characteristic.CurrentTemperature).setProps({
115
+ unit: Units.CELSIUS,
116
+ validValueRanges: [-273.15, 100],
117
+ minValue: -273.15,
118
+ maxValue: 100,
119
+ minStep: 0.1,
120
+ }).onGet(() => {
121
+ return this.TemperatureSensor!.CurrentTemperature
122
+ })
127
123
  }
128
124
 
129
125
  // Initialize Humidity Sensor Service
130
126
  if (device.iosensor?.hide_humidity) {
131
127
  if (this.HumiditySensor) {
132
- this.debugLog('Removing Humidity Sensor Service');
133
- this.HumiditySensor.Service = this.accessory.getService(this.hap.Service.HumiditySensor) as Service;
134
- accessory.removeService(this.HumiditySensor.Service);
128
+ this.debugLog('Removing Humidity Sensor Service')
129
+ this.HumiditySensor.Service = this.accessory.getService(this.hap.Service.HumiditySensor) as Service
130
+ accessory.removeService(this.HumiditySensor.Service)
135
131
  }
136
132
  } else {
137
- accessory.context.HumiditySensor = accessory.context.HumiditySensor ?? {};
133
+ accessory.context.HumiditySensor = accessory.context.HumiditySensor ?? {}
138
134
  this.HumiditySensor = {
139
135
  Name: `${accessory.displayName} Humidity Sensor`,
140
136
  Service: accessory.getService(this.hap.Service.HumiditySensor) ?? this.accessory.addService(this.hap.Service.HumiditySensor) as Service,
141
137
  CurrentRelativeHumidity: accessory.context.CurrentRelativeHumidity ?? 50,
142
- };
143
- accessory.context.HumiditySensor = this.HumiditySensor as object;
138
+ }
139
+ accessory.context.HumiditySensor = this.HumiditySensor as object
144
140
 
145
141
  // Initialize Humidity Sensor Characteristics
146
- this.HumiditySensor.Service
147
- .setCharacteristic(this.hap.Characteristic.Name, this.HumiditySensor.Name)
148
- .getCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity)
149
- .setProps({
150
- minStep: 0.1,
151
- })
152
- .onGet(() => {
153
- return this.HumiditySensor!.CurrentRelativeHumidity;
154
- });
142
+ this.HumiditySensor.Service.setCharacteristic(this.hap.Characteristic.Name, this.HumiditySensor.Name).getCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity).setProps({
143
+ minStep: 0.1,
144
+ }).onGet(() => {
145
+ return this.HumiditySensor!.CurrentRelativeHumidity
146
+ })
155
147
  }
156
148
 
157
149
  // Retrieve initial values and updateHomekit
158
- this.debugLog('Retrieve initial values and update Homekit');
159
- this.refreshStatus();
150
+ try {
151
+ this.debugLog('Retrieve initial values and update Homekit')
152
+ this.refreshStatus()
153
+ } catch (e: any) {
154
+ this.errorLog(`failed to retrieve initial values and update Homekit, Error: ${e}`)
155
+ }
156
+
157
+ // regisiter webhook event handler if enabled
158
+ try {
159
+ this.debugLog('Registering Webhook Event Handler')
160
+ this.registerWebhook()
161
+ } catch (e: any) {
162
+ this.errorLog(`failed to registerWebhook, Error: ${e}`)
163
+ }
160
164
 
161
- //regisiter webhook event handler
162
- this.debugLog('Registering Webhook Event Handler');
163
- this.registerWebhook();
165
+ // regisiter platform BLE event handler if enabled
166
+ try {
167
+ this.debugLog('Registering Platform BLE Event Handler')
168
+ this.registerPlatformBLE()
169
+ } catch (e: any) {
170
+ this.errorLog(`failed to registerPlatformBLE, Error: ${e}`)
171
+ }
164
172
 
165
173
  // Start an update interval
166
174
  interval(this.deviceRefreshRate * 1000)
167
175
  .pipe(skipWhile(() => this.ioSensorUpdateInProgress))
168
176
  .subscribe(async () => {
169
- await this.refreshStatus();
170
- });
177
+ await this.refreshStatus()
178
+ })
171
179
  }
172
180
 
173
181
  async BLEparseStatus(): Promise<void> {
174
- await this.debugLog('BLEparseStatus');
175
- await this.debugLog(`(battery, temperature, humidity) = BLE:(${this.serviceData.battery}, ${this.serviceData.temperature.c},`
176
- + ` ${this.serviceData.humidity}), current:(${this.Battery.BatteryLevel}, ${this.TemperatureSensor?.CurrentTemperature},`
177
- + ` ${this.HumiditySensor?.CurrentRelativeHumidity})`);
182
+ await this.debugLog('BLEparseStatus')
183
+ await this.debugLog(`(battery, temperature, humidity) = BLE:(${this.serviceData.battery}, ${this.serviceData.temperature.c}, ${this.serviceData.humidity}), current:(${this.Battery.BatteryLevel}, ${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity})`)
178
184
 
179
185
  // BatteryLevel
180
- this.Battery.BatteryLevel = this.serviceData.battery;
181
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
186
+ this.Battery.BatteryLevel = this.serviceData.battery
187
+ await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
182
188
 
183
189
  // StatusLowBattery
184
190
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
185
- ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
186
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
191
+ ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
192
+ : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
193
+ await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
187
194
 
188
195
  // CurrentRelativeHumidity
189
196
  if (!this.device.iosensor?.hide_humidity && this.HumiditySensor?.Service) {
190
- this.HumiditySensor.CurrentRelativeHumidity = validHumidity(this.serviceData.humidity, 0, 100);
191
- await this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}%`);
197
+ this.HumiditySensor.CurrentRelativeHumidity = validHumidity(this.serviceData.humidity, 0, 100)
198
+ await this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}%`)
192
199
  }
193
200
 
194
201
  // Current Temperature
195
202
  if (!this.device.meter?.hide_temperature && this.TemperatureSensor?.Service) {
196
- const CELSIUS = this.serviceData.temperature.c < 0 ? 0 : this.serviceData.temperature.c > 100 ? 100 : this.serviceData.temperature.c;
197
- this.TemperatureSensor.CurrentTemperature = CELSIUS;
198
- await this.debugLog(`Temperature: ${this.TemperatureSensor.CurrentTemperature}°c`);
203
+ const CELSIUS = this.serviceData.temperature.c < 0 ? 0 : this.serviceData.temperature.c > 100 ? 100 : this.serviceData.temperature.c
204
+ this.TemperatureSensor.CurrentTemperature = CELSIUS
205
+ await this.debugLog(`Temperature: ${this.TemperatureSensor.CurrentTemperature}°c`)
199
206
  }
200
207
  }
201
208
 
202
209
  async openAPIparseStatus(): Promise<void> {
203
- await this.debugLog('openAPIparseStatus');
204
- await this.debugLog(`(battery, temperature, humidity) = OpenAPI:(${this.deviceStatus.battery}, ${this.deviceStatus.temperature},`
205
- + ` ${this.deviceStatus.humidity}), current:(${this.Battery.BatteryLevel}, ${this.TemperatureSensor?.CurrentTemperature},`
206
- + ` ${this.HumiditySensor?.CurrentRelativeHumidity})`);
210
+ await this.debugLog('openAPIparseStatus')
211
+ await this.debugLog(`(battery, temperature, humidity) = OpenAPI:(${this.deviceStatus.battery}, ${this.deviceStatus.temperature}, ${this.deviceStatus.humidity}), current:(${this.Battery.BatteryLevel}, ${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity})`)
207
212
 
208
213
  // BatteryLevel
209
- this.Battery.BatteryLevel = this.deviceStatus.battery;
210
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
214
+ this.Battery.BatteryLevel = this.deviceStatus.battery
215
+ await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
211
216
 
212
217
  // StatusLowBattery
213
218
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
214
- ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
215
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
219
+ ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
220
+ : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
221
+ await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
216
222
 
217
223
  // CurrentRelativeHumidity
218
224
  if (!this.device.iosensor?.hide_humidity && this.HumiditySensor?.Service) {
219
- this.HumiditySensor.CurrentRelativeHumidity = this.deviceStatus.humidity;
220
- await this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}%`);
225
+ this.HumiditySensor.CurrentRelativeHumidity = this.deviceStatus.humidity
226
+ await this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}%`)
221
227
  }
222
228
 
223
229
  // Current Temperature
224
230
  if (!this.device.meter?.hide_temperature && this.TemperatureSensor?.Service) {
225
- this.TemperatureSensor.CurrentTemperature = this.deviceStatus.temperature;
226
- await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}°c`);
231
+ this.TemperatureSensor.CurrentTemperature = this.deviceStatus.temperature
232
+ await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}°c`)
227
233
  }
228
234
 
229
235
  // Firmware Version
230
236
  if (this.deviceStatus.version) {
231
- const version = this.deviceStatus.version.toString();
232
- await this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`);
233
- const deviceVersion = version.replace(/^V|-.*$/g, '') ?? '0.0.0';
237
+ const version = this.deviceStatus.version.toString()
238
+ await this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`)
239
+ const deviceVersion = version.replace(/^V|-.*$/g, '') ?? '0.0.0'
234
240
  this.accessory
235
241
  .getService(this.hap.Service.AccessoryInformation)!
236
242
  .setCharacteristic(this.hap.Characteristic.HardwareRevision, deviceVersion)
237
243
  .setCharacteristic(this.hap.Characteristic.FirmwareRevision, deviceVersion)
238
244
  .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
239
- .updateValue(deviceVersion);
240
- this.accessory.context.version = deviceVersion;
241
- await this.debugSuccessLog(`version: ${this.accessory.context.version}`);
245
+ .updateValue(deviceVersion)
246
+ this.accessory.context.version = deviceVersion
247
+ await this.debugSuccessLog(`version: ${this.accessory.context.version}`)
242
248
  }
243
249
  }
244
250
 
245
251
  async parseStatusWebhook(): Promise<void> {
246
- await this.debugLog('parseStatusWebhook');
247
- await this.debugLog(`(scale, temperature, humidity) = Webhook:(${this.webhookContext.scale}, ${convertUnits(this.webhookContext.temperature,
248
- this.webhookContext.scale, this.device.iosensor?.convertUnitTo)}, ${this.webhookContext.humidity}),`
249
- + ` current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity})`);
252
+ await this.debugLog('parseStatusWebhook')
253
+ await this.debugLog(`(scale, temperature, humidity) = Webhook:(${this.webhookContext.scale}, ${convertUnits(this.webhookContext.temperature, this.webhookContext.scale, this.device.iosensor?.convertUnitTo)}, ${this.webhookContext.humidity}), current:(${this.TemperatureSensor?.CurrentTemperature}, ${this.HumiditySensor?.CurrentRelativeHumidity})`)
250
254
 
251
255
  if (this.webhookContext.scale !== 'CELSIUS' && this.device.iosensor?.convertUnitTo === undefined) {
252
- await this.warnLog(`received a non-CELSIUS Webhook scale: ${this.webhookContext.scale}, Use the *convertUnitsTo* config under Hub settings,`
253
- + ' if displaying incorrectly in HomeKit.');
256
+ await this.warnLog(`received a non-CELSIUS Webhook scale: ${this.webhookContext.scale}, Use the *convertUnitsTo* config under Hub settings, if displaying incorrectly in HomeKit.`)
254
257
  }
255
258
  // CurrentRelativeHumidity
256
259
  if (this.device.iosensor?.hide_humidity && this.HumiditySensor?.Service) {
257
- this.HumiditySensor.CurrentRelativeHumidity = this.webhookContext.humidity;
258
- await this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}%`);
260
+ this.HumiditySensor.CurrentRelativeHumidity = this.webhookContext.humidity
261
+ await this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}%`)
259
262
  }
260
263
  // CurrentTemperature
261
264
  if (this.device.iosensor?.hide_temperature && this.TemperatureSensor?.Service) {
262
- this.TemperatureSensor.CurrentTemperature = convertUnits(this.webhookContext.temperature, this.webhookContext.scale,
263
- this.device.iosensor?.convertUnitTo);
264
- await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}°c`);
265
+ this.TemperatureSensor.CurrentTemperature = convertUnits(this.webhookContext.temperature, this.webhookContext.scale, this.device.iosensor?.convertUnitTo)
266
+ await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}°c`)
265
267
  }
266
268
  }
267
269
 
@@ -270,93 +272,97 @@ export class IOSensor extends deviceBase {
270
272
  */
271
273
  async refreshStatus(): Promise<void> {
272
274
  if (!this.device.enableCloudService && this.OpenAPI) {
273
- await this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`);
274
- } else if (this.BLE || this.config.options?.BLE) {
275
- await this.BLERefreshStatus();
275
+ await this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
276
+ } else if (this.BLE) {
277
+ await this.BLERefreshStatus()
276
278
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
277
- await this.openAPIRefreshStatus();
279
+ await this.openAPIRefreshStatus()
278
280
  } else {
279
- await this.offlineOff();
280
- await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`);
281
+ await this.offlineOff()
282
+ await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`)
281
283
  }
282
284
  }
283
285
 
284
286
  async BLERefreshStatus(): Promise<void> {
285
- await this.debugLog('BLERefreshStatus');
287
+ await this.debugLog('BLERefreshStatus')
288
+ const switchbot = await this.switchbotBLE()
289
+ if (switchbot === undefined) {
290
+ await this.BLERefreshConnection(switchbot)
291
+ } else {
292
+ // Start to monitor advertisement packets
293
+ (async () => {
294
+ // Start to monitor advertisement packets
295
+ const serviceData = await this.monitorAdvertisementPackets(switchbot) as outdoorMeterServiceData
296
+ // Update HomeKit
297
+ if (serviceData.model === SwitchBotBLEModel.OutdoorMeter && serviceData.modelName === SwitchBotBLEModelName.OutdoorMeter) {
298
+ this.serviceData = serviceData
299
+ await this.BLEparseStatus()
300
+ await this.updateHomeKitCharacteristics()
301
+ } else {
302
+ await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`)
303
+ await this.BLERefreshConnection(switchbot)
304
+ }
305
+ })()
306
+ }
307
+ }
308
+
309
+ async registerPlatformBLE(): Promise<void> {
310
+ await this.debugLog('registerPlatformBLE')
286
311
  if (this.config.options?.BLE) {
287
- await this.debugLog('is listening to Platform BLE.');
288
- this.device.bleMac = this.device.deviceId!.match(/.{1,2}/g)!.join(':').toLowerCase();
289
- await this.debugLog(`bleMac: ${this.device.bleMac}`);
312
+ await this.debugLog('is listening to Platform BLE.')
313
+ this.device.bleMac = this.device.deviceId!.match(/.{1,2}/g)!.join(':').toLowerCase()
314
+ await this.debugLog(`bleMac: ${this.device.bleMac}`)
290
315
  this.platform.bleEventHandler[this.device.bleMac] = async (context: outdoorMeterServiceData) => {
291
316
  try {
292
- await this.debugLog(`received BLE: ${JSON.stringify(context)}`);
293
- this.serviceData = context;
294
- await this.BLEparseStatus();
295
- await this.updateHomeKitCharacteristics();
317
+ await this.debugLog(`received BLE: ${JSON.stringify(context)}`)
318
+ this.serviceData = context
319
+ await this.BLEparseStatus()
320
+ await this.updateHomeKitCharacteristics()
296
321
  } catch (e: any) {
297
- await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e}`);
322
+ await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e}`)
298
323
  }
299
- };
300
- } else {
301
- await this.debugLog('is using Device BLE Scanning.');
302
- const switchbot = await this.switchbotBLE();
303
- if (switchbot === undefined) {
304
- await this.BLERefreshConnection(switchbot);
305
- } else {
306
- // Start to monitor advertisement packets
307
- (async () => {
308
- // Start to monitor advertisement packets
309
- const serviceData = await this.monitorAdvertisementPackets(switchbot) as outdoorMeterServiceData;
310
- // Update HomeKit
311
- if (serviceData.model === SwitchBotBLEModel.OutdoorMeter && serviceData.modelName === SwitchBotBLEModelName.OutdoorMeter) {
312
- this.serviceData = serviceData;
313
- await this.BLEparseStatus();
314
- await this.updateHomeKitCharacteristics();
315
- } else {
316
- await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`);
317
- await this.BLERefreshConnection(switchbot);
318
- }
319
- })();
320
324
  }
325
+ } else {
326
+ await this.debugLog('is not listening to Platform BLE')
321
327
  }
322
328
  }
323
329
 
324
330
  async openAPIRefreshStatus(): Promise<void> {
325
- await this.debugLog('openAPIRefreshStatus');
331
+ await this.debugLog('openAPIRefreshStatus')
326
332
  try {
327
- const { body, statusCode } = await this.deviceRefreshStatus();
328
- const deviceStatus: any = await body.json();
329
- await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);;
333
+ const { body, statusCode } = await this.deviceRefreshStatus()
334
+ const deviceStatus: any = await body.json()
335
+ await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
330
336
  if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
331
- await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
332
- this.deviceStatus = deviceStatus.body;
333
- await this.openAPIparseStatus();
334
- await this.updateHomeKitCharacteristics();
337
+ await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
338
+ this.deviceStatus = deviceStatus.body
339
+ await this.openAPIparseStatus()
340
+ await this.updateHomeKitCharacteristics()
335
341
  } else {
336
- await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
337
- await this.debugWarnLog(statusCode, deviceStatus);
342
+ await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
343
+ await this.debugWarnLog(statusCode, deviceStatus)
338
344
  }
339
345
  } catch (e: any) {
340
- await this.apiError(e);
341
- await this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
346
+ await this.apiError(e)
347
+ await this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
342
348
  }
343
349
  }
344
350
 
345
351
  async registerWebhook() {
346
352
  if (this.device.webhook) {
347
- await this.debugLog('is listening webhook.');
353
+ await this.debugLog('is listening webhook.')
348
354
  this.platform.webhookEventHandler[this.device.deviceId] = async (context: outdoorMeterWebhookContext) => {
349
355
  try {
350
- await this.debugLog(`received Webhook: ${JSON.stringify(context)}`);
351
- this.webhookContext = context;
352
- await this.parseStatusWebhook();
353
- await this.updateHomeKitCharacteristics();
356
+ await this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
357
+ this.webhookContext = context
358
+ await this.parseStatusWebhook()
359
+ await this.updateHomeKitCharacteristics()
354
360
  } catch (e: any) {
355
- await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e}`);
361
+ await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e}`)
356
362
  }
357
- };
363
+ }
358
364
  } else {
359
- await this.debugLog('is not listening webhook.');
365
+ await this.debugLog('is not listening webhook.')
360
366
  }
361
367
  }
362
368
 
@@ -366,49 +372,45 @@ export class IOSensor extends deviceBase {
366
372
  async updateHomeKitCharacteristics(): Promise<void> {
367
373
  // CurrentRelativeHumidity
368
374
  if (!this.device.iosensor?.hide_humidity && this.HumiditySensor?.Service) {
369
- await this.updateCharacteristic(this.HumiditySensor.Service, this.hap.Characteristic.CurrentRelativeHumidity,
370
- this.HumiditySensor.CurrentRelativeHumidity, 'CurrentRelativeHumidity');
375
+ await this.updateCharacteristic(this.HumiditySensor.Service, this.hap.Characteristic.CurrentRelativeHumidity, this.HumiditySensor.CurrentRelativeHumidity, 'CurrentRelativeHumidity')
371
376
  }
372
377
  // CurrentTemperature
373
378
  if (!this.device.iosensor?.hide_temperature && this.TemperatureSensor?.Service) {
374
- await this.updateCharacteristic(this.TemperatureSensor.Service, this.hap.Characteristic.CurrentTemperature,
375
- this.TemperatureSensor.CurrentTemperature, 'CurrentTemperature');
379
+ await this.updateCharacteristic(this.TemperatureSensor.Service, this.hap.Characteristic.CurrentTemperature, this.TemperatureSensor.CurrentTemperature, 'CurrentTemperature')
376
380
  }
377
381
  // BatteryLevel
378
- await this.updateCharacteristic(this.Battery.Service, this.hap.Characteristic.BatteryLevel,
379
- this.Battery.BatteryLevel, 'BatteryLevel');
382
+ await this.updateCharacteristic(this.Battery.Service, this.hap.Characteristic.BatteryLevel, this.Battery.BatteryLevel, 'BatteryLevel')
380
383
  // StatusLowBattery
381
- await this.updateCharacteristic(this.Battery.Service, this.hap.Characteristic.StatusLowBattery,
382
- this.Battery.StatusLowBattery, 'StatusLowBattery');
384
+ await this.updateCharacteristic(this.Battery.Service, this.hap.Characteristic.StatusLowBattery, this.Battery.StatusLowBattery, 'StatusLowBattery')
383
385
  }
384
386
 
385
387
  async BLERefreshConnection(switchbot: any): Promise<void> {
386
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
388
+ await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`)
387
389
  if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
388
- await this.warnLog('Using OpenAPI Connection to Refresh Status');
389
- await this.openAPIRefreshStatus();
390
+ await this.warnLog('Using OpenAPI Connection to Refresh Status')
391
+ await this.openAPIRefreshStatus()
390
392
  }
391
393
  }
392
394
 
393
395
  async offlineOff(): Promise<void> {
394
396
  if (this.device.offline) {
395
397
  if (!this.device.iosensor?.hide_humidity && this.HumiditySensor?.Service) {
396
- this.HumiditySensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity, 50);
398
+ this.HumiditySensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity, 50)
397
399
  }
398
400
  if (!this.device.iosensor?.hide_temperature && this.TemperatureSensor?.Service) {
399
- this.TemperatureSensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, 30);
401
+ this.TemperatureSensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, 30)
400
402
  }
401
403
  }
402
404
  }
403
405
 
404
406
  async apiError(e: any): Promise<void> {
405
407
  if (!this.device.iosensor?.hide_humidity && this.HumiditySensor?.Service) {
406
- this.HumiditySensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity, e);
408
+ this.HumiditySensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity, e)
407
409
  }
408
410
  if (!this.device.iosensor?.hide_temperature && this.TemperatureSensor?.Service) {
409
- this.TemperatureSensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, e);
411
+ this.TemperatureSensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, e)
410
412
  }
411
- this.Battery.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, e);
412
- this.Battery.Service.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, e);
413
+ this.Battery.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, e)
414
+ this.Battery.Service.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, e)
413
415
  }
414
416
  }