@switchbot/homebridge-switchbot 1.12.7-beta.5 → 1.12.7

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 (44) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/config.schema.json +6 -6
  3. package/dist/device/bot.js +2 -2
  4. package/dist/device/bot.js.map +1 -1
  5. package/dist/device/colorbulb.d.ts +0 -6
  6. package/dist/device/colorbulb.d.ts.map +1 -1
  7. package/dist/device/colorbulb.js +74 -89
  8. package/dist/device/colorbulb.js.map +1 -1
  9. package/dist/device/curtain.js +1 -1
  10. package/dist/device/curtain.js.map +1 -1
  11. package/dist/device/humidifier.js +2 -2
  12. package/dist/device/humidifier.js.map +1 -1
  13. package/dist/device/lock.d.ts.map +1 -1
  14. package/dist/device/lock.js +1 -21
  15. package/dist/device/lock.js.map +1 -1
  16. package/dist/device/meter.d.ts +0 -1
  17. package/dist/device/meter.d.ts.map +1 -1
  18. package/dist/device/meter.js +1 -14
  19. package/dist/device/meter.js.map +1 -1
  20. package/dist/device/meterplus.d.ts +76 -0
  21. package/dist/device/meterplus.d.ts.map +1 -0
  22. package/dist/device/meterplus.js +464 -0
  23. package/dist/device/meterplus.js.map +1 -0
  24. package/dist/device/plug.js +1 -1
  25. package/dist/device/plug.js.map +1 -1
  26. package/dist/device/striplight.d.ts +90 -0
  27. package/dist/device/striplight.d.ts.map +1 -0
  28. package/dist/device/striplight.js +487 -0
  29. package/dist/device/striplight.js.map +1 -0
  30. package/dist/platform.d.ts +2 -0
  31. package/dist/platform.d.ts.map +1 -1
  32. package/dist/platform.js +119 -9
  33. package/dist/platform.js.map +1 -1
  34. package/package.json +76 -76
  35. package/src/device/bot.ts +2 -2
  36. package/src/device/colorbulb.ts +74 -89
  37. package/src/device/curtain.ts +1 -1
  38. package/src/device/humidifier.ts +2 -2
  39. package/src/device/lock.ts +1 -21
  40. package/src/device/meter.ts +1 -13
  41. package/src/device/meterplus.ts +518 -0
  42. package/src/device/plug.ts +1 -1
  43. package/src/device/striplight.ts +583 -0
  44. package/src/platform.ts +127 -9
