@switchbot/homebridge-switchbot 1.10.2-beta.5 → 1.11.0

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 (52) hide show
  1. package/CHANGELOG.md +3 -3
  2. package/config.schema.json +49 -0
  3. package/dist/device/bot.d.ts +43 -40
  4. package/dist/device/bot.d.ts.map +1 -1
  5. package/dist/device/bot.js +29 -26
  6. package/dist/device/bot.js.map +1 -1
  7. package/dist/device/colorbulb.d.ts +25 -21
  8. package/dist/device/colorbulb.d.ts.map +1 -1
  9. package/dist/device/colorbulb.js +176 -145
  10. package/dist/device/colorbulb.js.map +1 -1
  11. package/dist/device/contact.d.ts +15 -15
  12. package/dist/device/contact.d.ts.map +1 -1
  13. package/dist/device/contact.js +14 -13
  14. package/dist/device/contact.js.map +1 -1
  15. package/dist/device/curtain.d.ts +25 -22
  16. package/dist/device/curtain.d.ts.map +1 -1
  17. package/dist/device/curtain.js +50 -37
  18. package/dist/device/curtain.js.map +1 -1
  19. package/dist/device/humidifier.d.ts +23 -20
  20. package/dist/device/humidifier.d.ts.map +1 -1
  21. package/dist/device/humidifier.js +41 -41
  22. package/dist/device/humidifier.js.map +1 -1
  23. package/dist/device/lock.d.ts +16 -13
  24. package/dist/device/lock.d.ts.map +1 -1
  25. package/dist/device/lock.js +20 -22
  26. package/dist/device/lock.js.map +1 -1
  27. package/dist/device/meter.d.ts +15 -15
  28. package/dist/device/meter.d.ts.map +1 -1
  29. package/dist/device/meter.js +11 -14
  30. package/dist/device/meter.js.map +1 -1
  31. package/dist/device/motion.d.ts +16 -16
  32. package/dist/device/motion.d.ts.map +1 -1
  33. package/dist/device/motion.js +16 -17
  34. package/dist/device/motion.js.map +1 -1
  35. package/dist/device/plug.d.ts +10 -7
  36. package/dist/device/plug.d.ts.map +1 -1
  37. package/dist/device/plug.js +22 -21
  38. package/dist/device/plug.js.map +1 -1
  39. package/dist/settings.d.ts +4 -1
  40. package/dist/settings.d.ts.map +1 -1
  41. package/dist/settings.js.map +1 -1
  42. package/package.json +76 -76
  43. package/src/device/bot.ts +53 -50
  44. package/src/device/colorbulb.ts +208 -162
  45. package/src/device/contact.ts +31 -30
  46. package/src/device/curtain.ts +68 -57
  47. package/src/device/humidifier.ts +68 -59
  48. package/src/device/lock.ts +28 -31
  49. package/src/device/meter.ts +25 -31
  50. package/src/device/motion.ts +32 -36
  51. package/src/device/plug.ts +25 -25
  52. package/src/settings.ts +5 -1
