@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
@@ -1,10 +1,10 @@
1
- /* Copyright(C) 2021-2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
2
- *
3
- * bot.ts: @switchbot/homebridge-switchbot.
4
- */
5
- import { deviceBase } from './device.js';
1
+ /*
2
+ * For Testing Locally:
3
+ * import { SwitchBotBLEModel, SwitchBotBLEModelName } from '/Users/Shared/GitHub/OpenWonderLabs/node-switchbot/dist/index.js';
4
+ */
6
5
  import { SwitchBotBLEModel, SwitchBotBLEModelName } from 'node-switchbot';
7
- import { Subject, debounceTime, interval, skipWhile, take, tap } from 'rxjs';
6
+ import { debounceTime, interval, skipWhile, Subject, take, tap } from 'rxjs';
7
+ import { deviceBase } from './device.js';
8
8
  /**
9
9
  * Platform Accessory
10
10
  * An instance of this class is created for each accessory your platform registers
@@ -27,7 +27,7 @@ export class Bot extends deviceBase {
27
27
  On;
28
28
  // OpenAPI
29
29
  deviceStatus;
30
- //Webhook
30
+ // Webhook
31
31
  webhookContext;
32
32
  // BLE
33
33
  serviceData;
@@ -59,10 +59,7 @@ export class Bot extends deviceBase {
59
59
  };
60
60
  accessory.context.Battery = this.Battery;
61
61
  // Initialize Battery Characteristics
62
- this.Battery.Service
63
- .setCharacteristic(this.hap.Characteristic.Name, this.Battery.Name)
64
- .setCharacteristic(this.hap.Characteristic.StatusLowBattery, this.Battery.StatusLowBattery)
65
- .setCharacteristic(this.hap.Characteristic.ChargingState, this.hap.Characteristic.ChargingState.NOT_CHARGEABLE);
62
+ this.Battery.Service.setCharacteristic(this.hap.Characteristic.Name, this.Battery.Name).setCharacteristic(this.hap.Characteristic.StatusLowBattery, this.Battery.StatusLowBattery).setCharacteristic(this.hap.Characteristic.ChargingState, this.hap.Characteristic.ChargingState.NOT_CHARGEABLE);
66
63
  // deviceType
67
64
  if (this.botDeviceType === 'switch') {
68
65
  // Set category
@@ -76,10 +73,7 @@ export class Bot extends deviceBase {
76
73
  accessory.context.Switch = this.Switch;
77
74
  this.debugLog('Displaying as Switch');
78
75
  // Initialize Switch Characteristics
79
- this.Switch.Service
80
- .setCharacteristic(this.hap.Characteristic.Name, this.Switch.Name)
81
- .getCharacteristic(this.hap.Characteristic.On)
82
- .onSet(this.OnSet.bind(this));
76
+ this.Switch.Service.setCharacteristic(this.hap.Characteristic.Name, this.Switch.Name).getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
83
77
  // Remove other services
84
78
  this.removeFanService(accessory);
85
79
  this.removeLockService(accessory);
@@ -103,17 +97,12 @@ export class Bot extends deviceBase {
103
97
  accessory.context.GarageDoor = this.GarageDoor;
104
98
  this.debugLog('Displaying as Garage Door Opener');
105
99
  // Initialize GarageDoor Characteristics
106
- this.GarageDoor.Service
107
- .setCharacteristic(this.hap.Characteristic.Name, this.GarageDoor.Name)
108
- .setCharacteristic(this.hap.Characteristic.ObstructionDetected, false)
109
- .getCharacteristic(this.hap.Characteristic.TargetDoorState)
110
- .setProps({
100
+ this.GarageDoor.Service.setCharacteristic(this.hap.Characteristic.Name, this.GarageDoor.Name).setCharacteristic(this.hap.Characteristic.ObstructionDetected, false).getCharacteristic(this.hap.Characteristic.TargetDoorState).setProps({
111
101
  validValues: [0, 100],
112
102
  minValue: 0,
113
103
  maxValue: 100,
114
104
  minStep: 100,
115
- })
116
- .onSet(this.OnSet.bind(this));
105
+ }).onSet(this.OnSet.bind(this));
117
106
  // Remove other services
118
107
  this.removeFanService(accessory);
119
108
  this.removeLockService(accessory);
@@ -137,16 +126,12 @@ export class Bot extends deviceBase {
137
126
  accessory.context.Door = this.Door;
138
127
  this.debugLog('Displaying as Door');
139
128
  // Initialize Door Characteristics
140
- this.Door.Service
141
- .setCharacteristic(this.hap.Characteristic.Name, this.Door.Name)
142
- .setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
143
- .getCharacteristic(this.hap.Characteristic.TargetPosition).setProps({
129
+ this.Door.Service.setCharacteristic(this.hap.Characteristic.Name, this.Door.Name).setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED).getCharacteristic(this.hap.Characteristic.TargetPosition).setProps({
144
130
  validValues: [0, 100],
145
131
  minValue: 0,
146
132
  maxValue: 100,
147
133
  minStep: 100,
148
- })
149
- .onSet(this.OnSet.bind(this));
134
+ }).onSet(this.OnSet.bind(this));
150
135
  // Remove other services
151
136
  this.removeFanService(accessory);
152
137
  this.removeLockService(accessory);
@@ -170,16 +155,12 @@ export class Bot extends deviceBase {
170
155
  accessory.context.Window = this.Window;
171
156
  this.debugLog('Displaying as Window');
172
157
  // Initialize Window Characteristics
173
- this.Window.Service
174
- .setCharacteristic(this.hap.Characteristic.Name, this.Window.Name)
175
- .setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
176
- .getCharacteristic(this.hap.Characteristic.TargetPosition).setProps({
158
+ this.Window.Service.setCharacteristic(this.hap.Characteristic.Name, this.Window.Name).setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED).getCharacteristic(this.hap.Characteristic.TargetPosition).setProps({
177
159
  validValues: [0, 100],
178
160
  minValue: 0,
179
161
  maxValue: 100,
180
162
  minStep: 100,
181
- })
182
- .onSet(this.OnSet.bind(this));
163
+ }).onSet(this.OnSet.bind(this));
183
164
  // Remove other services
184
165
  this.removeFanService(accessory);
185
166
  this.removeLockService(accessory);
@@ -203,17 +184,12 @@ export class Bot extends deviceBase {
203
184
  accessory.context.WindowCovering = this.WindowCovering;
204
185
  this.debugLog('Displaying as Window Covering');
205
186
  // Initialize WindowCovering Characteristics
206
- this.WindowCovering.Service
207
- .setCharacteristic(this.hap.Characteristic.Name, this.WindowCovering.Name)
208
- .setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
209
- .getCharacteristic(this.hap.Characteristic.TargetPosition)
210
- .setProps({
187
+ this.WindowCovering.Service.setCharacteristic(this.hap.Characteristic.Name, this.WindowCovering.Name).setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED).getCharacteristic(this.hap.Characteristic.TargetPosition).setProps({
211
188
  validValues: [0, 100],
212
189
  minValue: 0,
213
190
  maxValue: 100,
214
191
  minStep: 100,
215
- })
216
- .onSet(this.OnSet.bind(this));
192
+ }).onSet(this.OnSet.bind(this));
217
193
  // Remove other services
218
194
  this.removeFanService(accessory);
219
195
  this.removeLockService(accessory);
@@ -237,11 +213,7 @@ export class Bot extends deviceBase {
237
213
  accessory.context.LockMechanism = this.LockMechanism;
238
214
  this.debugLog('Displaying as Lock');
239
215
  // Initialize Lock Characteristics
240
- this.LockMechanism.Service
241
- .setCharacteristic(this.hap.Characteristic.Name, this.LockMechanism.Name)
242
- .setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
243
- .getCharacteristic(this.hap.Characteristic.LockTargetState)
244
- .onSet(this.OnSet.bind(this));
216
+ this.LockMechanism.Service.setCharacteristic(this.hap.Characteristic.Name, this.LockMechanism.Name).setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED).getCharacteristic(this.hap.Characteristic.LockTargetState).onSet(this.OnSet.bind(this));
245
217
  // Remove other services
246
218
  this.removeFanService(accessory);
247
219
  this.removeDoorService(accessory);
@@ -265,10 +237,7 @@ export class Bot extends deviceBase {
265
237
  accessory.context.Faucet = this.Faucet;
266
238
  this.debugLog('Displaying as Faucet');
267
239
  // Initialize Faucet Characteristics
268
- this.Faucet.Service
269
- .setCharacteristic(this.hap.Characteristic.Name, this.Faucet.Name)
270
- .getCharacteristic(this.hap.Characteristic.Active)
271
- .onSet(this.OnSet.bind(this));
240
+ this.Faucet.Service.setCharacteristic(this.hap.Characteristic.Name, this.Faucet.Name).getCharacteristic(this.hap.Characteristic.Active).onSet(this.OnSet.bind(this));
272
241
  // Remove other services
273
242
  this.removeFanService(accessory);
274
243
  this.removeLockService(accessory);
@@ -292,10 +261,7 @@ export class Bot extends deviceBase {
292
261
  accessory.context.Fan = this.Fan;
293
262
  this.debugLog('Displaying as Fan');
294
263
  // Initialize Fan Characteristics
295
- this.Fan.Service
296
- .setCharacteristic(this.hap.Characteristic.Name, this.Fan.Name)
297
- .getCharacteristic(this.hap.Characteristic.Active)
298
- .onSet(this.OnSet.bind(this));
264
+ this.Fan.Service.setCharacteristic(this.hap.Characteristic.Name, this.Fan.Name).getCharacteristic(this.hap.Characteristic.Active).onSet(this.OnSet.bind(this));
299
265
  // Remove other services
300
266
  this.removeLockService(accessory);
301
267
  this.removeDoorService(accessory);
@@ -314,16 +280,12 @@ export class Bot extends deviceBase {
314
280
  accessory.context.StatefulProgrammableSwitch = accessory.context.StatefulProgrammableSwitch ?? {};
315
281
  this.StatefulProgrammableSwitch = {
316
282
  Name: accessory.displayName,
317
- Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
318
- ?? accessory.addService(this.hap.Service.StatefulProgrammableSwitch),
283
+ Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch) ?? accessory.addService(this.hap.Service.StatefulProgrammableSwitch),
319
284
  };
320
285
  accessory.context.StatefulProgrammableSwitch = this.StatefulProgrammableSwitch;
321
286
  this.debugLog('Displaying as Stateful Programmable Switch');
322
287
  // Initialize StatefulProgrammableSwitch Characteristics
323
- this.StatefulProgrammableSwitch.Service
324
- .setCharacteristic(this.hap.Characteristic.Name, this.StatefulProgrammableSwitch.Name)
325
- .getCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState)
326
- .onSet(this.OnSet.bind(this));
288
+ this.StatefulProgrammableSwitch.Service.setCharacteristic(this.hap.Characteristic.Name, this.StatefulProgrammableSwitch.Name).getCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState).onSet(this.OnSet.bind(this));
327
289
  // Remove other services
328
290
  this.removeFanService(accessory);
329
291
  this.removeLockService(accessory);
@@ -347,10 +309,7 @@ export class Bot extends deviceBase {
347
309
  accessory.context.Outlet = this.Outlet;
348
310
  this.debugLog('Displaying as Outlet');
349
311
  // Initialize Outlet Characteristics
350
- this.Outlet.Service
351
- .setCharacteristic(this.hap.Characteristic.Name, this.Outlet.Name)
352
- .getCharacteristic(this.hap.Characteristic.On)
353
- .onSet(this.OnSet.bind(this));
312
+ this.Outlet.Service.setCharacteristic(this.hap.Characteristic.Name, this.Outlet.Name).getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
354
313
  // Remove other services
355
314
  this.removeFanService(accessory);
356
315
  this.removeLockService(accessory);
@@ -366,11 +325,29 @@ export class Bot extends deviceBase {
366
325
  this.errorLog('Device Type not set');
367
326
  }
368
327
  // Retrieve initial values and updateHomekit
369
- this.debugLog('Retrieve initial values and update Homekit');
370
- this.refreshStatus();
371
- //regisiter webhook event handler
372
- this.debugLog('Registering Webhook Event Handler');
373
- this.registerWebhook();
328
+ try {
329
+ this.debugLog('Retrieve initial values and update Homekit');
330
+ this.refreshStatus();
331
+ }
332
+ catch (e) {
333
+ this.errorLog(`failed to retrieve initial values and update Homekit, Error: ${e}`);
334
+ }
335
+ // regisiter webhook event handler if enabled
336
+ try {
337
+ this.debugLog('Registering Webhook Event Handler');
338
+ this.registerWebhook();
339
+ }
340
+ catch (e) {
341
+ this.errorLog(`failed to registerWebhook, Error: ${e}`);
342
+ }
343
+ // regisiter platform BLE event handler if enabled
344
+ try {
345
+ this.debugLog('Registering Platform BLE Event Handler');
346
+ this.registerPlatformBLE();
347
+ }
348
+ catch (e) {
349
+ this.errorLog(`failed to registerPlatformBLE, Error: ${e}`);
350
+ }
374
351
  // Start an update interval
375
352
  interval(this.deviceRefreshRate * 1000)
376
353
  .pipe(skipWhile(() => this.botUpdateInProgress))
@@ -408,8 +385,7 @@ export class Bot extends deviceBase {
408
385
  */