package/package.json CHANGED
@@ -1,80 +1,80 @@
1
1
  {
2
- "displayName": "Homebridge SwitchBot",
3
- "name": "@switchbot/homebridge-switchbot",
4
- "version": "1.12.7-beta.5",
5
- "description": "The [Homebridge](https://homebridge.io) SwitchBot plugin allows you to access your [SwitchBot](https://www.switch-bot.com) device(s) from HomeKit.",
6
- "author": "SwitchBot <support@wondertechlabs.com> (https://github.com/SwitchBot)",
7
- "license": "ISC",
8
- "repository": {
9
- "type": "git",
10
- "url": "git://github.com/OpenWonderLabs/homebridge-switchbot.git"
2
+ "displayName": "Homebridge SwitchBot",
3
+ "name": "@switchbot/homebridge-switchbot",
4
+ "version": "1.12.7",
5
+ "description": "The [Homebridge](https://homebridge.io) SwitchBot plugin allows you to access your [SwitchBot](https://www.switch-bot.com) device(s) from HomeKit.",
6
+ "author": "SwitchBot <support@wondertechlabs.com> (https://github.com/SwitchBot)",
7
+ "license": "ISC",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git://github.com/OpenWonderLabs/homebridge-switchbot.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/OpenWonderLabs/homebridge-switchbot/issues"
14
+ },
15
+ "engines": {
16
+ "homebridge": "^1.4.0",
17
+ "node": "^14.19.0 || ^16.14.0"
18
+ },
19
+ "main": "dist/index.js",
20
+ "scripts": {
21
+ "check": "npm install && npm outdated",
22
+ "update": "ncu -u && npm update && npm install",
23
+ "lint": "eslint src/**.ts",
24
+ "watch": "npm run build && npm link && nodemon",
25
+ "build": "rimraf ./dist && tsc",
26
+ "prepublishOnly": "npm run lint && npm run build",
27
+ "postpublish": "npm run clean",
28
+ "clean": "rimraf ./dist",
29
+ "test": "eslint src/**.ts"
30
+ },
31
+ "funding": [
32
+ {
33
+ "type": "Paypal",
34
+ "url": "https://paypal.me/donavanbecker"
11
35
  },
12
- "bugs": {
13
- "url": "https://github.com/OpenWonderLabs/homebridge-switchbot/issues"
14
- },
15
- "engines": {
16
- "homebridge": "^1.4.0",
17
- "node": "^14.19.0 || ^16.14.0"
18
- },
19
- "main": "dist/index.js",
20
- "scripts": {
21
- "check": "npm install && npm outdated",
22
- "update": "ncu -u && npm update && npm install",
23
- "lint": "eslint src/**.ts",
24
- "watch": "npm run build && npm link && nodemon",
25
- "build": "rimraf ./dist && tsc",
26
- "prepublishOnly": "npm run lint && npm run build",
27
- "postpublish": "npm run clean",
28
- "clean": "rimraf ./dist",
29
- "test": "eslint src/**.ts"
30
- },
31
- "funding": [
32
- {
33
- "type": "Paypal",
34
- "url": "https://paypal.me/donavanbecker"
35
- },
36
- {
37
- "type": "GitHub",
38
- "url": "https://github.com/sponsors/donavanbecker"
39
- }
40
- ],
41
- "publishConfig": {
42
- "access": "public"
43
- },
44
- "keywords": [
45
- "homebridge-plugin",
46
- "switchbot",
47
- "humidifier",
48
- "humidity",
49
- "temperature",
50
- "bot",
51
- "curtains",
52
- "windows",
53
- "ble",
54
- "ir"
55
- ],
56
- "dependencies": {
57
- "@homebridge/plugin-ui-utils": "^0.0.19",
58
- "axios": "^0.26.0",
59
- "rxjs": "^7.5.4"
60
- },
61
- "devDependencies": {
62
- "@types/node": "^17.0.21",
63
- "@typescript-eslint/eslint-plugin": "^5.13.0",
64
- "@typescript-eslint/parser": "^5.13.0",
65
- "eslint": "^8.10.0",
66
- "eslint-config-prettier": "8.5.0",
67
- "eslint-plugin-prettier": "4.0.0",
68
- "homebridge": "^1.4.0",
69
- "nodemon": "^2.0.15",
70
- "npm-check-updates": "^12.5.2",
71
- "prettier": "2.5.1",
72
- "rimraf": "^3.0.2",
73
- "ts-node": "^10.6.0",
74
- "typescript": "^4.6.2",
75
- "typescript-axios-wb": "^1.0.3"
76
- },
77
- "optionalDependencies": {
78
- "node-switchbot": "^1.2.1-beta.0"
36
+ {
37
+ "type": "GitHub",
38
+ "url": "https://github.com/sponsors/donavanbecker"
79
39
  }
40
+ ],
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "keywords": [
45
+ "homebridge-plugin",
46
+ "switchbot",
47
+ "humidifier",
48
+ "humidity",
49
+ "temperature",
50
+ "bot",
51
+ "curtains",
52
+ "windows",
53
+ "ble",
54
+ "ir"
55
+ ],
56
+ "dependencies": {
57
+ "@homebridge/plugin-ui-utils": "^0.0.19",
58
+ "axios": "^0.26.0",
59
+ "rxjs": "^7.5.4"
60
+ },
61
+ "devDependencies": {
62
+ "@types/node": "^17.0.21",
63
+ "@typescript-eslint/eslint-plugin": "^5.14.0",
64
+ "@typescript-eslint/parser": "^5.14.0",
65
+ "eslint": "^8.10.0",
66
+ "eslint-config-prettier": "8.5.0",
67
+ "eslint-plugin-prettier": "4.0.0",
68
+ "homebridge": "^1.4.0",
69
+ "nodemon": "^2.0.15",
70
+ "npm-check-updates": "^12.5.2",
71
+ "prettier": "2.5.1",
72
+ "rimraf": "^3.0.2",
73
+ "ts-node": "^10.7.0",
74
+ "typescript": "^4.6.2",
75
+ "typescript-axios-wb": "^1.0.3"
76
+ },
77
+ "optionalDependencies": {
78
+ "node-switchbot": "^1.2.0"
79
+ }
80
80
  }
package/src/device/bot.ts CHANGED
@@ -95,7 +95,7 @@ export class Bot {
95
95
  .setCharacteristic(this.platform.Characteristic.Model, 'SWITCHBOT-BOT-S1')
96
96
  .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
97
97
 
98
- // get the LightBulb service if it exists, otherwise create a new LightBulb service
98
+ // get the service if it exists, otherwise create a new service
99
99
  // you can create multiple services for each accessory
100
100
  if (device.bot?.deviceType === 'switch') {
101
101
  this.removeFanService(accessory);
@@ -602,7 +602,7 @@ export class Bot {
602
602
  .deviceId!.match(/.{1,2}/g)!
603
603
  .join(':')
604
604
  .toLowerCase();
605
- this.debugLog(`Curtain: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
605
+ this.debugLog(`Bot: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
606
606
  //if (switchbot !== false) {
607
607
  if (this.botMode === 'press') {
608
608
  this.debugLog(`Bot: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
@@ -82,7 +82,7 @@ export class ColorBulb {
82
82
  accessory
83
83
  .getService(this.platform.Service.AccessoryInformation)!
84
84
  .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
85
- .setCharacteristic(this.platform.Characteristic.Model, this.model(device))
85
+ .setCharacteristic(this.platform.Characteristic.Model, 'W1401400')
86
86
  .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
87
87
 
88
88
  // get the Lightbulb service if it exists, otherwise create a new Lightbulb service
@@ -94,7 +94,7 @@ export class ColorBulb {
94
94
  this.accessory.removeService(this.lightBulbService);
95
95
  this.lightBulbService = this.accessory.addService(this.platform.Service.Lightbulb);
96
96
  this.accessory.context.adaptiveLighting = false;
97
- this.debugLog(`${device.deviceType}: ${this.accessory.displayName} adaptiveLighting: ${this.accessory.context.adaptiveLighting}`);
97
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} adaptiveLighting: ${this.accessory.context.adaptiveLighting}`);
98
98
  }
99
99
 
100
100
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
@@ -162,7 +162,7 @@ export class ColorBulb {
162
162
  })
163
163
  .onSet(this.SaturationSet.bind(this));
164
164
 
165
- this.debugLog(`${device.deviceType}: ${this.accessory.displayName} adaptiveLightingShift: ${this.adaptiveLightingShift}`);
165
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} adaptiveLightingShift: ${this.adaptiveLightingShift}`);
166
166
  if (this.adaptiveLightingShift !== -1) {
167
167
  this.AdaptiveLightingController = new platform.api.hap.AdaptiveLightingController(this.lightBulbService, {
168
168
  customTemperatureAdjustment: this.adaptiveLightingShift,
@@ -170,7 +170,7 @@ export class ColorBulb {
170
170
  this.accessory.configureController(this.AdaptiveLightingController);
171
171
  this.accessory.context.adaptiveLighting = true;
172
172
  this.debugLog(
173
- `${device.deviceType}: ${this.accessory.displayName} adaptiveLighting: ${this.accessory.context.adaptiveLighting},` +
173
+ `Color Bulb: ${this.accessory.displayName} adaptiveLighting: ${this.accessory.context.adaptiveLighting},` +
174
174
  ` adaptiveLightingShift: ${this.adaptiveLightingShift}`,
175
175
  );
176
176
  }
@@ -198,9 +198,9 @@ export class ColorBulb {
198
198
  try {
199
199
  await this.pushChanges();
200
200
  } catch (e: any) {
201
- this.errorLog(`${device.deviceType}: ${this.accessory.displayName} failed pushChanges`);
201
+ this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges`);
202
202
  if (this.deviceLogging.includes('debug')) {
203
- this.errorLog(`${device.deviceType}: ${this.accessory.displayName} failed pushChanges,` + ` Error Message: ${JSON.stringify(e.message)}`);
203
+ this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges,` + ` Error Message: ${JSON.stringify(e.message)}`);
204
204
  }
205
205
  this.apiError(e);
206
206
  }
@@ -216,43 +216,43 @@ export class ColorBulb {
216
216
  default:
217
217
  this.On = false;
218
218
  }
219
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
219
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} On: ${this.On}`);
220
220
 
221
221
  // Brightness
222
222
  this.Brightness = Number(this.brightness);
223
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Brightness: ${this.Brightness}`);
223
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Brightness: ${this.Brightness}`);
224
224
 
225
225
  // Color, Hue & Brightness
226
226
  if (this.color) {
227
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} color: ${JSON.stringify(this.color)}`);
227
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} color: ${JSON.stringify(this.color)}`);
228
228
  const [red, green, blue] = this.color!.split(':');