@@ -12,7 +12,7 @@ import { DeviceURL, device, devicesConfig, switchbot, deviceStatusResponse, payl
12
12
  */
13
13
  export class ColorBulb {
14
14
  // Services
15
- service!: Service;
15
+ lightBulbService!: Service;
16
16
 
17
17
  // Characteristic Values
18
18
  On!: CharacteristicValue;
@@ -23,14 +23,14 @@ export class ColorBulb {
23
23
  SaturationCached!: CharacteristicValue;
24
24
  Brightness!: CharacteristicValue;
25
25
  BrightnessCached!: CharacteristicValue;
26
- ColorTemperature!: CharacteristicValue;
27
- ColorTemperatureCached!: CharacteristicValue;
26
+ ColorTemperature?: CharacteristicValue;
27
+ ColorTemperatureCached?: CharacteristicValue;
28
28
 
29
29
  // OpenAPI Others
30
30
  power: deviceStatus['power'];
31
31
  color: deviceStatus['color'];
32
32
  brightness: deviceStatus['brightness'];
33
- colorTemperature: deviceStatus['colorTemperature'];
33
+ colorTemperature?: deviceStatus['colorTemperature'];
34
34
  deviceStatus!: deviceStatusResponse;
35
35
 
36
36
  // BLE Others
@@ -44,13 +44,15 @@ export class ColorBulb {
44
44
 
45
45
  // Adaptive Lighting
46
46
  AdaptiveLightingController?: ControllerConstructor | Controller<ControllerServiceMap>;
47
- minKelvin: number;
48
- maxKelvin: number;
47
+ minKelvin!: number;
48
+ maxKelvin!: number;
49
+
50
+ // Others
51
+ cacheKelvin!: number;
49
52
 
50
53
  // Updates
51
54
  colorBulbUpdateInProgress!: boolean;
52
55
  doColorBulbUpdate!: Subject<void>;
53
- cacheKelvin!: number;
54
56
 
55
57
  constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: device & devicesConfig) {
56
58
  // default placeholders
@@ -63,12 +65,6 @@ export class ColorBulb {
63
65
  } else {
64
66
  this.On = this.accessory.context.On;
65
67
  }
66
- this.Hue = 0;
67
- this.Brightness = 0;
68
- this.Saturation = 0;
69
- this.ColorTemperature = 140;
70
- this.minKelvin = 2000;
71
- this.maxKelvin = 9000;
72
68
  // this is subject we use to track when we need to POST changes to the SwitchBot API
73
69
  this.doColorBulbUpdate = new Subject();
74
70
  this.colorBulbUpdateInProgress = false;
@@ -80,19 +76,19 @@ export class ColorBulb {
80
76
  accessory
81
77
  .getService(this.platform.Service.AccessoryInformation)!
82
78
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
83
- .setCharacteristic(this.platform.Characteristic.Model, 'SWITCHBOT-COLORBULB-W1401400')
79
+ .setCharacteristic(this.platform.Characteristic.Model, this.model(device))
84
80
  .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
85
81
 
86
82
  // get the Lightbulb service if it exists, otherwise create a new Lightbulb service
87
83
  // you can create multiple services for each accessory
88
- (this.service = accessory.getService(this.platform.Service.Lightbulb) || accessory.addService(this.platform.Service.Lightbulb)),
89
- `${accessory.displayName} Light Bulb`;
84
+ (this.lightBulbService = accessory.getService(this.platform.Service.Lightbulb) || accessory.addService(this.platform.Service.Lightbulb)),
85
+ `${accessory.displayName} ${this.device.deviceType}`;
90
86
 
91
87
  if (this.adaptiveLightingShift === -1 && this.accessory.context.adaptiveLighting) {
92
- this.accessory.removeService(this.service);
93
- this.service = this.accessory.addService(this.platform.Service.Lightbulb);
88
+ this.accessory.removeService(this.lightBulbService);
89
+ this.lightBulbService = this.accessory.addService(this.platform.Service.Lightbulb);
94
90
  this.accessory.context.adaptiveLighting = false;
95
- this.debugLog(`Color Bulb: ${this.accessory.displayName} adaptiveLighting: ${this.accessory.context.adaptiveLighting}`);
91
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} adaptiveLighting: ${this.accessory.context.adaptiveLighting}`);
96
92
  }
97
93
 
98
94
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
@@ -101,13 +97,13 @@ export class ColorBulb {
101
97
 
102
98
  // set the service name, this is what is displayed as the default name on the Home app
103
99
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
104
- this.service.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
100
+ this.lightBulbService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
105
101
 
106
102
  // handle on / off events using the On characteristic
107
- this.service.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
103
+ this.lightBulbService.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
108
104
 
109
105
  // handle Brightness events using the Brightness characteristic
110
- this.service
106
+ this.lightBulbService
111
107
  .getCharacteristic(this.platform.Characteristic.Brightness)
112
108
  .setProps({
113
109
  minStep: this.minStep(device),
@@ -121,20 +117,25 @@ export class ColorBulb {
121
117
  .onSet(this.BrightnessSet.bind(this));
122
118
 
123
119
  // handle ColorTemperature events using the ColorTemperature characteristic
124
- this.service
125
- .getCharacteristic(this.platform.Characteristic.ColorTemperature)
126
- .setProps({
127
- minValue: 140,
128
- maxValue: 500,
129
- validValueRanges: [140, 500],
130
- })
131
- .onGet(() => {
132
- return this.ColorTemperature;
133
- })
134
- .onSet(this.ColorTemperatureSet.bind(this));
120
+ if (device.deviceType === 'Color Bulb') {
121
+ this.debugLog(`Color Bulb: ${accessory.displayName} Add ColorTemperature Characteristic`);
122
+ this.lightBulbService
123
+ .getCharacteristic(this.platform.Characteristic.ColorTemperature)
124
+ .setProps({
125
+ minValue: 140,
126
+ maxValue: 500,
127
+ validValueRanges: [140, 500],
128
+ })
129
+ .onGet(() => {
130
+ return this.ColorTemperature!;
131
+ })
132
+ .onSet(this.ColorTemperatureSet.bind(this));
133
+ } else {
134
+ this.debugLog(`Color Bulb: ${accessory.displayName} ColorTemperature Characteristic Not Added`);
135
+ }
135
136
 
136
137
  // handle Hue events using the Hue characteristic
137
- this.service
138
+ this.lightBulbService
138
139
  .getCharacteristic(this.platform.Characteristic.Hue)
139
140
  .setProps({
140
141
  minValue: 0,
@@ -147,7 +148,7 @@ export class ColorBulb {
147
148
  .onSet(this.HueSet.bind(this));
148
149
 
149
150
  // handle Hue events using the Hue characteristic
150
- this.service
151
+ this.lightBulbService
151
152
  .getCharacteristic(this.platform.Characteristic.Saturation)
152
153
  .setProps({
153
154
  minValue: 0,
@@ -159,15 +160,15 @@ export class ColorBulb {
159
160
  })
160
161
  .onSet(this.SaturationSet.bind(this));
161
162
 
162
- this.debugLog(`Color Bulb: ${this.accessory.displayName} adaptiveLightingShift: ${this.adaptiveLightingShift}`);
163
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} adaptiveLightingShift: ${this.adaptiveLightingShift}`);
163
164
  if (this.adaptiveLightingShift !== -1) {
164
- this.AdaptiveLightingController = new platform.api.hap.AdaptiveLightingController(this.service, {
165
+ this.AdaptiveLightingController = new platform.api.hap.AdaptiveLightingController(this.lightBulbService, {
165
166
  customTemperatureAdjustment: this.adaptiveLightingShift,
166
167
  });
167
168
  this.accessory.configureController(this.AdaptiveLightingController);
168
169
  this.accessory.context.adaptiveLighting = true;
169
170
  this.debugLog(
170
- `Color Bulb: ${this.accessory.displayName} adaptiveLighting: ${this.accessory.context.adaptiveLighting},` +
171
+ `${this.device.deviceType}: ${this.accessory.displayName} adaptiveLighting: ${this.accessory.context.adaptiveLighting},` +
171
172
  ` adaptiveLightingShift: ${this.adaptiveLightingShift}`,
172
173
  );
173
174
  }
@@ -178,8 +179,8 @@ export class ColorBulb {
178
179
  // Start an update interval
179
180
  interval(this.deviceRefreshRate * 1000)
180
181
  .pipe(skipWhile(() => this.colorBulbUpdateInProgress))
181
- .subscribe(() => {
182
- this.refreshStatus();
182
+ .subscribe(async () => {
183
+ await this.refreshStatus();
183
184
  });
184
185
 
185
186
  // Watch for Bulb change events
@@ -195,12 +196,14 @@ export class ColorBulb {
195
196
  try {
196
197
  await this.pushChanges();
197
198
  } catch (e: any) {
198
- this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges`);
199
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges`);
199
200
  if (this.deviceLogging === 'debug') {
200
- this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges,` + ` Error Message: ${JSON.stringify(e.message)}`);
201
+ this.errorLog(
202
+ `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges,` + ` Error Message: ${JSON.stringify(e.message)}`,
203
+ );
201
204
  }
202
205
  if (this.platform.debugMode) {
203
- this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges,` + ` Error: ${JSON.stringify(e)}`);
206
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges,` + ` Error: ${JSON.stringify(e)}`);
204
207
  }
205
208
  this.apiError(e);
206
209
  }
@@ -208,7 +211,7 @@ export class ColorBulb {
208
211
  });
209
212
  }
210
213
 
211
- parseStatus() {
214
+ async parseStatus(): Promise<void> {
212
215
  switch (this.power) {
213
216
  case 'on':
214
217
  this.On = true;
@@ -216,63 +219,72 @@ export class ColorBulb {
216
219
  default:
217
220
  this.On = false;
218
221
  }
219
- this.debugLog(`Color Bulb: ${this.accessory.displayName} On: ${this.On}`);
222
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
220
223
 
221
224
  // Brightness
222
225
  this.Brightness = Number(this.brightness);
223
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Brightness: ${this.Brightness}`);
226
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Brightness: ${this.Brightness}`);
224
227
 
225
228
  // Color, Hue & Brightness
226
229
  if (this.color) {
227
- this.debugLog(`Color Bulb: ${this.accessory.displayName} color: ${JSON.stringify(this.color)}`);
230
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} color: ${JSON.stringify(this.color)}`);
228
231
  const [red, green, blue] = this.color!.split(':');
229
- this.debugLog(`Color Bulb: ${this.accessory.displayName} red: ${JSON.stringify(red)}`);
230
- this.debugLog(`Color Bulb: ${this.accessory.displayName} green: ${JSON.stringify(green)}`);
231
- this.debugLog(`Color Bulb: ${this.accessory.displayName} blue: ${JSON.stringify(blue)}`);
232
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} red: ${JSON.stringify(red)}`);
233
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} green: ${JSON.stringify(green)}`);
234
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} blue: ${JSON.stringify(blue)}`);
232
235
 
233
236
  const [hue, saturation] = rgb2hs(Number(red), Number(green), Number(blue));
234
- this.debugLog(`Color Bulb: ${this.accessory.displayName} hs: ${JSON.stringify(rgb2hs(Number(red), Number(green), Number(blue)))}`);
237
+ this.debugLog(
238
+ `${this.device.deviceType}: ${this.accessory.displayName} hs: ${JSON.stringify(rgb2hs(Number(red), Number(green), Number(blue)))}`,
239
+ );
235
240
 
236
241
  // Hue
237
242
  this.Hue = hue;
238
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Hue: ${this.Hue}`);
243
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${this.Hue}`);
239
244
 
240
245
  // Saturation
241
246
  this.Saturation = saturation;
242
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Saturation: ${this.Saturation}`);
247
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${this.Saturation}`);
243
248
  }
244
249
 
245
250
  // ColorTemperature
246
- if (!Number.isNaN(this.colorTemperature)) {
247
- this.debugLog(`Color Bulb: ${this.accessory.displayName} OpenAPI ColorTemperature: ${this.colorTemperature}`);
248
- const mired = Math.round(1000000 / this.colorTemperature!);
251
+ if (this.device.deviceType === 'Color Bulb') {
252
+ if (!Number.isNaN(this.colorTemperature)) {
253
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI ColorTemperature: ${this.colorTemperature}`);
254
+ const mired = Math.round(1000000 / this.colorTemperature!);
249
255
 
250
- this.ColorTemperature = Number(mired);
256
+ this.ColorTemperature = Number(mired);
251
257
 
252
- this.ColorTemperature = Math.max(Math.min(this.ColorTemperature, 500), 140);
253
- this.debugLog(`Color Bulb: ${this.accessory.displayName} ColorTemperature: ${this.ColorTemperature}`);
258
+ this.ColorTemperature = Math.max(Math.min(this.ColorTemperature, 500), 140);
259
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ColorTemperature: ${this.ColorTemperature}`);
260
+ }
254
261
  }
255
262
  }
256
263
 
257
- async refreshStatus() {
264
+ async refreshStatus(): Promise<void> {
258
265
  try {
259
266
  this.deviceStatus = (await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`)).data;