409
386
  async BLEparseStatus() {
410
387
  await this.debugLog('BLEparseStatus');
411
- await this.debugLog(`(power, battery, deviceMode) = BLE:(${this.serviceData.state}, ${this.serviceData.battery}, ${this.serviceData.mode}),`
412
- + ` current:(${this.accessory.context.On}, ${this.Battery.BatteryLevel}, ${this.botMode})`);
388
+ await this.debugLog(`(power, battery, deviceMode) = BLE:(${this.serviceData.state}, ${this.serviceData.battery}, ${this.serviceData.mode}), current:(${this.accessory.context.On}, ${this.Battery.BatteryLevel}, ${this.botMode})`);
413
389
  // BLEmode (true if Switch Mode) | (false if Press Mode)
414
390
  this.On = this.serviceData.mode ? this.serviceData.state : false;
415
391
  const mode = this.serviceData.mode ? 'Switch' : 'Press';
@@ -420,7 +396,8 @@ export class Bot extends deviceBase {
420
396
  await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
421
397
  // StatusLowBattery
422
398
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
423
- ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
399
+ ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
400
+ : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
424
401
  await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
425
402
  }
426
403
  /**
@@ -428,10 +405,9 @@ export class Bot extends deviceBase {
428
405
  */
429
406
  async openAPIparseStatus() {
430
407
  await this.debugLog('openAPIparseStatus');
431
- await this.debugLog(`(power, battery, deviceMode) = API:(${this.deviceStatus.power}, ${this.deviceStatus.battery}, ${this.botMode}),`
432
- + ` current:(${this.accessory.context.On}, ${this.Battery.BatteryLevel}, ${this.botMode})`);
408
+ await this.debugLog(`(power, battery, deviceMode) = API:(${this.deviceStatus.power}, ${this.deviceStatus.battery}, ${this.botMode}), current:(${this.accessory.context.On}, ${this.Battery.BatteryLevel}, ${this.botMode})`);
433
409
  // On
434
- this.On = this.botMode === 'press' ? false : this.deviceStatus.power === 'on' ? true : false;
410
+ this.On = this.botMode === 'press' ? false : this.deviceStatus.power === 'on';
435
411
  this.accessory.context.On = this.On;
436
412
  await this.debugLog(`On: ${this.accessory.context.On}`);
437
413
  // Battery Level
@@ -439,7 +415,8 @@ export class Bot extends deviceBase {
439
415
  await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
440
416
  // StatusLowBattery
441
417
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
442
- ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
418
+ ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
419
+ : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
443
420
  await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
444
421
  // Firmware Version
445
422
  if (this.deviceStatus.version) {
@@ -458,17 +435,17 @@ export class Bot extends deviceBase {
458
435
  }
459
436
  async parseStatusWebhook() {
460
437
  await this.debugLog('parseStatusWebhook');
461
- await this.debugLog(`(power, battery, deviceMode) = Webhook:(${this.webhookContext.power}, ${this.webhookContext.battery},`
462
- + ` ${this.webhookContext.deviceMode}), current:(${this.On}, ${this.Battery.BatteryLevel}, ${this.botMode})`);
438
+ await this.debugLog(`(power, battery, deviceMode) = Webhook:(${this.webhookContext.power}, ${this.webhookContext.battery}, ${this.webhookContext.deviceMode}), current:(${this.On}, ${this.Battery.BatteryLevel}, ${this.botMode})`);
463
439
  // On
464
- this.On = this.webhookContext.power === 'on' ? true : false;
440
+ this.On = this.webhookContext.power === 'on';
465
441
  await this.debugLog(`On: ${this.On}`);
466
442
  // BatteryLevel
467
443
  this.Battery.BatteryLevel = this.webhookContext.battery;
468
444
  await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
469
445
  // StatusLowBattery
470
446
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
471
- ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
447
+ ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
448
+ : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
472
449
  await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
473
450
  // Mode
474
451
  this.botMode = this.webhookContext.deviceMode;
@@ -481,7 +458,7 @@ export class Bot extends deviceBase {
481
458
  if (!this.device.enableCloudService && this.OpenAPI) {
482
459
  await this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`);
483
460
  }
484
- else if (this.BLE || this.config.options?.BLE) {
461
+ else if (this.BLE) {
485
462
  await this.BLERefreshStatus();
486
463
  }
487
464
  else if (this.OpenAPI && this.platform.config.credentials?.token) {
@@ -494,6 +471,30 @@ export class Bot extends deviceBase {
494
471
  }
495
472
  async BLERefreshStatus() {
496
473
  await this.debugLog('BLERefreshStatus');
474
+ const switchbot = await this.switchbotBLE();
475
+ if (switchbot === undefined) {
476
+ await this.BLERefreshConnection(switchbot);
477
+ }
478
+ else {
479
+ // Start to monitor advertisement packets
480
+ (async () => {
481
+ // Start to monitor advertisement packets
482
+ const serviceData = await this.monitorAdvertisementPackets(switchbot);
483
+ // Update HomeKit
484
+ if (serviceData.model === SwitchBotBLEModel.Bot && serviceData.modelName === SwitchBotBLEModelName.Bot) {
485
+ this.serviceData = serviceData;
486
+ await this.BLEparseStatus();
487
+ await this.updateHomeKitCharacteristics();
488
+ }
489
+ else {
490
+ await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`);
491
+ await this.BLERefreshConnection(switchbot);
492
+ }
493
+ })();
494
+ }
495
+ }
496
+ async registerPlatformBLE() {
497
+ await this.debugLog('registerPlatformBLE');
497
498
  if (this.config.options?.BLE) {
498
499
  await this.debugLog('is listening to Platform BLE.');
499
500
  this.device.bleMac = this.device.deviceId.match(/.{1,2}/g).join(':').toLowerCase();
@@ -511,28 +512,7 @@ export class Bot extends deviceBase {
511
512
  };
512
513
  }
513
514
  else {
514
- await this.debugLog('is using Device BLE Scanning.');
515
- const switchbot = await this.switchbotBLE();
516
- if (switchbot === undefined) {
517
- await this.BLERefreshConnection(switchbot);
518
- }
519
- else {
520
- // Start to monitor advertisement packets
521
- (async () => {
522
- // Start to monitor advertisement packets
523
- const serviceData = await this.monitorAdvertisementPackets(switchbot);
524
- // Update HomeKit
525
- if (serviceData.model === SwitchBotBLEModel.Bot && serviceData.modelName === SwitchBotBLEModelName.Bot) {
526
- this.serviceData = serviceData;
527
- await this.BLEparseStatus();
528
- await this.updateHomeKitCharacteristics();
529
- }
530
- else {
531
- await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`);
532
- await this.BLERefreshConnection(switchbot);
533
- }
534
- })();
535
- }
515
+ await this.debugLog('is not listening to Platform BLE');
536
516
  }
537
517
  }
538
518
  async openAPIRefreshStatus() {
@@ -541,7 +521,6 @@ export class Bot extends deviceBase {
541
521
  const { body, statusCode } = await this.deviceRefreshStatus();
542
522
  const deviceStatus = await body.json();
543
523
  await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
544
- ;
545
524
  if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
546
525
  await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
547
526
  this.deviceStatus = deviceStatus.body;
@@ -579,10 +558,10 @@ export class Bot extends deviceBase {
579
558
  }
580
559
  /**
581
560
  * Pushes the requested changes to the SwitchBot API
582
- * deviceType commandType Command command parameter Description
583
- * Bot - "command" "turnOff" "default" = set to OFF state
584
- * Bot - "command" "turnOn" "default" = set to ON state
585
- * Bot - "command" "press" "default" = trigger press
561
+ * deviceType commandType Command command parameter Description
562
+ * Bot "command" "turnOff" "default" = set to OFF state
563
+ * Bot "command" "turnOn" "default" = set to ON state
564
+ * Bot "command" "press" "default" = trigger press
586
565
  */
587
566
  async pushChanges() {
588
567
  if (!this.device.enableCloudService && this.OpenAPI) {
@@ -612,7 +591,7 @@ export class Bot extends deviceBase {
612
591
  await this.debugLog(`BLEpushChanges On: ${this.On} OnCached: ${this.accessory.context.On}`);
613
592
  const switchbot = await this.platform.connectBLE(this.accessory, this.device);
614
593
  await this.convertBLEAddress();
615
- //if (switchbot !== false) {
594
+ // if (switchbot !== false) {
616
595
  await this.debugLog(`Bot Mode: ${this.botMode}`);
617
596
  if (this.botMode === 'press') {
618
597
  switchbot
@@ -730,66 +709,76 @@ export class Bot extends deviceBase {
730
709
  * Handle requests to set the "On" characteristic
731
710
  */
732
711
  async OnSet(value) {
733
- if (this.botDeviceType === 'switch') {
734
- if (this.Switch) {
735
- await this.debugLog(`Set On: ${value}`);
736
- this.On = value === false ? false : true;
737
- }
738
- }
739
- else if (this.botDeviceType === 'garagedoor') {
740
- if (this.GarageDoor) {
741
- await this.debugLog(`Set TargetDoorState: ${value}`);
742
- this.On = value === this.hap.Characteristic.TargetDoorState.CLOSED ? false : true;
743
- }
744
- }
745
- else if (this.botDeviceType === 'door') {
746
- if (this.Door) {
747
- await this.debugLog(`Set TargetPosition: ${value}`);
748
- this.On = value === 0 ? false : true;
749
- }
750
- }
751
- else if (this.botDeviceType === 'window') {
752
- if (this.Window) {
753
- await this.debugLog(`Set TargetPosition: ${value}`);
754
- this.On = value === 0 ? false : true;
755
- }
756
- }
757
- else if (this.botDeviceType === 'windowcovering') {
758
- if (this.WindowCovering) {
759
- await this.debugLog(`Set TargetPosition: ${value}`);
760
- this.On = value === 0 ? false : true;
761
- }
762
- }
763
- else if (this.botDeviceType === 'lock') {
764
- if (this.LockMechanism) {
765
- await this.debugLog(`Set LockTargetState: ${value}`);
766
- this.On = value === this.hap.Characteristic.LockTargetState.SECURED ? false : true;
767
- }
768
- }
769
- else if (this.botDeviceType === 'faucet') {
770
- if (this.Faucet) {
771
- await this.debugLog(`Set Active: ${value}`);
772
- this.On = value === this.hap.Characteristic.Active.INACTIVE ? false : true;
773
- }
774
- }
775
- else if (this.botDeviceType === 'stateful') {
776
- if (this.StatefulProgrammableSwitch) {
777
- await this.debugLog(`Set ProgrammableSwitchOutputState: ${value}`);
778
- this.On = value === 0 ? false : true;
779
- }
712
+ if (this.On === undefined) {
713
+ this.On = false;
714
+ this.accessory.context.On = this.On;
780
715
  }
781
716
  else {
782
- if (this.Outlet) {
783
- await this.debugLog(`Set On: ${value}`);
784
- this.On = value === false ? false : true;
785
- }
786
- }
787
- if (this.device.bot?.mode === 'multipress') {
788
- if (this.On === true) {
789
- this.multiPressCount++;
790
- await this.debugLog(`multiPressCount: ${this.multiPressCount}`);
791
- }
717
+ this.On = this.accessory.context.On;
792
718
  }
719
+ const deviceTypeActions = {
720
+ switch: async () => {
721
+ if (this.Switch) {
722
+ await this.debugLog(`Set On: ${value}`);
723
+ this.On = value !== false;
724
+ }
725
+ },
726
+ garagedoor: async () => {
727
+ if (this.GarageDoor) {
728
+ await this.debugLog(`Set TargetDoorState: ${value}`);
729
+ this.On = value !== this.hap.Characteristic.TargetDoorState.CLOSED;
730
+ }
731
+ },
732
+ door: async () => {
733
+ if (this.Door) {
734
+ await this.debugLog(`Set TargetPosition: ${value}`);
735
+ this.On = value !== 0;
736
+ }
737
+ },
738
+ window: async () => {
739
+ if (this.Window) {
740
+ await this.debugLog(`Set TargetPosition: ${value}`);
741
+ this.On = value !== 0;
742
+ }
743
+ },
744
+ windowcovering: async () => {
745
+ if (this.WindowCovering) {
746
+ await this.debugLog(`Set TargetPosition: ${value}`);
747
+ this.On = value !== 0;
748
+ }
749
+ },
750
+ lock: async () => {
751
+ if (this.LockMechanism) {
752
+ await this.debugLog(`Set LockTargetState: ${value}`);
753
+ this.On = value !== this.hap.Characteristic.LockTargetState.SECURED;
754
+ }
755
+ },
756
+ faucet: async () => {
757
+ if (this.Faucet) {
758
+ await this.debugLog(`Set Active: ${value}`);
759
+ this.On = value !== this.hap.Characteristic.Active.INACTIVE;
760
+ }
761
+ },
762
+ stateful: async () => {
763
+ if (this.StatefulProgrammableSwitch) {
764
+ await this.debugLog(`Set ProgrammableSwitchOutputState: ${value}`);
765
+ this.On = value !== 0;
766
+ }
767
+ },
768
+ default: async () => {
769
+ if (this.Outlet) {
770
+ await this.debugLog(`Set On: ${value}`);
771
+ this.On = value !== false;
772
+ }
773
+ if (this.device.bot?.mode === 'multipress' && this.On) {
774
+ this.multiPressCount++;
775
+ await this.debugLog(`multiPressCount: ${this.multiPressCount}`);
776
+ }
777
+ },
778
+ };
779
+ const action = deviceTypeActions[this.botDeviceType] || deviceTypeActions.default;
780
+ await action();
781
+ this.accessory.context.On = this.On;
793
782
  this.doBotUpdate.next();
794
783
  }
795
784
  /**
@@ -992,7 +981,7 @@ export class Bot extends deviceBase {
992
981
  Service: accessory.getService(this.hap.Service.Outlet),
993
982
  };
994
983
  accessory.context.Outlet = this.Outlet;
995
- await this.warnLog('Removing any leftover Outlet Service');
984
+ await this.debugWarnLog('Removing any leftover Outlet Service');
996
985
  accessory.removeService(this.Outlet.Service);
997
986
  }
998
987
  async removeGarageDoorService(accessory) {
@@ -1003,7 +992,7 @@ export class Bot extends deviceBase {
1003
992
  Service: accessory.getService(this.hap.Service.GarageDoorOpener),
1004
993
  };
1005
994
  accessory.context.GarageDoor = this.GarageDoor;
1006
- await this.warnLog('Removing any leftover Garage Door Service');
995
+ await this.debugWarnLog('Removing any leftover Garage Door Service');
1007
996
  accessory.removeService(this.GarageDoor.Service);
1008
997
  }
1009
998
  async removeDoorService(accessory) {
@@ -1014,7 +1003,7 @@ export class Bot extends deviceBase {
1014
1003
  Service: accessory.getService(this.hap.Service.Door),
1015
1004
  };
1016
1005
  accessory.context.Door = this.Door;
1017
- await this.warnLog('Removing any leftover Door Service');
1006
+ await this.debugWarnLog('Removing any leftover Door Service');
1018
1007
  accessory.removeService(this.Door.Service);
1019
1008
  }
1020
1009
  async removeLockService(accessory) {
@@ -1025,7 +1014,7 @@ export class Bot extends deviceBase {
1025
1014
  Service: accessory.getService(this.hap.Service.LockMechanism),
1026
1015
  };
1027
1016
  accessory.context.LockMechanism = this.LockMechanism;
1028
- this.warnLog('Removing any leftover Lock Service');
1017
+ await this.debugWarnLog('Removing any leftover Lock Service');
1029
1018
  accessory.removeService(this.LockMechanism.Service);
1030
1019
  }
1031
1020
  async removeFaucetService(accessory) {
@@ -1036,7 +1025,7 @@ export class Bot extends deviceBase {
1036
1025
  Service: accessory.getService(this.hap.Service.Valve),
1037
1026
  };
1038
1027
  accessory.context.Faucet = this.Faucet;
1039
- await this.warnLog('Removing any leftover Faucet Service');
1028
+ await this.debugWarnLog('Removing any leftover Faucet Service');
1040
1029
  accessory.removeService(this.Faucet.Service);
1041
1030
  }
1042
1031
  async removeFanService(accessory) {
@@ -1047,7 +1036,7 @@ export class Bot extends deviceBase {
1047
1036
  Service: accessory.getService(this.hap.Service.Fan),
1048
1037
  };
1049
1038
  accessory.context.Fan = this.Fan;
1050
- this.warnLog('Removing any leftover Fan Service');
1039
+ await this.debugWarnLog('Removing any leftover Fan Service');
1051
1040
  accessory.removeService(this.Fan.Service);
1052
1041
  }
1053
1042
  async removeWindowService(accessory) {
@@ -1058,7 +1047,7 @@ export class Bot extends deviceBase {
1058
1047
  Service: accessory.getService(this.hap.Service.Window),
1059
1048
  };
1060
1049
  accessory.context.Window = this.Window;
1061
- await this.warnLog('Removing any leftover Window Service');
1050
+ await this.debugWarnLog('Removing any leftover Window Service');
1062
1051
  accessory.removeService(this.Window.Service);
1063
1052
  }
1064
1053
  async removeWindowCoveringService(accessory) {
@@ -1069,7 +1058,7 @@ export class Bot extends deviceBase {
1069
1058
  Service: accessory.getService(this.hap.Service.WindowCovering),
1070
1059
  };
1071
1060
  accessory.context.WindowCovering = this.WindowCovering;
1072
- await this.warnLog('Removing any leftover Window Covering Service');
1061
+ await this.debugWarnLog('Removing any leftover Window Covering Service');
1073
1062
  accessory.removeService(this.WindowCovering.Service);
1074
1063
  }
1075
1064
  async removeStatefulProgrammableSwitchService(accessory) {
@@ -1080,7 +1069,7 @@ export class Bot extends deviceBase {
1080
1069
  Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch),
1081
1070
  };
1082
1071
  accessory.context.StatefulProgrammableSwitch = this.StatefulProgrammableSwitch;
1083
- await this.warnLog('Removing any leftover Stateful Programmable Switch Service');
1072
+ await this.debugWarnLog('Removing any leftover Stateful Programmable Switch Service');
1084
1073
  accessory.removeService(this.StatefulProgrammableSwitch.Service);
1085
1074
  }
1086
1075
  async removeSwitchService(accessory) {
@@ -1091,42 +1080,52 @@ export class Bot extends deviceBase {
1091
1080
  Service: accessory.getService(this.hap.Service.Switch),
1092
1081
  };
1093
1082
  accessory.context.Switch = this.Switch;
1094
- await this.warnLog('Removing any leftover Switch Service');
1083
+ await this.debugWarnLog('Removing any leftover Switch Service');
1095
1084
  accessory.removeService(this.Switch.Service);
1096
1085
  }
1097
1086
  async getBotConfigSettings(device) {
1098
- //Bot Device Type
1099
- this.botDeviceType = this.accessory.context.botDeviceType === device.bot?.deviceType ? this.accessory.context.botDeviceType
1087
+ // Bot Device Type
1088
+ this.botDeviceType = this.accessory.context.botDeviceType === device.bot?.deviceType
1089
+ ? this.accessory.context.botDeviceType
1100
1090
  : device.bot?.deviceType ?? 'outlet';
1101
- const botDeviceType = this.accessory.context.botDeviceType ? `Using Device Type: ${this.botDeviceType}, from Accessory Cache.`
1102
- : device.bot?.deviceType ? `Using Device Type: ${this.botDeviceType}`
1091
+ const botDeviceType = this.accessory.context.botDeviceType
1092
+ ? `Using Device Type: ${this.botDeviceType}, from Accessory Cache.`
1093
+ : device.bot?.deviceType
1094
+ ? `Using Device Type: ${this.botDeviceType}`
1103
1095
  : `No Device Type Set, deviceType: ${this.device.bot?.deviceType}, Using default deviceType: ${this.botDeviceType}`;
1104
1096
  await this.debugWarnLog(botDeviceType);
1105
1097
  this.accessory.context.botDeviceType = this.botDeviceType;
1106
1098
  // Bot Mode
1107
1099
  this.botMode = this.accessory.context.botMode ?? device.bot?.mode ?? 'switch';
1108
- const botMode = this.accessory.context.botMode ? `Using Bot Mode: ${this.botMode}, from Accessory Cache.`
1100
+ const botMode = this.accessory.context.botMode
1101
+ ? `Using Bot Mode: ${this.botMode}, from Accessory Cache.`
1109
1102
  : device.bot?.mode ? `Using Bot Mode: ${this.botMode}` : `No Bot Mode Set, Using default Bot Mode: ${this.botMode}`;
1110
1103
  await this.debugWarnLog(botMode);
1111
1104
  this.accessory.context.botMode = this.botMode;
1112
1105
  // Bot Double Press
1113
1106
  this.doublePress = this.accessory.context.doublePress ?? device.bot?.doublePress ?? 1;
1114
- const doublePress = this.accessory.context.doublePress ? `Using Double Press: ${this.doublePress}, from Accessory Cache.`
1115
- : device.bot?.doublePress ? `Using Double Press: ${this.doublePress}`
1107
+ const doublePress = this.accessory.context.doublePress
1108
+ ? `Using Double Press: ${this.doublePress}, from Accessory Cache.`
1109
+ : device.bot?.doublePress
1110
+ ? `Using Double Press: ${this.doublePress}`
1116
1111
  : `No Double Press Set, Using default Double Press: ${this.doublePress}`;
1117
1112
  await this.debugWarnLog(doublePress);
1118
1113
  this.accessory.context.doublePress = this.doublePress;
1119
1114
  // Bot Press PushRate
1120
1115
  this.pushRatePress = this.accessory.context.pushRatePress ?? device.bot?.pushRatePress ?? 15;
1121
- const pushRatePress = this.accessory.context.pushRatePress ? `Using Push Rate Press: ${this.pushRatePress}, from Accessory Cache.`
1122
- : device.bot?.pushRatePress ? `Using Bot Push Rate Press: ${this.pushRatePress}`
1116
+ const pushRatePress = this.accessory.context.pushRatePress
1117
+ ? `Using Push Rate Press: ${this.pushRatePress}, from Accessory Cache.`
1118
+ : device.bot?.pushRatePress
1119
+ ? `Using Bot Push Rate Press: ${this.pushRatePress}`
1123
1120
  : `No Push Rate Press Set, Using default Push Rate Press: ${this.pushRatePress}`;
1124
1121
  await this.debugWarnLog(pushRatePress);
1125
1122
  this.accessory.context.pushRatePress = this.pushRatePress;
1126
1123
  // Bot Allow Push
1127
1124
  this.allowPush = this.accessory.context.allowPush ?? device.bot?.allowPush ?? false;
1128
- const allowPush = this.accessory.context.allowPush ? `Using Allow Push: ${this.allowPush}, from Accessory Cache.`
1129
- : device.bot?.allowPush ? `Using Allow Push: ${this.allowPush}`
1125
+ const allowPush = this.accessory.context.allowPush
1126
+ ? `Using Allow Push: ${this.allowPush}, from Accessory Cache.`
1127
+ : device.bot?.allowPush
1128
+ ? `Using Allow Push: ${this.allowPush}`
1130
1129
  : `No Allow Push Set, Using default Allow Push: ${this.allowPush}`;
1131
1130
  await this.debugWarnLog(allowPush);
1132
1131
  this.accessory.context.allowPush = this.allowPush;