229
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} red: ${JSON.stringify(red)}`);
230
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} green: ${JSON.stringify(green)}`);
231
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} blue: ${JSON.stringify(blue)}`);
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
232
 
233
233
  const [hue, saturation] = rgb2hs(Number(red), Number(green), Number(blue));
234
234
  this.debugLog(
235
- `${this.device.deviceType}: ${this.accessory.displayName} hs: ${JSON.stringify(rgb2hs(Number(red), Number(green), Number(blue)))}`,
235
+ `Color Bulb: ${this.accessory.displayName} hs: ${JSON.stringify(rgb2hs(Number(red), Number(green), Number(blue)))}`,
236
236
  );
237
237
 
238
238
  // Hue
239
239
  this.Hue = hue;
240
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${this.Hue}`);
240
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Hue: ${this.Hue}`);
241
241
 
242
242
  // Saturation
243
243
  this.Saturation = saturation;
244
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${this.Saturation}`);
244
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Saturation: ${this.Saturation}`);
245
245
  }
246
246
 
247
247
  // ColorTemperature
248
248
  if (!Number.isNaN(this.colorTemperature)) {
249
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI ColorTemperature: ${this.colorTemperature}`);
249
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} OpenAPI ColorTemperature: ${this.colorTemperature}`);
250
250
  const mired = Math.round(1000000 / this.colorTemperature!);
251
251
 
252
252
  this.ColorTemperature = Number(mired);
253
253
 
254
254
  this.ColorTemperature = Math.max(Math.min(this.ColorTemperature, 500), 140);
255
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ColorTemperature: ${this.ColorTemperature}`);
255
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} ColorTemperature: ${this.ColorTemperature}`);
256
256
  }
257
257
 
258
258
  }
@@ -260,7 +260,7 @@ export class ColorBulb {
260
260
  async refreshStatus(): Promise<void> {
261
261
  try {
262
262
  this.deviceStatus = (await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`)).data;