260
- this.debugLog(`Color Bulb: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
267
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
261
268
  this.power = this.deviceStatus.body.power;
262
269
  this.color = this.deviceStatus.body.color;
263
270
  this.brightness = this.deviceStatus.body.brightness;
264
- this.colorTemperature = this.deviceStatus.body.colorTemperature;
271
+ if (this.device.deviceType === 'Color Bulb') {
272
+ this.colorTemperature = this.deviceStatus.body.colorTemperature;
273
+ }
265
274
  this.parseStatus();
266
275
  this.updateHomeKitCharacteristics();
267
276
  } catch (e: any) {
268
- this.errorLog(`Color Bulb: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
277
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
269
278
  if (this.deviceLogging === 'debug') {
270
279
  this.errorLog(
271
- `Color Bulb: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
280
+ `${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` +
281
+ ` Error Message: ${JSON.stringify(e.message)}`,
272
282
  );
273
283
  }
274
284
  if (this.platform.debugMode) {
275
- this.errorLog(`Color Bulb: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
285
+ this.errorLog(
286
+ `${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`,
287
+ );
276
288
  }
277
289
  this.apiError(e);
278
290
  }
@@ -294,7 +306,7 @@ export class ColorBulb {
294
306
  * Strip Light - "command" "setColor" "`"{0-255}:{0-255}:{0-255}"`" = set RGB color value |
295
307
  *
296
308
  */
297
- async pushChanges() {
309
+ async pushChanges(): Promise<void> {
298
310
  try {
299
311
  if (this.On !== this.OnCached) {
300
312
  // Push On Update
@@ -310,13 +322,13 @@ export class ColorBulb {
310
322
  }
311
323
 
312
324
  this.infoLog(
313
- `Color Bulb: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
325
+ `${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
314
326
  ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`,
315
327
  );
316
328
 
317
329
  // Make the API request
318
330
  const push: any = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
319
- this.debugLog(`Color Bulb: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
331
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
320
332
  this.statusCode(push);
321
333
  this.OnCached = this.On;
322
334
  this.accessory.context.On = this.OnCached;
@@ -327,7 +339,7 @@ export class ColorBulb {
327
339
  }
328
340
 
329
341
  // Push ColorTemperature Update
330
- if (this.On) {
342
+ if (this.On && this.device.deviceType === 'Color Bulb') {
331
343
  await this.pushColorTemperatureChanges();
332
344
  }
333
345
 
@@ -336,27 +348,30 @@ export class ColorBulb {
336
348
  await this.pushHueSaturationChanges();
337
349
  }
338
350
  } catch (e: any) {
339
- this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
351
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
340
352
  if (this.deviceLogging === 'debug') {
341
353
  this.errorLog(
342
- `Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
354
+ `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
355
+ ` Error Message: ${JSON.stringify(e.message)}`,
343
356
  );
344
357
  }
345
358
  if (this.platform.debugMode) {
346
- this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
359
+ this.errorLog(
360
+ `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`,
361
+ );
347
362
  }
348
363
  this.apiError(e);
349
364
  }
350
365
  }
351
366
 
352
- private async pushHueSaturationChanges() {
367
+ async pushHueSaturationChanges(): Promise<void> {
353
368
  try {
354
369
  if (this.Hue !== this.HueCached || this.Saturation !== this.SaturationCached) {
355
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Hue: ${JSON.stringify(this.Hue)}`);
356
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Saturation: ${JSON.stringify(this.Saturation)}`);
370
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${JSON.stringify(this.Hue)}`);
371
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${JSON.stringify(this.Saturation)}`);
357
372
 
358
373
  const [red, green, blue] = hs2rgb(Number(this.Hue), Number(this.Saturation));
359
- this.debugLog(`Color Bulb: ${this.accessory.displayName} rgb: ${JSON.stringify([red, green, blue])}`);
374
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} rgb: ${JSON.stringify([red, green, blue])}`);
360
375
 
361
376
  const payload = {
362
377
  commandType: 'command',
@@ -365,37 +380,40 @@ export class ColorBulb {
365
380
  } as payload;
366
381
 
367
382
  this.infoLog(
368
- `Color Bulb: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
383
+ `${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
369
384
  ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`,
370
385
  );
371
386
 
372
387
  // Make the API request
373
388
  const push: any = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
374
- this.debugLog(`Color Bulb: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
389
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
375
390
  this.statusCode(push);
376
391
  this.HueCached = this.Hue;
377
392
  this.SaturationCached = this.Saturation;
378
393
  } else {
379
394
  this.debugLog(
380
- `Color Bulb: ${this.accessory.displayName} No Changes.` +
395
+ `${this.device.deviceType}: ${this.accessory.displayName} No Changes.` +
381
396
  `Hue: ${this.Hue}, HueCached: ${this.HueCached}, Saturation: ${this.Saturation}, SaturationCached: ${this.SaturationCached}`,
382
397
  );
383
398
  }
384
399
  } catch (e: any) {
385
- this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
400
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
386
401
  if (this.deviceLogging === 'debug') {
387
402
  this.errorLog(
388
- `Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
403
+ `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
404
+ ` Error Message: ${JSON.stringify(e.message)}`,
389
405
  );
390
406
  }
391
407
  if (this.platform.debugMode) {
392
- this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
408
+ this.errorLog(
409
+ `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`,
410
+ );
393
411
  }
394
412
  this.apiError(e);
395
413
  }
396
414
  }
397
415
 
398
- private async pushColorTemperatureChanges() {
416
+ async pushColorTemperatureChanges(): Promise<void> {
399
417
  try {
400
418
  if (this.ColorTemperature !== this.ColorTemperatureCached) {
401
419
  const kelvin = Math.round(1000000 / Number(this.ColorTemperature));
@@ -408,36 +426,39 @@ export class ColorBulb {
408
426
  } as payload;
409
427
 
410
428
  this.infoLog(
411
- `Color Bulb: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
429
+ `${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
412
430
  ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`,
413
431
  );
414
432
 
415
433
  // Make the API request
416
434
  const push: any = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
417
- this.debugLog(`Color Bulb: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
435
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
418
436
  this.statusCode(push);
419
437
  this.ColorTemperatureCached = this.ColorTemperature;
420
438
  } else {
421
439
  this.debugLog(
422
- `Color Bulb: ${this.accessory.displayName} No Changes.` +
440
+ `${this.device.deviceType}: ${this.accessory.displayName} No Changes.` +
423
441
  `ColorTemperature: ${this.ColorTemperature}, ColorTemperatureCached: ${this.ColorTemperatureCached}`,
424
442
  );
425
443
  }
426
444
  } catch (e: any) {
427
- this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
445
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
428
446
  if (this.deviceLogging === 'debug') {
429
447
  this.errorLog(
430
- `Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
448
+ `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
449
+ ` Error Message: ${JSON.stringify(e.message)}`,
431
450
  );
432
451
  }
433
452
  if (this.platform.debugMode) {
434
- this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
453
+ this.errorLog(
454
+ `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`,
455
+ );
435
456
  }
436
457
  this.apiError(e);
437
458
  }
438
459
  }
439
460
 
440
- private async pushBrightnessChanges() {
461
+ async pushBrightnessChanges(): Promise<void> {
441
462
  try {
442
463
  if (this.Brightness !== this.BrightnessCached) {
443
464
  const payload = {
@@ -447,125 +468,133 @@ export class ColorBulb {
447
468
  } as payload;
448
469
 
449
470
  this.infoLog(
450
- `Color Bulb: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
471
+ `${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
451
472
  ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`,
452
473
  );
453
474
 
454
475
  // Make the API request
455
476
  const push: any = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
456
- this.debugLog(`Color Bulb: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
477
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
457
478
  this.statusCode(push);
458
479
  this.BrightnessCached = this.Brightness;
459
480
  } else {
460
481
  this.debugLog(
461
- `Color Bulb: ${this.accessory.displayName} No Changes.` + `Brightness: ${this.Brightness}, BrightnessCached: ${this.BrightnessCached}`,
482
+ `${this.device.deviceType}: ${this.accessory.displayName} No Changes.` +
483
+ `Brightness: ${this.Brightness}, BrightnessCached: ${this.BrightnessCached}`,
462
484
  );
463
485
  }
464
486
  } catch (e: any) {
465
- this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
487
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
466
488
  if (this.deviceLogging === 'debug') {
467
489
  this.errorLog(
468
- `Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
490
+ `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
491
+ ` Error Message: ${JSON.stringify(e.message)}`,
469
492
  );
470
493
  }
471
494
  if (this.platform.debugMode) {
472
- this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
495
+ this.errorLog(
496
+ `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`,
497
+ );
473
498
  }
474
499
  this.apiError(e);
475
500
  }
476
501
  }
477
502
 
478
- updateHomeKitCharacteristics() {
503
+ async updateHomeKitCharacteristics(): Promise<void> {
479
504
  if (this.On === undefined) {
480
- this.debugLog(`Color Bulb: ${this.accessory.displayName} On: ${this.On}`);
505
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
481
506
  } else {
482
- this.service.updateCharacteristic(this.platform.Characteristic.On, this.On);
483
- this.debugLog(`Color Bulb: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
507
+ this.lightBulbService.updateCharacteristic(this.platform.Characteristic.On, this.On);
508
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
484
509
  }
485
510
  if (this.Brightness === undefined) {
486
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Brightness: ${this.Brightness}`);
511
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Brightness: ${this.Brightness}`);
487
512
  } else {
488
- this.service.updateCharacteristic(this.platform.Characteristic.Brightness, this.Brightness);
489
- this.debugLog(`Color Bulb: ${this.accessory.displayName} updateCharacteristic Brightness: ${this.Brightness}`);
513
+ this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Brightness, this.Brightness);
514
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Brightness: ${this.Brightness}`);
490
515
  }
491
- if (this.ColorTemperature === undefined) {
492
- this.debugLog(`Color Bulb: ${this.accessory.displayName} ColorTemperature: ${this.ColorTemperature}`);
493
- } else {
494
- this.service.updateCharacteristic(this.platform.Characteristic.ColorTemperature, this.ColorTemperature);
495
- this.debugLog(`Color Bulb: ${this.accessory.displayName} updateCharacteristic ColorTemperature: ${this.ColorTemperature}`);
516
+ if (this.device.deviceType === 'Color Bulb') {
517
+ if (this.ColorTemperature === undefined) {
518
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ColorTemperature: ${this.ColorTemperature}`);
519
+ } else {
520
+ this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, this.ColorTemperature);
521
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic ColorTemperature: ${this.ColorTemperature}`);
522
+ }
496
523
  }
497
524
  if (this.Hue === undefined) {
498
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Hue: ${this.Hue}`);
525
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${this.Hue}`);
499
526
  } else {
500
- this.service.updateCharacteristic(this.platform.Characteristic.Hue, this.Hue);
501
- this.debugLog(`Color Bulb: ${this.accessory.displayName} updateCharacteristic Hue: ${this.Hue}`);
527
+ this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Hue, this.Hue);
528
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Hue: ${this.Hue}`);
502
529
  }
503
530
  if (this.Saturation === undefined) {
504
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Saturation: ${this.Saturation}`);
531
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${this.Saturation}`);
505
532
  } else {
506
- this.service.updateCharacteristic(this.platform.Characteristic.Saturation, this.Saturation);
507
- this.debugLog(`Color Bulb: ${this.accessory.displayName} updateCharacteristic Saturation: ${this.Saturation}`);
533
+ this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Saturation, this.Saturation);
534
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Saturation: ${this.Saturation}`);
508
535
  }
509
536
  }
510
537
 
511
- public apiError(e: any) {
512
- this.service.updateCharacteristic(this.platform.Characteristic.On, e);
513
- this.service.updateCharacteristic(this.platform.Characteristic.Hue, e);
514
- this.service.updateCharacteristic(this.platform.Characteristic.Brightness, e);
515
- this.service.updateCharacteristic(this.platform.Characteristic.Saturation, e);
516
- this.service.updateCharacteristic(this.platform.Characteristic.ColorTemperature, e);
538
+ apiError(e: any): void {
539
+ this.lightBulbService.updateCharacteristic(this.platform.Characteristic.On, e);
540
+ this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Hue, e);
541
+ this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Brightness, e);
542
+ this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Saturation, e);
543
+ if (this.device.deviceType === 'Color Bulb') {
544
+ this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, e);
545
+ }
517
546
  //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
518
547
  }
519
548
 
520
- private statusCode(push: AxiosResponse<{ statusCode: number }>) {
549
+ statusCode(push: AxiosResponse<{ statusCode: number }>): void {
521
550
  switch (push.data.statusCode) {
522
551
  case 151:
523
- this.errorLog(`Color Bulb: ${this.accessory.displayName} Command not supported by this device type.`);
552
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Command not supported by this device type.`);
524
553
  break;
