@switchbot/homebridge-switchbot 3.5.1-beta.9 → 3.5.1

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 (159) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/config.schema.json +19 -3
  3. package/dist/device/blindtilt.d.ts +6 -4
  4. package/dist/device/blindtilt.d.ts.map +1 -1
  5. package/dist/device/blindtilt.js +60 -46
  6. package/dist/device/blindtilt.js.map +1 -1
  7. package/dist/device/bot.d.ts +6 -3
  8. package/dist/device/bot.d.ts.map +1 -1
  9. package/dist/device/bot.js +59 -25
  10. package/dist/device/bot.js.map +1 -1
  11. package/dist/device/ceilinglight.d.ts +6 -3
  12. package/dist/device/ceilinglight.d.ts.map +1 -1
  13. package/dist/device/ceilinglight.js +47 -29
  14. package/dist/device/ceilinglight.js.map +1 -1
  15. package/dist/device/colorbulb.d.ts +6 -3
  16. package/dist/device/colorbulb.d.ts.map +1 -1
  17. package/dist/device/colorbulb.js +53 -36
  18. package/dist/device/colorbulb.js.map +1 -1
  19. package/dist/device/contact.d.ts +6 -3
  20. package/dist/device/contact.d.ts.map +1 -1
  21. package/dist/device/contact.js +45 -31
  22. package/dist/device/contact.js.map +1 -1
  23. package/dist/device/curtain.d.ts +6 -4
  24. package/dist/device/curtain.d.ts.map +1 -1
  25. package/dist/device/curtain.js +41 -27
  26. package/dist/device/curtain.js.map +1 -1
  27. package/dist/device/device.d.ts +6 -3
  28. package/dist/device/device.d.ts.map +1 -1
  29. package/dist/device/device.js +59 -152
  30. package/dist/device/device.js.map +1 -1
  31. package/dist/device/fan.d.ts +6 -3
  32. package/dist/device/fan.d.ts.map +1 -1
  33. package/dist/device/fan.js +53 -32
  34. package/dist/device/fan.js.map +1 -1
  35. package/dist/device/hub.d.ts +6 -3
  36. package/dist/device/hub.d.ts.map +1 -1
  37. package/dist/device/hub.js +49 -30
  38. package/dist/device/hub.js.map +1 -1
  39. package/dist/device/humidifier.d.ts +6 -3
  40. package/dist/device/humidifier.d.ts.map +1 -1
  41. package/dist/device/humidifier.js +47 -28
  42. package/dist/device/humidifier.js.map +1 -1
  43. package/dist/device/iosensor.d.ts +6 -3
  44. package/dist/device/iosensor.d.ts.map +1 -1
  45. package/dist/device/iosensor.js +44 -27
  46. package/dist/device/iosensor.js.map +1 -1
  47. package/dist/device/lightstrip.d.ts +6 -3
  48. package/dist/device/lightstrip.d.ts.map +1 -1
  49. package/dist/device/lightstrip.js +46 -28
  50. package/dist/device/lightstrip.js.map +1 -1
  51. package/dist/device/lock.d.ts +6 -3
  52. package/dist/device/lock.d.ts.map +1 -1
  53. package/dist/device/lock.js +38 -25
  54. package/dist/device/lock.js.map +1 -1
  55. package/dist/device/meter.d.ts +6 -3
  56. package/dist/device/meter.d.ts.map +1 -1
  57. package/dist/device/meter.js +43 -27
  58. package/dist/device/meter.js.map +1 -1
  59. package/dist/device/meterplus.d.ts +6 -3
  60. package/dist/device/meterplus.d.ts.map +1 -1
  61. package/dist/device/meterplus.js +42 -27
  62. package/dist/device/meterplus.js.map +1 -1
  63. package/dist/device/motion.d.ts +6 -3
  64. package/dist/device/motion.d.ts.map +1 -1
  65. package/dist/device/motion.js +37 -24
  66. package/dist/device/motion.js.map +1 -1
  67. package/dist/device/plug.d.ts +6 -3
  68. package/dist/device/plug.d.ts.map +1 -1
  69. package/dist/device/plug.js +30 -17
  70. package/dist/device/plug.js.map +1 -1
  71. package/dist/device/robotvacuumcleaner.d.ts +6 -3
  72. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  73. package/dist/device/robotvacuumcleaner.js +37 -22
  74. package/dist/device/robotvacuumcleaner.js.map +1 -1
  75. package/dist/device/waterdetector.d.ts +6 -3
  76. package/dist/device/waterdetector.d.ts.map +1 -1
  77. package/dist/device/waterdetector.js +43 -26
  78. package/dist/device/waterdetector.js.map +1 -1
  79. package/dist/homebridge-ui/public/index.html +2 -2
  80. package/dist/irdevice/airconditioner.d.ts +1 -3
  81. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  82. package/dist/irdevice/airconditioner.js +67 -177
  83. package/dist/irdevice/airconditioner.js.map +1 -1
  84. package/dist/irdevice/airpurifier.d.ts +0 -1
  85. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  86. package/dist/irdevice/airpurifier.js +24 -53
  87. package/dist/irdevice/airpurifier.js.map +1 -1
  88. package/dist/irdevice/camera.d.ts.map +1 -1
  89. package/dist/irdevice/camera.js +12 -17
  90. package/dist/irdevice/camera.js.map +1 -1
  91. package/dist/irdevice/fan.d.ts.map +1 -1
  92. package/dist/irdevice/fan.js +22 -38
  93. package/dist/irdevice/fan.js.map +1 -1
  94. package/dist/irdevice/irdevice.d.ts +22 -10
  95. package/dist/irdevice/irdevice.d.ts.map +1 -1
  96. package/dist/irdevice/irdevice.js +94 -100
  97. package/dist/irdevice/irdevice.js.map +1 -1
  98. package/dist/irdevice/light.d.ts.map +1 -1
  99. package/dist/irdevice/light.js +20 -38
  100. package/dist/irdevice/light.js.map +1 -1
  101. package/dist/irdevice/other.d.ts.map +1 -1
  102. package/dist/irdevice/other.js +79 -77
  103. package/dist/irdevice/other.js.map +1 -1
  104. package/dist/irdevice/tv.d.ts.map +1 -1
  105. package/dist/irdevice/tv.js +38 -53
  106. package/dist/irdevice/tv.js.map +1 -1
  107. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  108. package/dist/irdevice/vacuumcleaner.js +11 -16
  109. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  110. package/dist/irdevice/waterheater.d.ts.map +1 -1
  111. package/dist/irdevice/waterheater.js +11 -16
  112. package/dist/irdevice/waterheater.js.map +1 -1
  113. package/dist/platform.d.ts +4 -6
  114. package/dist/platform.d.ts.map +1 -1
  115. package/dist/platform.js +564 -665
  116. package/dist/platform.js.map +1 -1
  117. package/dist/settings.d.ts +10 -8
  118. package/dist/settings.d.ts.map +1 -1
  119. package/dist/settings.js.map +1 -1
  120. package/dist/types/bledevicestatus.d.ts +2 -1
  121. package/dist/types/bledevicestatus.d.ts.map +1 -1
  122. package/dist/types/devicestatus.d.ts +1 -1
  123. package/dist/types/devicestatus.d.ts.map +1 -1
  124. package/package.json +11 -11
  125. package/src/device/blindtilt.ts +64 -48
  126. package/src/device/bot.ts +79 -26
  127. package/src/device/ceilinglight.ts +57 -31
  128. package/src/device/colorbulb.ts +57 -43
  129. package/src/device/contact.ts +49 -31
  130. package/src/device/curtain.ts +51 -28
  131. package/src/device/device.ts +61 -135
  132. package/src/device/fan.ts +67 -33
  133. package/src/device/hub.ts +62 -33
  134. package/src/device/humidifier.ts +60 -33
  135. package/src/device/iosensor.ts +51 -30
  136. package/src/device/lightstrip.ts +52 -29
  137. package/src/device/lock.ts +55 -26
  138. package/src/device/meter.ts +60 -29
  139. package/src/device/meterplus.ts +56 -29
  140. package/src/device/motion.ts +50 -26
  141. package/src/device/plug.ts +38 -18
  142. package/src/device/robotvacuumcleaner.ts +53 -24
  143. package/src/device/waterdetector.ts +62 -28
  144. package/src/homebridge-ui/public/index.html +2 -2
  145. package/src/irdevice/airconditioner.ts +76 -165
  146. package/src/irdevice/airpurifier.ts +29 -49
  147. package/src/irdevice/camera.ts +13 -16
  148. package/src/irdevice/fan.ts +25 -35
  149. package/src/irdevice/irdevice.ts +97 -96
  150. package/src/irdevice/light.ts +21 -35
  151. package/src/irdevice/other.ts +79 -77
  152. package/src/irdevice/tv.ts +40 -51
  153. package/src/irdevice/vacuumcleaner.ts +12 -15
  154. package/src/irdevice/waterheater.ts +12 -15
  155. package/src/platform.ts +566 -696
  156. package/src/settings.ts +11 -8
  157. package/src/types/bledevicestatus.ts +4 -2
  158. package/src/types/devicestatus.ts +1 -1
  159. package/.github/npm-version-script.cjs +0 -81