263
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
263
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
264
264
  this.power = this.deviceStatus.body.power;
265
265
  this.color = this.deviceStatus.body.color;
266
266
  this.brightness = this.deviceStatus.body.brightness;
@@ -269,10 +269,10 @@ export class ColorBulb {
269
269
  this.parseStatus();
270
270
  this.updateHomeKitCharacteristics();
271
271
  } catch (e: any) {
272
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
272
+ this.errorLog(`Color Bulb: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
273
273
  if (this.deviceLogging.includes('debug')) {
274
274
  this.errorLog(
275
- `${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` +
275
+ `Color Bulb: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` +
276
276
  ` Error Message: ${JSON.stringify(e.message)}`,
277
277
  );
278
278
  }
@@ -289,11 +289,6 @@ export class ColorBulb {
289
289
  * Color Bulb - "command" "setBrightness" "{1-100}" = set brightness
290
290
  * Color Bulb - "command" "setColor" "{0-255}:{0-255}:{0-255}" = set RGB color value
291
291
  * Color Bulb - "command" "setColorTemperature" "{2700-6500}" = set color temperature
292
- * Strip Light - "command" "turnOn" "default" = set to ON state |
293
- * Strip Light - "command" "turnOff" "default" = set to OFF state |
294
- * Strip Light - "command" "toggle" "default" = toggle state |
295
- * Strip Light - "command" "setBrightness" "`{1-100}`" = set brightness |
296
- * Strip Light - "command" "setColor" "`"{0-255}:{0-255}:{0-255}"`" = set RGB color value |
297
292
  *
298
293
  */
299
294
  async pushChanges(): Promise<void> {
@@ -312,13 +307,13 @@ export class ColorBulb {
312
307
  }
313
308
 
314
309
  this.infoLog(
315
- `${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
310
+ `Color Bulb: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
316
311
  ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`,
317
312
  );
318
313
 
319
314
  // Make the API request
320
315
  const push: any = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
321
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
316
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
322
317
  this.statusCode(push);
323
318
  this.OnCached = this.On;
324
319
  this.accessory.context.On = this.OnCached;
@@ -338,10 +333,10 @@ export class ColorBulb {
338
333
  await this.pushHueSaturationChanges();
339
334
  }
340
335
  } catch (e: any) {
341
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
336
+ this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
342
337
  if (this.deviceLogging.includes('debug')) {
343
338
  this.errorLog(
344
- `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
339
+ `Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
345
340
  ` Error Message: ${JSON.stringify(e.message)}`,
346
341
  );
347
342
  }
@@ -352,11 +347,11 @@ export class ColorBulb {
352
347
  async pushHueSaturationChanges(): Promise<void> {
353
348
  try {
354
349
  if (this.Hue !== this.HueCached || this.Saturation !== this.SaturationCached) {
355
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${JSON.stringify(this.Hue)}`);
356
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${JSON.stringify(this.Saturation)}`);
350
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Hue: ${JSON.stringify(this.Hue)}`);
351
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Saturation: ${JSON.stringify(this.Saturation)}`);
357
352
 
358
353
  const [red, green, blue] = hs2rgb(Number(this.Hue), Number(this.Saturation));
359
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} rgb: ${JSON.stringify([red, green, blue])}`);
354
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} rgb: ${JSON.stringify([red, green, blue])}`);
360
355
 
361
356
  const payload = {
362
357
  commandType: 'command',
@@ -365,27 +360,27 @@ export class ColorBulb {
365
360
  } as payload;
366
361
 
367
362
  this.infoLog(
368
- `${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
363
+ `Color Bulb: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
369
364
  ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`,
370
365
  );
371
366
 
372
367
  // Make the API request
373
368
  const push: any = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
374
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
369
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
375
370
  this.statusCode(push);
376
371
  this.HueCached = this.Hue;
377
372
  this.SaturationCached = this.Saturation;
378
373
  } else {
379
374
  this.debugLog(
380
- `${this.device.deviceType}: ${this.accessory.displayName} No Changes.` +
375
+ `Color Bulb: ${this.accessory.displayName} No Changes.` +
381
376
  `Hue: ${this.Hue}, HueCached: ${this.HueCached}, Saturation: ${this.Saturation}, SaturationCached: ${this.SaturationCached}`,
382
377
  );
383
378
  }
384
379
  } catch (e: any) {
385
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
380
+ this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
386
381
  if (this.deviceLogging.includes('debug')) {
387
382
  this.errorLog(
388
- `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
383
+ `Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
389
384
  ` Error Message: ${JSON.stringify(e.message)}`,
390
385
  );
391
386
  }
@@ -406,26 +401,26 @@ export class ColorBulb {
406
401
  } as payload;
407
402
 
408
403
  this.infoLog(
409
- `${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
404
+ `Color Bulb: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
410
405
  ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`,
411
406
  );
412
407
 
413
408
  // Make the API request
414
409
  const push: any = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
415
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
410
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
416
411
  this.statusCode(push);
417
412
  this.ColorTemperatureCached = this.ColorTemperature;
418
413
  } else {
419
414
  this.debugLog(
420
- `${this.device.deviceType}: ${this.accessory.displayName} No Changes.` +
415
+ `Color Bulb: ${this.accessory.displayName} No Changes.` +
421
416
  `ColorTemperature: ${this.ColorTemperature}, ColorTemperatureCached: ${this.ColorTemperatureCached}`,
422
417
  );
423
418
  }
424
419
  } catch (e: any) {
425
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
420
+ this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
426
421
  if (this.deviceLogging.includes('debug')) {
427
422
  this.errorLog(
428
- `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
423
+ `Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
429
424
  ` Error Message: ${JSON.stringify(e.message)}`,
430
425
  );
431
426
  }
@@ -443,26 +438,26 @@ export class ColorBulb {
443
438
  } as payload;
444
439
 
445
440
  this.infoLog(
446
- `${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
441
+ `Color Bulb: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
447
442
  ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`,
448
443
  );
449
444
 
450
445
  // Make the API request
451
446
  const push: any = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
452
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
447
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
453
448
  this.statusCode(push);
454
449
  this.BrightnessCached = this.Brightness;
455
450
  } else {
456
451
  this.debugLog(
457
- `${this.device.deviceType}: ${this.accessory.displayName} No Changes.` +
452
+ `Color Bulb: ${this.accessory.displayName} No Changes.` +
458
453
  `Brightness: ${this.Brightness}, BrightnessCached: ${this.BrightnessCached}`,
459
454
  );
460
455
  }
461
456
  } catch (e: any) {
462
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
457
+ this.errorLog(`Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
463
458
  if (this.deviceLogging.includes('debug')) {
464
459
  this.errorLog(
465
- `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
460
+ `Color Bulb: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
466
461
  ` Error Message: ${JSON.stringify(e.message)}`,
467
462
  );
468
463
  }
@@ -472,34 +467,34 @@ export class ColorBulb {
472
467
 
473
468
  async updateHomeKitCharacteristics(): Promise<void> {
474
469
  if (this.On === undefined) {
475
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
470
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} On: ${this.On}`);
476
471
  } else {
477
472
  this.lightBulbService.updateCharacteristic(this.platform.Characteristic.On, this.On);
478
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
473
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
479
474
  }
480
475
  if (this.Brightness === undefined) {
481
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Brightness: ${this.Brightness}`);
476
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Brightness: ${this.Brightness}`);
482
477
  } else {
483
478
  this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Brightness, this.Brightness);
484
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Brightness: ${this.Brightness}`);
479
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} updateCharacteristic Brightness: ${this.Brightness}`);
485
480
  }
486
481
  if (this.ColorTemperature === undefined) {
487
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ColorTemperature: ${this.ColorTemperature}`);
482
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} ColorTemperature: ${this.ColorTemperature}`);
488
483
  } else {
489
484
  this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, this.ColorTemperature);
490
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic ColorTemperature: ${this.ColorTemperature}`);
485
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} updateCharacteristic ColorTemperature: ${this.ColorTemperature}`);
491
486
  }
492
487
  if (this.Hue === undefined) {
493
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${this.Hue}`);
488
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Hue: ${this.Hue}`);
494
489
  } else {
495
490
  this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Hue, this.Hue);
496
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Hue: ${this.Hue}`);
491
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} updateCharacteristic Hue: ${this.Hue}`);
497
492
  }
498
493
  if (this.Saturation === undefined) {
499
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${this.Saturation}`);
494
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Saturation: ${this.Saturation}`);
500
495
  } else {
501
496
  this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Saturation, this.Saturation);
502
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Saturation: ${this.Saturation}`);
497
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} updateCharacteristic Saturation: ${this.Saturation}`);
503
498
  }
504
499
  }
505
500
 
@@ -515,36 +510,36 @@ export class ColorBulb {
515
510
  statusCode(push: AxiosResponse<{ statusCode: number }>): void {
516
511
  switch (push.data.statusCode) {
517
512
  case 151:
518
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Command not supported by this device type.`);
513
+ this.errorLog(`Color Bulb: ${this.accessory.displayName} Command not supported by this device type.`);
519
514
  break;