525
554
  case 152:
526
- this.errorLog(`Color Bulb: ${this.accessory.displayName} Device not found.`);
555
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device not found.`);
527
556
  break;
528
557
  case 160:
529
- this.errorLog(`Color Bulb: ${this.accessory.displayName} Command is not supported.`);
558
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Command is not supported.`);
530
559
  break;
531
560
  case 161:
532
- this.errorLog(`Color Bulb: ${this.accessory.displayName} Device is offline.`);
561
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device is offline.`);
533
562
  this.offlineOff();
534
563
  break;
535
564
  case 171:
536
- this.errorLog(`Color Bulb: ${this.accessory.displayName} is offline. Hub: ${this.device.hubDeviceId}`);
565
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} is offline. Hub: ${this.device.hubDeviceId}`);
537
566
  this.offlineOff();
538
567
  break;
539
568
  case 190:
540
569
  this.errorLog(
541
- `Color Bulb: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` +
570
+ `${this.device.deviceType}: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` +
542
571
  ` Or command: ${JSON.stringify(push.data)} format is invalid`,
543
572
  );
544
573
  break;
545
574
  case 100:
546
575
  if (this.platform.debugMode) {
547
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Command successfully sent.`);
576
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Command successfully sent.`);
548
577
  }
549
578
  break;
