@switchbot/homebridge-switchbot 1.8.3-beta.0 → 1.10.1-beta.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 (122) hide show
  1. package/.eslintrc +14 -45
  2. package/.github/ISSUE_TEMPLATE/bug-report.yml +3 -3
  3. package/.github/ISSUE_TEMPLATE/feature-request.yml +2 -2
  4. package/.github/ISSUE_TEMPLATE/support-request.yml +3 -3
  5. package/.github/labeler.yml +1 -1
  6. package/.github/workflows/codeql-analysis.yml +29 -29
  7. package/.github/workflows/nodejs-beta.yml +1 -1
  8. package/.github/workflows/prerelease-beta.js +1 -1
  9. package/.github/workflows/stale.yml +1 -1
  10. package/.prettierrc +9 -0
  11. package/.vscode/extensions.json +2 -4
  12. package/.vscode/settings.json +14 -2
  13. package/CHANGELOG.md +16 -0
  14. package/README.md +100 -99
  15. package/SECURITY.md +2 -2
  16. package/config.schema.json +17 -0
  17. package/dist/devices/bots.d.ts +35 -32
  18. package/dist/devices/bots.d.ts.map +1 -1
  19. package/dist/devices/bots.js +168 -210
  20. package/dist/devices/bots.js.map +1 -1
  21. package/dist/devices/colorbulb.d.ts +35 -35
  22. package/dist/devices/colorbulb.d.ts.map +1 -1
  23. package/dist/devices/colorbulb.js +83 -108
  24. package/dist/devices/colorbulb.js.map +1 -1
  25. package/dist/devices/contact.d.ts +27 -25
  26. package/dist/devices/contact.d.ts.map +1 -1
  27. package/dist/devices/contact.js +110 -131
  28. package/dist/devices/contact.js.map +1 -1
  29. package/dist/devices/curtains.d.ts +29 -27
  30. package/dist/devices/curtains.d.ts.map +1 -1
  31. package/dist/devices/curtains.js +147 -182
  32. package/dist/devices/curtains.js.map +1 -1
  33. package/dist/devices/humidifiers.d.ts +31 -31
  34. package/dist/devices/humidifiers.d.ts.map +1 -1
  35. package/dist/devices/humidifiers.js +154 -181
  36. package/dist/devices/humidifiers.js.map +1 -1
  37. package/dist/devices/meters.d.ts +29 -28
  38. package/dist/devices/meters.d.ts.map +1 -1
  39. package/dist/devices/meters.js +98 -120
  40. package/dist/devices/meters.js.map +1 -1
  41. package/dist/devices/motion.d.ts +24 -23
  42. package/dist/devices/motion.d.ts.map +1 -1
  43. package/dist/devices/motion.js +97 -113
  44. package/dist/devices/motion.js.map +1 -1
  45. package/dist/devices/plugs.d.ts +16 -16
  46. package/dist/devices/plugs.d.ts.map +1 -1
  47. package/dist/devices/plugs.js +48 -71
  48. package/dist/devices/plugs.js.map +1 -1
  49. package/dist/index.d.ts +2 -2
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +3 -22
  52. package/dist/index.js.map +1 -1
  53. package/dist/irdevices/airconditioners.d.ts +7 -4
  54. package/dist/irdevices/airconditioners.d.ts.map +1 -1
  55. package/dist/irdevices/airconditioners.js +72 -93
  56. package/dist/irdevices/airconditioners.js.map +1 -1
  57. package/dist/irdevices/airpurifiers.d.ts +3 -3
  58. package/dist/irdevices/airpurifiers.d.ts.map +1 -1
  59. package/dist/irdevices/airpurifiers.js +32 -51
  60. package/dist/irdevices/airpurifiers.js.map +1 -1
  61. package/dist/irdevices/cameras.d.ts +3 -3
  62. package/dist/irdevices/cameras.d.ts.map +1 -1
  63. package/dist/irdevices/cameras.js +19 -26
  64. package/dist/irdevices/cameras.js.map +1 -1
  65. package/dist/irdevices/fans.d.ts +3 -3
  66. package/dist/irdevices/fans.d.ts.map +1 -1
  67. package/dist/irdevices/fans.js +35 -44
  68. package/dist/irdevices/fans.js.map +1 -1
  69. package/dist/irdevices/lights.d.ts +3 -3
  70. package/dist/irdevices/lights.d.ts.map +1 -1
  71. package/dist/irdevices/lights.js +25 -32
  72. package/dist/irdevices/lights.js.map +1 -1
  73. package/dist/irdevices/others.d.ts +3 -3
  74. package/dist/irdevices/others.d.ts.map +1 -1
  75. package/dist/irdevices/others.js +21 -29
  76. package/dist/irdevices/others.js.map +1 -1
  77. package/dist/irdevices/tvs.d.ts +3 -3
  78. package/dist/irdevices/tvs.d.ts.map +1 -1
  79. package/dist/irdevices/tvs.js +66 -89
  80. package/dist/irdevices/tvs.js.map +1 -1
  81. package/dist/irdevices/vacuumcleaners.d.ts +3 -3
  82. package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
  83. package/dist/irdevices/vacuumcleaners.js +18 -24
  84. package/dist/irdevices/vacuumcleaners.js.map +1 -1
  85. package/dist/irdevices/waterheaters.d.ts +3 -3
  86. package/dist/irdevices/waterheaters.d.ts.map +1 -1
  87. package/dist/irdevices/waterheaters.js +19 -26
  88. package/dist/irdevices/waterheaters.js.map +1 -1
  89. package/dist/platform.d.ts +10 -10
  90. package/dist/platform.d.ts.map +1 -1
  91. package/dist/platform.js +163 -233
  92. package/dist/platform.js.map +1 -1
  93. package/dist/settings.d.ts +3 -1
  94. package/dist/settings.d.ts.map +1 -1
  95. package/dist/settings.js +4 -4
  96. package/dist/settings.js.map +1 -1
  97. package/homebridge-ui/public/index.html +231 -245
  98. package/homebridge-ui/server.js +2 -4
  99. package/nodemon.json +2 -4
  100. package/package.json +17 -12
  101. package/src/devices/bots.ts +411 -854
  102. package/src/devices/colorbulb.ts +187 -408
  103. package/src/devices/contact.ts +210 -376
  104. package/src/devices/curtains.ts +288 -563
  105. package/src/devices/humidifiers.ts +291 -537
  106. package/src/devices/meters.ts +189 -331
  107. package/src/devices/motion.ts +188 -322
  108. package/src/devices/plugs.ts +88 -160
  109. package/src/index.ts +5 -5
  110. package/src/irdevices/airconditioners.ts +139 -318
  111. package/src/irdevices/airpurifiers.ts +71 -170
  112. package/src/irdevices/cameras.ts +44 -103
  113. package/src/irdevices/fans.ts +70 -165
  114. package/src/irdevices/lights.ts +49 -104
  115. package/src/irdevices/others.ts +55 -131
  116. package/src/irdevices/tvs.ts +114 -247
  117. package/src/irdevices/vacuumcleaners.ts +44 -104
  118. package/src/irdevices/waterheaters.ts +49 -121
  119. package/src/platform.ts +341 -753
  120. package/src/settings.ts +8 -11
  121. package/tsconfig.json +5 -14
  122. package/.github/PULL_REQUEST_TEMPLATE/pull_requests.md +0 -27