@@ -59,20 +59,20 @@ export class TV extends irdeviceBase {
59
59
  switch (device.remoteType) {
60
60
  case 'Speaker':
61
61
  case 'DIY Speaker':
62
- accessory.category = this.platform.api.hap.Categories.SPEAKER;
62
+ accessory.category = this.hap.Categories.SPEAKER;
63
63
  break;
64
64
  case 'IPTV':
65
65
  case 'DIY IPTV':
66
- accessory.category = this.platform.api.hap.Categories.TV_STREAMING_STICK;
66
+ accessory.category = this.hap.Categories.TV_STREAMING_STICK;
67
67
  break;
68
68
  case 'DVD':
69
69
  case 'DIY DVD':
70
70
  case 'Set Top Box':
71
71
  case 'DIY Set Top Box':
72
- accessory.category = this.platform.api.hap.Categories.TV_SET_TOP_BOX;
72
+ accessory.category = this.hap.Categories.TV_SET_TOP_BOX;
73
73
  break;
74
74
  default:
75
- accessory.category = this.platform.api.hap.Categories.TELEVISION;
75
+ accessory.category = this.hap.Categories.TELEVISION;
76
76
  }
77
77
 
78
78
  this.Television.Service
@@ -125,7 +125,7 @@ export class TV extends irdeviceBase {
125
125
  }
126
126
 
127
127
  async VolumeSelectorSet(value: CharacteristicValue): Promise<void> {
128
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} VolumeSelector: ${value}`);
128
+ await this.debugLog(`VolumeSelector: ${value}`);
129
129
  if (value === this.hap.Characteristic.VolumeSelector.INCREMENT) {
130
130
  this.pushVolumeUpChanges();
131
131
  } else {
@@ -136,61 +136,61 @@ export class TV extends irdeviceBase {
136
136
  async RemoteKeySet(value: CharacteristicValue): Promise<void> {
137
137
  switch (value) {
138
138
  case this.hap.Characteristic.RemoteKey.REWIND: {
139
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: REWIND`);
139
+ await this.debugLog('Set Remote Key Pressed: REWIND');
140
140
  break;