550
579
  default:
551
580
  if (this.platform.debugMode) {
552
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Unknown statusCode.`);
581
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode.`);
553
582
  }
554
583
  }
555
584
  }
556
585
 
557
- private offlineOff() {
586
+ async offlineOff(): Promise<void> {
558
587
  if (this.device.offline) {
559
588
  this.On = false;
560
- this.service.getCharacteristic(this.platform.Characteristic.On).updateValue(this.On);
589
+ this.lightBulbService.getCharacteristic(this.platform.Characteristic.On).updateValue(this.On);
561
590
  }
562
591
  }
563
592
 
564
593
  /**
565
594
  * Handle requests to set the value of the "On" characteristic
566
595
  */
567
- OnSet(value: CharacteristicValue) {
568
- this.debugLog(`Color Bulb: ${this.accessory.displayName} On: ${value}`);
596
+ async OnSet(value: CharacteristicValue): Promise<void> {
597
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${value}`);
569
598
 
570
599
  this.On = value;
571
600
  this.doColorBulbUpdate.next();
@@ -574,8 +603,8 @@ export class ColorBulb {
574
603
  /**
575
604
  * Handle requests to set the value of the "Brightness" characteristic
576
605
  */
577
- BrightnessSet(value: CharacteristicValue) {
578
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Brightness: ${value}`);
606
+ async BrightnessSet(value: CharacteristicValue): Promise<void> {
607
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Brightness: ${value}`);
579
608
 
580
609
  this.Brightness = value;
581
610
  this.doColorBulbUpdate.next();
@@ -584,8 +613,8 @@ export class ColorBulb {
584
613
  /**
585
614
  * Handle requests to set the value of the "ColorTemperature" characteristic
586
615
  */
587
- ColorTemperatureSet(value: CharacteristicValue) {
588
- this.debugLog(`Color Bulb: ${this.accessory.displayName} ColorTemperature: ${value}`);
616
+ async ColorTemperatureSet(value: CharacteristicValue): Promise<void> {
617
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ColorTemperature: ${value}`);
589
618
 
590
619
  // Convert mired to kelvin to nearest 100 (SwitchBot seems to need this)
591
620
  const kelvin = Math.round(1000000 / Number(value) / 100) * 100;
@@ -599,8 +628,8 @@ export class ColorBulb {
599
628
 
600
629
  // Updating the hue/sat to the corresponding values mimics native adaptive lighting
601
630
  const hs = m2hs(value);
602
- this.service.updateCharacteristic(this.platform.Characteristic.Hue, hs[0]);
603
- this.service.updateCharacteristic(this.platform.Characteristic.Saturation, hs[1]);
631
+ this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Hue, hs[0]);
632
+ this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Saturation, hs[1]);
604
633
 
605
634
  this.ColorTemperature = value;
606
635
  this.doColorBulbUpdate.next();
@@ -609,10 +638,12 @@ export class ColorBulb {
609
638
  /**
610
639
  * Handle requests to set the value of the "Hue" characteristic
611
640
  */
612
- HueSet(value: CharacteristicValue) {
613
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Hue: ${value}`);
641
+ async HueSet(value: CharacteristicValue): Promise<void> {
642
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${value}`);
614
643
 
615
- this.service.updateCharacteristic(this.platform.Characteristic.ColorTemperature, 140);
644
+ if (this.device.deviceType === 'Color Bulb') {
645
+ this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, 140);
646
+ }
616
647
 
617
648
  this.Hue = value;
618
649
  this.doColorBulbUpdate.next();
@@ -621,16 +652,28 @@ export class ColorBulb {
621
652
  /**
622
653
  * Handle requests to set the value of the "Saturation" characteristic
623
654
  */
624
- SaturationSet(value: CharacteristicValue) {
625
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Saturation: ${value}`);
655
+ async SaturationSet(value: CharacteristicValue): Promise<void> {
656
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${value}`);
626
657
 
627
- this.service.updateCharacteristic(this.platform.Characteristic.ColorTemperature, 140);
658
+ if (this.device.deviceType === 'Color Bulb') {
659
+ this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, 140);
660
+ }
628
661
 
629
662
  this.Saturation = value;
630
663
  this.doColorBulbUpdate.next();
631
664
  }