@@ -1,7 +1,7 @@
1
- import { AxiosResponse } from "axios";
2
- import { SwitchBotPlatform } from "../platform";
3
- import { irDevicesConfig, DeviceURL, irdevice, payload } from "../settings";
4
- import { CharacteristicValue, PlatformAccessory, Service } from "homebridge";
1
+ import { AxiosResponse } from 'axios';
2
+ import { SwitchBotPlatform } from '../platform';
3
+ import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
4
+ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
5
5
 
6
6
  /**
7
7
  * Platform Accessory
@@ -19,11 +19,7 @@ export class Light {
19
19
  // Config
20
20
  deviceLogging!: string;
21
21
 
22
- constructor(
23
- private readonly platform: SwitchBotPlatform,
24
- private accessory: PlatformAccessory,
25
- public device: irdevice & irDevicesConfig,
26
- ) {
22
+ constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
27
23
  // default placeholders
28
24
  this.logs(device);
29
25
  this.config(device);
@@ -36,18 +32,13 @@ export class Light {
36
32
  // set accessory information
37
33
  accessory
38
34
  .getService(this.platform.Service.AccessoryInformation)!
39
- .setCharacteristic(this.platform.Characteristic.Manufacturer, "SwitchBot")
35
+ .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
40
36
  .setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
41
- .setCharacteristic(
42
- this.platform.Characteristic.SerialNumber,
43
- device.deviceId!,
44
- );
37
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
45
38
 
46
39
  // get the Television service if it exists, otherwise create a new Television service
47
40
  // you can create multiple services for each accessory
48
- (this.service =
49
- accessory.getService(this.platform.Service.Lightbulb) ||
50
- accessory.addService(this.platform.Service.Lightbulb)),
41
+ (this.service = accessory.getService(this.platform.Service.Lightbulb) || accessory.addService(this.platform.Service.Lightbulb)),
51
42
  `${accessory.displayName} Light Bulb`;
52
43
 
53
44
  // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
@@ -56,15 +47,10 @@ export class Light {
56
47
 
57
48
  // set the service name, this is what is displayed as the default name on the Home app
58
49
  // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
59
- this.service.setCharacteristic(
60
- this.platform.Characteristic.Name,
61
- accessory.displayName,
62
- );
50
+ this.service.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
63
51
 
64
52
  // handle on / off events using the On characteristic
65
- this.service
66
- .getCharacteristic(this.platform.Characteristic.On)
67
- .onSet(this.OnSet.bind(this));
53
+ this.service.getCharacteristic(this.platform.Characteristic.On).onSet(this.OnSet.bind(this));
68
54
 
69
55
  // handle Brightness events using the Brightness characteristic
70
56
  /* this.service
@@ -96,13 +82,8 @@ export class Light {
96
82
  if (this.On === undefined) {
97
83
  this.debugLog(`Light: ${this.accessory.displayName} On: ${this.On}`);
98
84
  } else {
99
- this.service?.updateCharacteristic(
100
- this.platform.Characteristic.On,
101
- this.On,
102
- );
103
- this.debugLog(
104
- `Light: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`,
105
- );
85
+ this.service?.updateCharacteristic(this.platform.Characteristic.On, this.On);
86
+ this.debugLog(`Light: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
106
87
  }
107
88
  }
108
89
 
@@ -119,9 +100,9 @@ export class Light {
119
100
  async pushLightOnChanges() {
120
101
  if (this.On) {
121
102
  const payload = {
122
- commandType: "command",
123
- parameter: "default",
124
- command: "turnOn",
103
+ commandType: 'command',
104
+ parameter: 'default',
105
+ command: 'turnOn',
125
106
  } as payload;
126
107
  await this.pushChanges(payload);
127
108
  }
@@ -130,9 +111,9 @@ export class Light {
130
111
  async pushLightOffChanges() {
131
112
  if (!this.On) {
132
113
  const payload = {
133
- commandType: "command",
134
- parameter: "default",
135
- command: "turnOff",
114
+ commandType: 'command',
115
+ parameter: 'default',
116
+ command: 'turnOff',
136
117
  } as payload;
137
118
  await this.pushChanges(payload);
138
119
  }
@@ -140,18 +121,18 @@ export class Light {
140
121
 
141
122
  async pushLightBrightnessUpChanges() {
142
123
  const payload = {
143
- commandType: "command",
144
- parameter: "default",
145
- command: "brightnessUp",
124
+ commandType: 'command',
125
+ parameter: 'default',
126
+ command: 'brightnessUp',
146
127
  } as payload;
147
128
  await this.pushChanges(payload);
148
129
  }
149
130
 
150
131
  async pushLightBrightnessDownChanges() {
151
132
  const payload = {
152
- commandType: "command",
153
- parameter: "default",
154
- command: "brightnessDown",
133
+ commandType: 'command',
134
+ parameter: 'default',
135
+ command: 'brightnessDown',
155
136
  } as payload;
156
137
  await this.pushChanges(payload);
157
138
  }
@@ -164,32 +145,21 @@ export class Light {
164
145
  );
165
146
 
166
147
  // Make the API request
167
- const push = await this.platform.axios.post(
168
- `${DeviceURL}/${this.device.deviceId}/commands`,
169
- payload,
170
- );
171
- this.debugLog(
172
- `Light: ${this.accessory.displayName} pushChanges: ${push.data}`,
173
- );
148
+ const push = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
149
+ this.debugLog(`Light: ${this.accessory.displayName} pushChanges: ${push.data}`);
174
150
  this.statusCode(push);
175
151
  this.OnCached = this.On;
176
152
  this.accessory.context.On = this.OnCached;
177
153
  this.updateHomeKitCharacteristics();
178
154
  } catch (e: any) {
179
- this.errorLog(
180
- `Light: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`,
181
- );
182
- if (this.deviceLogging === "debug") {
155
+ this.errorLog(`Light: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
156
+ if (this.deviceLogging === 'debug') {
183
157
  this.errorLog(
184
- `Light: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
185
- ` Error Message: ${JSON.stringify(e.message)}`,
158
+ `Light: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
186
159
  );
187
160
  }
188
161
  if (this.platform.debugMode) {
189
- this.errorLog(
190
- `Light: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
191
- ` Error: ${JSON.stringify(e)}`,
192
- );
162
+ this.errorLog(`Light: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
193
163
  }
194
164
  this.apiError(e);
195
165
  }
@@ -198,45 +168,31 @@ export class Light {
198
168
  private statusCode(push: AxiosResponse<{ statusCode: number }>) {
199
169
  switch (push.data.statusCode) {
200
170
  case 151:
201
- this.errorLog(
202
- `Light: ${this.accessory.displayName} Command not supported by this device type.`,
203
- );
171
+ this.errorLog(`Light: ${this.accessory.displayName} Command not supported by this device type.`);
204
172
  break;
205
173
  case 152:
206
174
  this.errorLog(`Light: ${this.accessory.displayName} Device not found.`);
207
175
  break;
208
176
  case 160:
209
- this.errorLog(
210
- `Light: ${this.accessory.displayName} Command is not supported.`,
211
- );
177
+ this.errorLog(`Light: ${this.accessory.displayName} Command is not supported.`);
212
178
  break;
213
179
  case 161:
214
- this.errorLog(
215
- `Light: ${this.accessory.displayName} Device is offline.`,
216
- );
180
+ this.errorLog(`Light: ${this.accessory.displayName} Device is offline.`);
217
181
  break;
218
182
  case 171:
219
- this.errorLog(
220
- `Light: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`,
221
- );
183
+ this.errorLog(`Light: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
222
184
  break;
223
185
  case 190:
224
186
  this.errorLog(
225
187
  `Light: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
226
- ` with server, Or command: ${JSON.stringify(
227
- push.data,
228
- )} format is invalid`,
188
+ ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`,
229
189
  );
230
190
  break;
231
191
  case 100:
232
- this.debugLog(
233
- `Light: ${this.accessory.displayName} Command successfully sent.`,
234
- );
192
+ this.debugLog(`Light: ${this.accessory.displayName} Command successfully sent.`);
235
193
  break;
236
194
  default:
237
- this.debugLog(
238
- `Light: ${this.accessory.displayName} Unknown statusCode.`,
239
- );
195
+ this.debugLog(`Light: ${this.accessory.displayName} Unknown statusCode.`);
240
196
  }
241
197
  }
242
198
 
@@ -251,37 +207,26 @@ export class Light {
251
207
  config = device.irlight;
252
208
  }
253
209
  if (device.logging !== undefined) {
254
- config["logging"] = device.logging;
210
+ config['logging'] = device.logging;
255
211
  }
256
212
  if (Object.entries(config).length !== 0) {
257
- this.warnLog(
258
- `Light: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`,
259
- );
213
+ this.warnLog(`Light: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
260
214
  }
261
215
  }
262
216
 
263
217
  logs(device: irdevice & irDevicesConfig) {
264
218
  if (this.platform.debugMode) {
265
- this.deviceLogging = this.accessory.context.logging = "debugMode";
266
- this.debugLog(
267
- `Light: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`,
268
- );
219
+ this.deviceLogging = this.accessory.context.logging = 'debugMode';
220
+ this.debugLog(`Light: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
269
221
  } else if (device.logging) {
270
222
  this.deviceLogging = this.accessory.context.logging = device.logging;
271
- this.debugLog(
272
- `Light: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`,
273
- );
223
+ this.debugLog(`Light: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
274
224
  } else if (this.platform.config.options?.logging) {
275
- this.deviceLogging = this.accessory.context.logging =
276
- this.platform.config.options?.logging;
277
- this.debugLog(
278
- `Light: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`,
279
- );
225
+ this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
226
+ this.debugLog(`Light: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
280
227
  } else {
281
- this.deviceLogging = this.accessory.context.logging = "standard";
282
- this.debugLog(
283
- `Light: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`,
284
- );
228
+ this.deviceLogging = this.accessory.context.logging = 'standard';
229
+ this.debugLog(`Light: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
285
230
  }
286
231
  }
287
232
 
@@ -308,8 +253,8 @@ export class Light {
308
253
 
309
254
  debugLog(...log: any[]) {
310
255
  if (this.enablingDeviceLogging()) {
311
- if (this.deviceLogging === "debug") {
312
- this.platform.log.info("[DEBUG]", String(...log));
256
+ if (this.deviceLogging === 'debug') {
257
+ this.platform.log.info('[DEBUG]', String(...log));
313
258
  } else {
314
259
  this.platform.log.debug(String(...log));
315
260
  }
@@ -317,6 +262,6 @@ export class Light {
317
262
  }
318
263
 
319
264
  enablingDeviceLogging(): boolean {
320
- return this.deviceLogging.includes("debug") || this.deviceLogging === "standard";
265
+ return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
321
266
  }
322
267
  }
@@ -1,7 +1,7 @@
1
- import { AxiosResponse } from "axios";
2
- import { SwitchBotPlatform } from "../platform";
3
- import { irDevicesConfig, DeviceURL, irdevice, payload } from "../settings";
4
- import { CharacteristicValue, PlatformAccessory, Service } from "homebridge";
1
+ import { AxiosResponse } from 'axios';
2
+ import { SwitchBotPlatform } from '../platform';
3
+ import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
4
+ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
5
5
 
6
6
  /**
7
7
  * Platform Accessory
@@ -20,11 +20,7 @@ export class Others {
20
20
  deviceLogging!: string;
21
21
  otherDeviceType?: string;
22
22
 
23
- constructor(
24
- private readonly platform: SwitchBotPlatform,
25
- private accessory: PlatformAccessory,
26
- public device: irdevice & irDevicesConfig,
27
- ) {
23
+ constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
28
24
  // default placeholders
29
25
  this.logs(device);
30
26
  this.deviceType(device);
@@ -38,44 +34,30 @@ export class Others {
38
34
  // set accessory information
39
35
  accessory
40
36
  .getService(this.platform.Service.AccessoryInformation)!
41
- .setCharacteristic(this.platform.Characteristic.Manufacturer, "SwitchBot")
37
+ .setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
42
38
  .setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
43
- .setCharacteristic(
44
- this.platform.Characteristic.SerialNumber,
45
- device.deviceId!,
46
- );
39
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
47
40
 
48
41
  // get the Television service if it exists, otherwise create a new Television service
49
42
  // you can create multiple services for each accessory
50
- if (this.otherDeviceType !== "Fan") {
43
+ if (this.otherDeviceType !== 'Fan') {
51
44
  this.debugLog(`Other: ${accessory.displayName} Removing Fanv2 Service`);
52
45
 
53
46
  if (this.otherDeviceType === undefined) {
54
- this.errorLog(
55
- `Other: ${this.accessory.displayName} No Device Type Set, deviceType: ${device.other?.deviceType}`,
56
- );
47
+ this.errorLog(`Other: ${this.accessory.displayName} No Device Type Set, deviceType: ${device.other?.deviceType}`);
57
48
  }
58
49
  this.service = this.accessory.getService(this.platform.Service.Fanv2);
59
50
  accessory.removeService(this.service!);
60
- } else if (!this.service && this.otherDeviceType === "Fan") {
51
+ } else if (!this.service && this.otherDeviceType === 'Fan') {
61
52
  this.debugLog(`Other: ${accessory.displayName} Add Fanv2 Service`);
62
- (this.service =
63
- this.accessory.getService(this.platform.Service.Fanv2) ||
64
- this.accessory.addService(this.platform.Service.Fanv2)),
53
+ (this.service = this.accessory.getService(this.platform.Service.Fanv2) || this.accessory.addService(this.platform.Service.Fanv2)),
65
54
  `${accessory.displayName} Fan`;
66
55
 
67
- this.service.setCharacteristic(
68
- this.platform.Characteristic.Name,
69
- `${accessory.displayName} Fan`,
70
- );
56
+ this.service.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Fan`);
71
57
 
72
- this.service
73
- .getCharacteristic(this.platform.Characteristic.Active)
74
- .onSet(this.ActiveSet.bind(this));
58
+ this.service.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
75
59
  } else {
76
- this.debugLog(
77
- `Other: ${accessory.displayName} Fanv2 Service Not Added, deviceType: ${device.other?.deviceType}`,
78
- );
60
+ this.debugLog(`Other: ${accessory.displayName} Fanv2 Service Not Added, deviceType: ${device.other?.deviceType}`);
79
61
  }
80
62
  }
81
63
 
@@ -93,17 +75,10 @@ export class Others {
93
75
 
94
76
  private updateHomeKitCharacteristics() {
95
77
  if (this.Active === undefined) {
96
- this.debugLog(
97
- `Other: ${this.accessory.displayName} Active: ${this.Active}`,
98
- );
78
+ this.debugLog(`Other: ${this.accessory.displayName} Active: ${this.Active}`);
99
79
  } else {
100
- this.service?.updateCharacteristic(
101
- this.platform.Characteristic.Active,
102
- this.Active,
103
- );
104
- this.debugLog(
105
- `Other: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`,
106
- );
80
+ this.service?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
81
+ this.debugLog(`Other: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
107
82
  }
108
83
  }
109
84
 
@@ -123,21 +98,17 @@ export class Others {
123
98
  if (this.device.other.commandOn) {
124
99
  if (this.Active) {
125
100
  const payload = {
126
- commandType: "customize",
127
- parameter: "default",
101
+ commandType: 'customize',
102
+ parameter: 'default',
128
103
  command: `${this.device.other.commandOn}`,
129
104
  } as payload;
130
105
  await this.pushChanges(payload);
131
106
  }
132
107
  } else {
133
- this.errorLog(
134
- `Other: ${this.accessory.displayName} On Command not set, commandOn: ${this.device.other.commandOn}`,
135
- );
108
+ this.errorLog(`Other: ${this.accessory.displayName} On Command not set, commandOn: ${this.device.other.commandOn}`);
136
109
  }
137
110
  } else {
138
- this.errorLog(
139
- `Other: ${this.accessory.displayName} On Command not set, other: ${this.device.other}`,
140
- );
111
+ this.errorLog(`Other: ${this.accessory.displayName} On Command not set, other: ${this.device.other}`);
141
112
  }
142
113
  } else {
143
114
  this.errorLog(`Other: ${this.accessory.displayName} On Command not set`);
@@ -150,26 +121,20 @@ export class Others {
150
121
  if (this.device.other.commandOff) {
151
122
  if (!this.Active) {
152
123
  const payload = {
153
- commandType: "customize",
154
- parameter: "default",
124
+ commandType: 'customize',
125
+ parameter: 'default',
155
126
  command: `${this.device.other.commandOff}`,
156
127
  } as payload;
157
128
  await this.pushChanges(payload);
158
129
  }
159
130
  } else {
160
- this.errorLog(
161
- `Other: ${this.accessory.displayName} Off Command not set, commandOff: ${this.device.other.commandOff}`,
162
- );
131
+ this.errorLog(`Other: ${this.accessory.displayName} Off Command not set, commandOff: ${this.device.other.commandOff}`);
163
132
  }
164
133
  } else {
165
- this.errorLog(
166
- `Other: ${this.accessory.displayName} Off Command not set, other: ${this.device.other}`,
167
- );
134
+ this.errorLog(`Other: ${this.accessory.displayName} Off Command not set, other: ${this.device.other}`);
168
135
  }
169
136
  } else {
170
- this.errorLog(
171
- `Other: ${this.accessory.displayName} Off Command not set.`,
172
- );
137
+ this.errorLog(`Other: ${this.accessory.displayName} Off Command not set.`);
173
138
  }
174
139
  }
175
140
 
@@ -181,30 +146,19 @@ export class Others {
181
146
  );
182
147
 
183
148
  // Make the API request
184
- const push = await this.platform.axios.post(
185
- `${DeviceURL}/${this.device.deviceId}/commands`,
186
- payload,
187
- );
188
- this.debugLog(
189
- `Other: ${this.accessory.displayName} pushChanges: ${push.data}`,
190
- );
149
+ const push = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
150
+ this.debugLog(`Other: ${this.accessory.displayName} pushChanges: ${push.data}`);
191
151
  this.statusCode(push);
192
152
  this.updateHomeKitCharacteristics();
193
153
  } catch (e: any) {
194
- this.errorLog(
195
- `Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`,
196
- );
197
- if (this.deviceLogging === "debug") {
154
+ this.errorLog(`Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
155
+ if (this.deviceLogging === 'debug') {
198
156
  this.errorLog(
199
- `Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
200
- ` Error Message: ${JSON.stringify(e.message)}`,
157
+ `Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
201
158
  );
202
159
  }
203
160
  if (this.platform.debugMode) {
204
- this.errorLog(
205
- `Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
206
- ` Error: ${JSON.stringify(e)}`,
207
- );
161
+ this.errorLog(`Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
208
162
  }
209
163
  this.apiError(e);
210
164
  }
@@ -213,45 +167,31 @@ export class Others {
213
167
  private statusCode(push: AxiosResponse<{ statusCode: number }>) {
214
168
  switch (push.data.statusCode) {
215
169
  case 151:
216
- this.errorLog(
217
- `Other: ${this.accessory.displayName} Command not supported by this device type.`,
218
- );
170
+ this.errorLog(`Other: ${this.accessory.displayName} Command not supported by this device type.`);
219
171
  break;
220
172
  case 152:
221
173
  this.errorLog(`Other: ${this.accessory.displayName} Device not found.`);
222
174
  break;
223
175
  case 160:
224
- this.errorLog(
225
- `Other: ${this.accessory.displayName} Command is not supported.`,
226
- );
176
+ this.errorLog(`Other: ${this.accessory.displayName} Command is not supported.`);
227
177
  break;
228
178
  case 161:
229
- this.errorLog(
230
- `Other: ${this.accessory.displayName} Device is offline.`,
231
- );
179
+ this.errorLog(`Other: ${this.accessory.displayName} Device is offline.`);
232
180
  break;
233
181
  case 171:
234
- this.errorLog(
235
- `Other: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`,
236
- );
182
+ this.errorLog(`Other: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
237
183
  break;
238
184
  case 190:
239
185
  this.errorLog(
240
186
  `Other: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
241
- ` with server, Or command: ${JSON.stringify(
242
- push.data,
243
- )} format is invalid`,
187
+ ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`,
244
188
  );
245
189
  break;
246
190
  case 100:
247
- this.debugLog(
248
- `Other: ${this.accessory.displayName} Command successfully sent.`,
249
- );
191
+ this.debugLog(`Other: ${this.accessory.displayName} Command successfully sent.`);
250
192
  break;
251
193
  default:
252
- this.debugLog(
253
- `Other: ${this.accessory.displayName} Unknown statusCode.`,
254
- );
194
+ this.debugLog(`Other: ${this.accessory.displayName} Unknown statusCode.`);
255
195
  }
256
196
  }
257
197
 
@@ -262,17 +202,12 @@ export class Others {
262
202
 
263
203
  deviceType(device: irdevice & irDevicesConfig) {
264
204
  if (device.other?.deviceType) {
265
- this.otherDeviceType = this.accessory.context.deviceType =
266
- device.other.deviceType;
267
- if (this.deviceLogging === "debug" || this.deviceLogging === "standard") {
268
- this.warnLog(
269
- `Other: ${this.accessory.displayName} Using Device Type: ${this.otherDeviceType}`,
270
- );
205
+ this.otherDeviceType = this.accessory.context.deviceType = device.other.deviceType;
206
+ if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
207
+ this.warnLog(`Other: ${this.accessory.displayName} Using Device Type: ${this.otherDeviceType}`);
271
208
  }
272
209
  } else {
273
- this.errorLog(
274
- `Other: ${this.accessory.displayName} No Device Type Set, deviceType: ${this.device.other?.deviceType}`,
275
- );
210
+ this.errorLog(`Other: ${this.accessory.displayName} No Device Type Set, deviceType: ${this.device.other?.deviceType}`);
276
211
  }
277
212
  }
278
213
 
@@ -282,37 +217,26 @@ export class Others {
282
217
  config = device.other;
283
218
  }
284
219
  if (device.logging !== undefined) {
285
- config["logging"] = device.logging;
220
+ config['logging'] = device.logging;
286
221
  }
287
222
  if (Object.entries(config).length !== 0) {
288
- this.warnLog(
289
- `Other: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`,
290
- );
223
+ this.warnLog(`Other: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
291
224
  }
292
225
  }
293
226
 
294
227
  logs(device: irdevice & irDevicesConfig) {
295
228
  if (this.platform.debugMode) {
296
- this.deviceLogging = this.accessory.context.logging = "debugMode";
297
- this.debugLog(
298
- `Other: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`,
299
- );
229
+ this.deviceLogging = this.accessory.context.logging = 'debugMode';
230
+ this.debugLog(`Other: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
300
231
  } else if (device.logging) {
301
232
  this.deviceLogging = this.accessory.context.logging = device.logging;
302
- this.debugLog(
303
- `Other: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`,
304
- );
233
+ this.debugLog(`Other: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
305
234
  } else if (this.platform.config.options?.logging) {
306
- this.deviceLogging = this.accessory.context.logging =
307
- this.platform.config.options?.logging;
308
- this.debugLog(
309
- `Other: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`,
310
- );
235
+ this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
236
+ this.debugLog(`Other: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
311
237
  } else {
312
- this.deviceLogging = this.accessory.context.logging = "standard";
313
- this.debugLog(
314
- `Other: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`,
315
- );
238
+ this.deviceLogging = this.accessory.context.logging = 'standard';
239
+ this.debugLog(`Other: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
316
240
  }
317
241
  }
318
242
 
@@ -339,8 +263,8 @@ export class Others {
339
263
 
340
264
  debugLog(...log: any[]) {
341
265
  if (this.enablingDeviceLogging()) {
342
- if (this.deviceLogging === "debug") {
343
- this.platform.log.info("[DEBUG]", String(...log));
266
+ if (this.deviceLogging === 'debug') {
267
+ this.platform.log.info('[DEBUG]', String(...log));
344
268
  } else {
345
269
  this.platform.log.debug(String(...log));
346
270
  }
@@ -348,6 +272,6 @@ export class Others {
348
272
  }
349
273
 
350
274
  enablingDeviceLogging(): boolean {
351
- return this.deviceLogging.includes("debug") || this.deviceLogging === "standard";
275
+ return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
352
276
  }
353
277
  }