520
515
  case 152:
521
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device not found.`);
516
+ this.errorLog(`Color Bulb: ${this.accessory.displayName} Device not found.`);
522
517
  break;
523
518
  case 160:
524
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Command is not supported.`);
519
+ this.errorLog(`Color Bulb: ${this.accessory.displayName} Command is not supported.`);
525
520
  break;
526
521
  case 161:
527
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device is offline.`);
522
+ this.errorLog(`Color Bulb: ${this.accessory.displayName} Device is offline.`);
528
523
  this.offlineOff();
529
524
  break;
530
525
  case 171:
531
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} is offline. Hub: ${this.device.hubDeviceId}`);
526
+ this.errorLog(`Color Bulb: ${this.accessory.displayName} is offline. Hub: ${this.device.hubDeviceId}`);
532
527
  this.offlineOff();
533
528
  break;
534
529
  case 190:
535
530
  this.errorLog(
536
- `${this.device.deviceType}: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` +
531
+ `Color Bulb: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` +
537
532
  ` Or command: ${JSON.stringify(push.data)} format is invalid`,
538
533
  );
539
534
  break;
540
535
  case 100:
541
536
  if (this.platform.debugMode) {
542
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Command successfully sent.`);
537
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Command successfully sent.`);
543
538
  }
544
539
  break;