632
665
 
633
- config(device: device & devicesConfig) {
666
+ model(device: device & devicesConfig): string {
667
+ let model: string;
668
+ if (device.deviceType === 'Strip Light') {
669
+ model = 'W1701100';
670
+ } else {
671
+ model = 'W1401400';
672
+ }
673
+ return model;
674
+ }
675
+
676
+ async config(device: device & devicesConfig): Promise<void> {
634
677
  let config = {};
635
678
  if (device.colorbulb) {
636
679
  config = device.colorbulb;
@@ -647,44 +690,47 @@ export class ColorBulb {
647
690
  if (device.scanDuration !== undefined) {
648
691
  config['scanDuration'] = device.scanDuration;
649
692
  }
693
+ if (device.offline !== undefined) {
694
+ config['offline'] = device.offline;
695
+ }
650
696
  if (Object.entries(config).length !== 0) {
651
- this.warnLog(`Color Bulb: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
697
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
652
698
  }
653
699
  }
654
700
 
655
- refreshRate(device: device & devicesConfig) {
701
+ async refreshRate(device: device & devicesConfig): Promise<void> {
656
702
  if (device.refreshRate) {
657
703
  this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
658
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
704
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
659
705
  } else if (this.platform.config.options!.refreshRate) {
660
706
  this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
661
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
707
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
662
708
  }
663
709
  }
664
710
 
665
- logs(device: device & devicesConfig) {
711
+ async logs(device: device & devicesConfig): Promise<void> {
666
712
  if (this.platform.debugMode) {
667
713
  this.deviceLogging = this.accessory.context.logging = 'debugMode';
668
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
714
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
669
715
  } else if (device.logging) {
670
716
  this.deviceLogging = this.accessory.context.logging = device.logging;
671
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
717
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
672
718
  } else if (this.platform.config.options?.logging) {
673
719
  this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
674
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
720
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
675
721
  } else {
676
722
  this.deviceLogging = this.accessory.context.logging = 'standard';
677
- this.debugLog(`Color Bulb: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
723
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
678
724
  }
679
725
  }
680
726
 
681
- adaptiveLighting(device: device & devicesConfig) {
727
+ async adaptiveLighting(device: device & devicesConfig): Promise<void> {
682
728
  if (device.colorbulb?.adaptiveLightingShift) {
683
729
  this.adaptiveLightingShift = device.colorbulb.adaptiveLightingShift;
684
- this.debugLog(`Color Bulb: ${this.accessory.displayName} adaptiveLightingShift: ${this.adaptiveLightingShift}`);
730
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} adaptiveLightingShift: ${this.adaptiveLightingShift}`);
685
731
  } else {
686
732
  this.adaptiveLightingShift = 0;
687
- this.debugLog(`Color Bulb: ${this.accessory.displayName} adaptiveLightingShift: ${this.adaptiveLightingShift}`);
733
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} adaptiveLightingShift: ${this.adaptiveLightingShift}`);
688
734
  }
689
735
  }
690
736
 
@@ -700,25 +746,25 @@ export class ColorBulb {
700
746
  /**
701
747
  * Logging for Device
702
748
  */
703
- infoLog(...log: any[]) {
749
+ infoLog(...log: any[]): void {
704
750
  if (this.enablingDeviceLogging()) {
705
751
  this.platform.log.info(String(...log));
706
752
  }
707
753
  }
708
754
 
709
- warnLog(...log: any[]) {
755
+ warnLog(...log: any[]): void {
710
756
  if (this.enablingDeviceLogging()) {
711
757
  this.platform.log.warn(String(...log));
712
758
  }
713
759
  }
714
760
 
715
- errorLog(...log: any[]) {
761
+ errorLog(...log: any[]): void {
716
762
  if (this.enablingDeviceLogging()) {
717
763
  this.platform.log.error(String(...log));
718
764
  }
719
765
  }
720
766
 
721
- debugLog(...log: any[]) {
767
+ debugLog(...log: any[]): void {
722
768
  if (this.enablingDeviceLogging()) {
723
769
  if (this.deviceLogging === 'debug') {
724
770
  this.platform.log.info('[DEBUG]', String(...log));