141
141
  }
142
142
  case this.hap.Characteristic.RemoteKey.FAST_FORWARD: {
143
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: FAST_FORWARD`);
143
+ await this.debugLog('Set Remote Key Pressed: FAST_FORWARD');
144
144
  break;
145
145
  }
146
146
  case this.hap.Characteristic.RemoteKey.NEXT_TRACK: {
147
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: NEXT_TRACK`);
147
+ await this.debugLog('Set Remote Key Pressed: NEXT_TRACK');
148
148
  break;
149
149
  }
150
150
  case this.hap.Characteristic.RemoteKey.PREVIOUS_TRACK: {
151
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: PREVIOUS_TRACK`);
151
+ await this.debugLog('Set Remote Key Pressed: PREVIOUS_TRACK');
152
152
  break;
153
153
  }
154
154
  case this.hap.Characteristic.RemoteKey.ARROW_UP: {
155
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: ARROW_UP`);
155
+ await this.debugLog('Set Remote Key Pressed: ARROW_UP');
156
156
  //this.pushUpChanges();
157
157
  break;
158
158
  }
159
159
  case this.hap.Characteristic.RemoteKey.ARROW_DOWN: {
160
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: ARROW_DOWN`);
160
+ await this.debugLog('Set Remote Key Pressed: ARROW_DOWN');
161
161
  //this.pushDownChanges();
162
162
  break;
163
163
  }
164
164
  case this.hap.Characteristic.RemoteKey.ARROW_LEFT: {
165
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: ARROW_LEFT`);
165
+ await this.debugLog('Set Remote Key Pressed: ARROW_LEFT');
166
166
  //this.pushLeftChanges();