545
540
  default:
546
541
  if (this.platform.debugMode) {
547
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode.`);
542
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Unknown statusCode.`);
548
543
  }
549
544
  }
550
545
  }
@@ -560,7 +555,7 @@ export class ColorBulb {
560
555
  * Handle requests to set the value of the "On" characteristic
561
556
  */
562
557
  async OnSet(value: CharacteristicValue): Promise<void> {
563
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${value}`);
558
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} On: ${value}`);
564
559
 
565
560
  this.On = value;
566
561
  this.doColorBulbUpdate.next();
@@ -570,7 +565,7 @@ export class ColorBulb {
570
565
  * Handle requests to set the value of the "Brightness" characteristic
571
566
  */
572
567
  async BrightnessSet(value: CharacteristicValue): Promise<void> {
573
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Brightness: ${value}`);
568
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Brightness: ${value}`);
574
569
 
575
570
  this.Brightness = value;
576
571
  this.doColorBulbUpdate.next();
@@ -580,7 +575,7 @@ export class ColorBulb {
580
575
  * Handle requests to set the value of the "ColorTemperature" characteristic
581
576
  */
582
577
  async ColorTemperatureSet(value: CharacteristicValue): Promise<void> {
583
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ColorTemperature: ${value}`);
578
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} ColorTemperature: ${value}`);
584
579
 
585
580
  // Convert mired to kelvin to nearest 100 (SwitchBot seems to need this)
586
581
  const kelvin = Math.round(1000000 / Number(value) / 100) * 100;
@@ -605,7 +600,7 @@ export class ColorBulb {
605
600
  * Handle requests to set the value of the "Hue" characteristic
606
601
  */
607
602
  async HueSet(value: CharacteristicValue): Promise<void> {
608
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${value}`);
603
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Hue: ${value}`);
609
604
 
610
605
  this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, 140);
611
606
 
@@ -617,7 +612,7 @@ export class ColorBulb {
617
612
  * Handle requests to set the value of the "Saturation" characteristic
618
613
  */
619
614
  async SaturationSet(value: CharacteristicValue): Promise<void> {
620
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${value}`);
615
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Saturation: ${value}`);
621
616
 
622
617
  this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, 140);
623
618
 
@@ -625,16 +620,6 @@ export class ColorBulb {
625
620
  this.doColorBulbUpdate.next();
626
621
  }
627
622
 
628
- model(device: device & devicesConfig): string {
629
- let model: string;
630
- if (device.deviceType === 'Strip Light') {
631
- model = 'W1701100';
632
- } else {
633
- model = 'W1401400';
634
- }
635
- return model;
636
- }
637
-
638
623
  async config(device: device & devicesConfig): Promise<void> {
639
624
  let config = {};
640
625
  if (device.colorbulb) {
@@ -656,43 +641,43 @@ export class ColorBulb {
656
641
  config['offline'] = device.offline;
657
642
  }
658
643
  if (Object.entries(config).length !== 0) {
659
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
644
+ this.infoLog(`Color Bulb: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
660
645
  }
661
646
  }
662
647
 
663
648
  async refreshRate(device: device & devicesConfig): Promise<void> {
664
649
  if (device.refreshRate) {
665
650
  this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
666
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
651
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
667
652
  } else if (this.platform.config.options!.refreshRate) {
668
653
  this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
669
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
654
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
670
655
  }
671
656
  }
672
657
 
673
658
  async logs(device: device & devicesConfig): Promise<void> {
674
659
  if (this.platform.debugMode) {
675
660
  this.deviceLogging = this.accessory.context.logging = 'debugMode';
676
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
661
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
677
662
  } else if (device.logging) {
678
663
  this.deviceLogging = this.accessory.context.logging = device.logging;
679
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
664
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
680
665
  } else if (this.platform.config.options?.logging) {
681
666
  this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
682
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
667
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
683
668
  } else {
684
669
  this.deviceLogging = this.accessory.context.logging = 'standard';
685
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
670
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
686
671
  }
687
672
  }
688
673
 
689
674
  async adaptiveLighting(device: device & devicesConfig): Promise<void> {
690
675
  if (device.colorbulb?.adaptiveLightingShift) {
691
676
  this.adaptiveLightingShift = device.colorbulb.adaptiveLightingShift;
692
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} adaptiveLightingShift: ${this.adaptiveLightingShift}`);
677
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} adaptiveLightingShift: ${this.adaptiveLightingShift}`);
693
678
  } else {
694
679
  this.adaptiveLightingShift = 0;
695
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} adaptiveLightingShift: ${this.adaptiveLightingShift}`);
680
+ this.debugLog(`Color Bulb: ${this.accessory.displayName} adaptiveLightingShift: ${this.adaptiveLightingShift}`);
696
681
  }
697
682
  }
698
683