167
167
  break;
168
168
  }
169
169
  case this.hap.Characteristic.RemoteKey.ARROW_RIGHT: {
170
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: ARROW_RIGHT`);
170
+ await this.debugLog('Set Remote Key Pressed: ARROW_RIGHT');
171
171
  //this.pushRightChanges();
172
172
  break;
173
173
  }
174
174
  case this.hap.Characteristic.RemoteKey.SELECT: {
175
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: SELECT`);
175
+ await this.debugLog('Set Remote Key Pressed: SELECT');
176
176
  //this.pushOkChanges();
177
177
  break;
178
178
  }
179
179
  case this.hap.Characteristic.RemoteKey.BACK: {
180
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: BACK`);
180
+ await this.debugLog('Set Remote Key Pressed: BACK');
181
181
  //this.pushBackChanges();
182
182
  break;
183
183
  }
184
184
  case this.hap.Characteristic.RemoteKey.EXIT: {
185
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: EXIT`);
185
+ await this.debugLog('Set Remote Key Pressed: EXIT');
186
186
  break;
187
187
  }
188
188
  case this.hap.Characteristic.RemoteKey.PLAY_PAUSE: {
189
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: PLAY_PAUSE`);
189
+ await this.debugLog('Set Remote Key Pressed: PLAY_PAUSE');
190
190
  break;
191
191
  }
192
192
  case this.hap.Characteristic.RemoteKey.INFORMATION: {
193
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Remote Key Pressed: INFORMATION`);
193
+ await this.debugLog('Set Remote Key Pressed: INFORMATION');
194
194
  //this.pushMenuChanges();
195
195
  break;
196
196
  }
@@ -198,12 +198,12 @@ export class TV extends irdeviceBase {
198
198
  }
199
199
 
200
200
  async ActiveIdentifierSet(value: CharacteristicValue): Promise<void> {
201
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ActiveIdentifier: ${value}`);
201
+ await this.debugLog(`ActiveIdentifier: ${value}`);
202
202
  this.Television.ActiveIdentifier = value;
203
203
  }
204
204
 
205
205
  async ActiveSet(value: CharacteristicValue): Promise<void> {
206
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active (value): ${value}`);
206
+ await this.debugLog(`Active (value): ${value}`);
207
207
 
208
208
  this.Television.Active = value;
209
209
  if (this.Television.Active === this.hap.Characteristic.Active.ACTIVE) {
@@ -224,7 +224,7 @@ export class TV extends irdeviceBase {
224
224
  * TV "command" "channelSub" "default" previous channel
225
225
  */
226
226
  async pushTvOnChanges(): Promise<void> {
227
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushTvOnChanges`
227
+ await this.debugLog('pushTvOnChanges'
228
228
  + ` Active: ${this.Television.Active}, disablePushOn: ${this.disablePushOn}`);
229
229
  if (this.Television.Active === this.hap.Characteristic.Active.ACTIVE && !this.disablePushOn) {
230
230
  const commandType: string = await this.commandType();
@@ -239,7 +239,7 @@ export class TV extends irdeviceBase {
239
239
  }
240
240
 
241
241
  async pushTvOffChanges(): Promise<void> {
242
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushTvOffChanges`
242
+ await this.debugLog('pushTvOffChanges'
243
243
  + ` Active: ${this.Television.Active}, disablePushOff: ${this.disablePushOff}`);
244
244
  if (this.Television.Active === this.hap.Characteristic.Active.INACTIVE && !this.disablePushOff) {
245
245
  const commandType: string = await this.commandType();
@@ -254,7 +254,7 @@ export class TV extends irdeviceBase {
254
254
  }
255
255
 
256
256
  async pushOkChanges(): Promise<void> {
257
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOkChanges disablePushDetail: ${this.disablePushDetail}`);
257
+ await this.debugLog(`pushOkChanges disablePushDetail: ${this.disablePushDetail}`);
258
258
  if (!this.disablePushDetail) {
259
259
  const bodyChange = JSON.stringify({
260
260
  command: 'Ok',
@@ -266,7 +266,7 @@ export class TV extends irdeviceBase {
266
266
  }
267
267
 
268
268
  async pushBackChanges(): Promise<void> {
269
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushBackChanges disablePushDetail: ${this.disablePushDetail}`);
269
+ await this.debugLog(`pushBackChanges disablePushDetail: ${this.disablePushDetail}`);
270
270
  if (!this.disablePushDetail) {
271
271
  const bodyChange = JSON.stringify({
272
272
  command: 'Back',
@@ -278,7 +278,7 @@ export class TV extends irdeviceBase {
278
278
  }
279
279
 
280
280
  async pushMenuChanges(): Promise<void> {
281
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushMenuChanges disablePushDetail: ${this.disablePushDetail}`);
281
+ await this.debugLog(`pushMenuChanges disablePushDetail: ${this.disablePushDetail}`);
282
282
  if (!this.disablePushDetail) {
283
283
  const bodyChange = JSON.stringify({
284
284
  command: 'Menu',
@@ -290,7 +290,7 @@ export class TV extends irdeviceBase {
290
290
  }
291
291
 
292
292
  async pushUpChanges(): Promise<void> {
293
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushUpChanges disablePushDetail: ${this.disablePushDetail}`);
293
+ await this.debugLog(`pushUpChanges disablePushDetail: ${this.disablePushDetail}`);
294
294
  if (!this.disablePushDetail) {
295
295
  const bodyChange = JSON.stringify({
296
296
  command: 'Up',
@@ -302,7 +302,7 @@ export class TV extends irdeviceBase {
302
302
  }
303
303
 
304
304
  async pushDownChanges(): Promise<void> {
305
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushDownChanges disablePushDetail: ${this.disablePushDetail}`);
305
+ await this.debugLog(`pushDownChanges disablePushDetail: ${this.disablePushDetail}`);
306
306
  if (!this.disablePushDetail) {
307
307
  const bodyChange = JSON.stringify({
308
308
  command: 'Down',
@@ -314,7 +314,7 @@ export class TV extends irdeviceBase {
314
314
  }
315
315
 
316
316
  async pushRightChanges(): Promise<void> {
317
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushRightChanges disablePushDetail: ${this.disablePushDetail}`);
317
+ await this.debugLog(`pushRightChanges disablePushDetail: ${this.disablePushDetail}`);
318
318
  if (!this.disablePushDetail) {
319
319
  const bodyChange = JSON.stringify({
320
320
  command: 'Right',
@@ -326,7 +326,7 @@ export class TV extends irdeviceBase {
326
326
  }
327
327
 
328
328
  async pushLeftChanges(): Promise<void> {
329
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushLeftChanges disablePushDetail: ${this.disablePushDetail}`);
329
+ await this.debugLog(`pushLeftChanges disablePushDetail: ${this.disablePushDetail}`);
330
330
  if (!this.disablePushDetail) {
331
331
  const bodyChange = JSON.stringify({
332
332
  command: 'Left',
@@ -338,7 +338,7 @@ export class TV extends irdeviceBase {
338
338
  }
339
339
 
340
340
  async pushVolumeUpChanges(): Promise<void> {
341
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushVolumeUpChanges disablePushDetail: ${this.disablePushDetail}`);
341
+ await this.debugLog(`pushVolumeUpChanges disablePushDetail: ${this.disablePushDetail}`);
342
342
  if (!this.disablePushDetail) {
343
343
  const bodyChange = JSON.stringify({
344
344
  command: 'volumeAdd',
@@ -350,7 +350,7 @@ export class TV extends irdeviceBase {
350
350
  }
351
351
 
352
352
  async pushVolumeDownChanges(): Promise<void> {
353
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushVolumeDownChanges disablePushDetail: ${this.disablePushDetail}`);
353
+ await this.debugLog(`pushVolumeDownChanges disablePushDetail: ${this.disablePushDetail}`);
354
354
  if (!this.disablePushDetail) {
355
355
  const bodyChange = JSON.stringify({
356
356
  command: 'volumeSub',
@@ -362,14 +362,14 @@ export class TV extends irdeviceBase {
362
362
  }
363
363
 
364
364
  async pushTVChanges(bodyChange: any): Promise<void> {
365
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushTVChanges`);
365
+ await this.debugLog('pushTVChanges');
366
366
  if (this.device.connectionType === 'OpenAPI') {
367
- this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
367
+ await this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`);
368
368
  try {
369
369
  const { body, statusCode } = await this.pushChangeRequest(bodyChange);
370
370
  const deviceStatus: any = await body.json();
371
371
  await this.pushStatusCodes(statusCode, deviceStatus);
372
- if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
372
+ if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
373
373
  await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
374
374
  await this.updateHomeKitCharacteristics();
375
375
  } else {
@@ -381,29 +381,18 @@ export class TV extends irdeviceBase {
381
381
  await this.pushChangeError(e);
382
382
  }
383
383
  } else {
384
- this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
385
- + ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
384
+ await this.warnLog(`Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
386
385
  }
387
386
  }
388
387
 
389
388
  async updateHomeKitCharacteristics(): Promise<void> {
389
+ await this.debugLog('updateHomeKitCharacteristics');
390
390
  // Active
391
- if (this.Television.Active === undefined) {
392
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Television.Active}`);
393
- } else {
394
- this.accessory.context.Active = this.Television.Active;
395
- this.Television.Service.updateCharacteristic(this.hap.Characteristic.Active, this.Television.Active);
396
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Television.Active}`);
397
- }
391
+ await this.updateCharacteristic(this.Television.Service, this.hap.Characteristic.Active,
392
+ this.Television.Active, 'Active');
398
393
  // ActiveIdentifier
399
- if (this.Television.ActiveIdentifier === undefined) {
400
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ActiveIdentifier: ${this.Television.ActiveIdentifier}`);
401
- } else {
402
- this.accessory.context.ActiveIdentifier = this.Television.ActiveIdentifier;
403
- this.Television.Service.updateCharacteristic(this.hap.Characteristic.ActiveIdentifier, this.Television.ActiveIdentifier);
404
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
405
- + ` ActiveIdentifier: ${this.Television.ActiveIdentifier}`);
406
- }
394
+ await this.updateCharacteristic(this.Television.Service, this.hap.Characteristic.ActiveIdentifier,
395
+ this.Television.ActiveIdentifier, 'ActiveIdentifier');
407
396
  }
408
397
 
409
398
  async apiError(e: any): Promise<void> {
@@ -28,6 +28,8 @@ export class VacuumCleaner extends irdeviceBase {
28
28
  device: irdevice & irDevicesConfig,
29
29
  ) {
30
30
  super(platform, accessory, device);
31
+ // Set category
32
+ accessory.category = this.hap.Categories.OTHER;
31
33
 
32
34
  // Initialize Switch Service
33
35
  accessory.context.Switch = accessory.context.Switch ?? {};
@@ -48,7 +50,7 @@ export class VacuumCleaner extends irdeviceBase {
48
50
  }
49
51
 
50
52
  async OnSet(value: CharacteristicValue): Promise<void> {
51
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${value}`);
53
+ await this.debugLog(`On: ${value}`);
52
54
 
53
55
  // Set the requested state
54
56
  this.Switch.On = value;
@@ -66,7 +68,7 @@ export class VacuumCleaner extends irdeviceBase {
66
68
  * Vacuum Cleaner "command" "turnOn" "default" set to ON state
67
69
  */
68
70
  async pushOnChanges(): Promise<void> {
69
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOnChanges`
71
+ await this.debugLog('pushOnChanges'
70
72
  + ` On: ${this.Switch.On}, disablePushOn: ${this.disablePushOn}`);
71
73
  if (this.Switch.On && !this.disablePushOn) {
72
74
  const commandType: string = await this.commandType();
@@ -81,7 +83,7 @@ export class VacuumCleaner extends irdeviceBase {
81
83
  }
82
84
 
83
85
  async pushOffChanges(): Promise<void> {
84
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOffChanges`
86
+ await this.debugLog('pushOffChanges'
85
87
  + ` On: ${this.Switch.On}, disablePushOff: ${this.disablePushOff}`);
86
88
  if (!this.Switch.On && !this.disablePushOff) {
87
89
  const commandType: string = await this.commandType();
@@ -96,14 +98,14 @@ export class VacuumCleaner extends irdeviceBase {
96
98
  }
97
99
 
98
100
  async pushChanges(bodyChange: any): Promise<void> {
99
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
101
+ await this.debugLog('pushChanges');
100
102
  if (this.device.connectionType === 'OpenAPI') {
101
- this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
103
+ await this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`);
102
104
  try {
103
105
  const { body, statusCode } = await this.pushChangeRequest(bodyChange);
104
106
  const deviceStatus: any = await body.json();
105
107
  await this.pushStatusCodes(statusCode, deviceStatus);
106
- if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
108
+ if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
107
109
  await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
108
110
  await this.updateHomeKitCharacteristics();
109
111
  } else {
@@ -115,20 +117,15 @@ export class VacuumCleaner extends irdeviceBase {
115
117
  await this.pushChangeError(e);
116
118
  }
117
119
  } else {
118
- this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
119
- + ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
120
+ await this.warnLog(`Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
120
121
  }
121
122
  }
122
123
 
123
124
  async updateHomeKitCharacteristics(): Promise<void> {
125
+ await this.debugLog('updateHomeKitCharacteristics');
124
126
  // On
125
- if (this.Switch.On === undefined) {
126
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.Switch.On}`);
127
- } else {
128
- this.accessory.context.On = this.Switch.On;
129
- this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, this.Switch.On);
130
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.Switch.On}`);
131
- }
127
+ await this.updateCharacteristic(this.Switch.Service, this.hap.Characteristic.On,
128
+ this.Switch.On, 'On');
132
129
  }
133
130
 
134
131
  async apiError(e: any): Promise<void> {
@@ -28,6 +28,8 @@ export class WaterHeater extends irdeviceBase {
28
28
  device: irdevice & irDevicesConfig,
29
29
  ) {
30
30
  super(platform, accessory, device);
31
+ // Set category
32
+ accessory.category = this.hap.Categories.FAUCET;
31
33
 
32
34
  // Initialize Switch Service
33
35
  accessory.context.Valve = accessory.context.Valve ?? {};
@@ -49,7 +51,7 @@ export class WaterHeater extends irdeviceBase {
49
51
  }
50
52
 
51
53
  async ActiveSet(value: CharacteristicValue): Promise<void> {
52
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${value}`);
54
+ await this.debugLog(`Active: ${value}`);
53
55
 
54
56
  this.Valve.Active = value;
55
57
  if (this.Valve.Active === this.hap.Characteristic.Active.ACTIVE) {
@@ -68,7 +70,7 @@ export class WaterHeater extends irdeviceBase {
68
70
  * WaterHeater "command" "turnOn" "default" set to ON state
69
71
  */
70
72
  async pushWaterHeaterOnChanges(): Promise<void> {
71
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushWaterHeaterOnChanges Active: ${this.Valve.Active},`
73
+ await this.debugLog(`pushWaterHeaterOnChanges Active: ${this.Valve.Active},`
72
74
  + ` disablePushOn: ${this.disablePushOn}`);
73
75
  if (this.Valve.Active === this.hap.Characteristic.Active.ACTIVE && !this.disablePushOn) {
74
76
  const commandType: string = await this.commandType();
@@ -83,7 +85,7 @@ export class WaterHeater extends irdeviceBase {
83
85
  }
84
86
 
85
87
  async pushWaterHeaterOffChanges(): Promise<void> {
86
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushWaterHeaterOffChanges Active: ${this.Valve.Active},`
88
+ await this.debugLog(`pushWaterHeaterOffChanges Active: ${this.Valve.Active},`
87
89
  + ` disablePushOff: ${this.disablePushOff}`);
88
90
  if (this.Valve.Active === this.hap.Characteristic.Active.INACTIVE && !this.disablePushOff) {
89
91
  const commandType: string = await this.commandType();
@@ -98,14 +100,14 @@ export class WaterHeater extends irdeviceBase {
98
100
  }
99
101
 
100
102
  async pushChanges(bodyChange: any): Promise<void> {
101
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
103
+ await this.debugLog('pushChanges');
102
104
  if (this.device.connectionType === 'OpenAPI') {
103
- this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
105
+ this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`);
104
106
  try {
105
107
  const { body, statusCode } = await this.pushChangeRequest(bodyChange);
106
108
  const deviceStatus: any = await body.json();
107
109
  await this.pushStatusCodes(statusCode, deviceStatus);
108
- if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
110
+ if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
109
111
  await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
110
112
  await this.updateHomeKitCharacteristics();
111
113
  } else {
@@ -117,20 +119,15 @@ export class WaterHeater extends irdeviceBase {
117
119
  await this.pushChangeError(e);
118
120
  }
119
121
  } else {
120
- this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
121
- + ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
122
+ await this.warnLog(`Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
122
123
  }
123
124
  }
124
125
 
125
126
  async updateHomeKitCharacteristics(): Promise<void> {
127
+ await this.debugLog('updateHomeKitCharacteristics');
126
128
  // Active
127
- if (this.Valve.Active === undefined) {
128
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Valve.Active}`);
129
- } else {
130
- this.accessory.context.Active = this.Valve.Active;
131
- this.Valve.Service.updateCharacteristic(this.hap.Characteristic.Active, this.Valve.Active);
132
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Valve.Active}`);
133
- }
129
+ await this.updateCharacteristic(this.Valve.Service, this.hap.Characteristic.Active,
130
+ this.Valve.Active, 'Active');
134
131
  }
135
132
 
136
133
  async apiError({ e }: { e: any }): Promise<void> {