@switchbot/homebridge-switchbot 3.5.1-beta.10 → 3.5.1-beta.11
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.
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +3 -4
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.js +1 -1
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +45 -51
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +17 -17
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +9 -9
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +19 -19
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +22 -10
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js +89 -67
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +15 -17
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +76 -76
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +35 -35
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +9 -9
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +9 -9
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +202 -201
- package/dist/platform.js.map +1 -1
- package/package.json +1 -1
- package/src/device/ceilinglight.ts +3 -6
- package/src/device/colorbulb.ts +1 -1
- package/src/irdevice/airconditioner.ts +45 -51
- package/src/irdevice/airpurifier.ts +17 -17
- package/src/irdevice/camera.ts +9 -9
- package/src/irdevice/fan.ts +19 -19
- package/src/irdevice/irdevice.ts +92 -68
- package/src/irdevice/light.ts +15 -17
- package/src/irdevice/other.ts +76 -76
- package/src/irdevice/tv.ts +35 -35
- package/src/irdevice/vacuumcleaner.ts +9 -9
- package/src/irdevice/waterheater.ts +9 -9
- package/src/platform.ts +202 -201
package/src/irdevice/irdevice.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { request } from 'undici';
|
|
|
6
6
|
import { Devices } from '../settings.js';
|
|
7
7
|
|
|
8
8
|
import type { SwitchBotPlatform } from '../platform.js';
|
|
9
|
-
import type { API, HAP, Logging, PlatformAccessory } from 'homebridge';
|
|
9
|
+
import type { API, HAP, Logging, PlatformAccessory, Service, CharacteristicValue } from 'homebridge';
|
|
10
10
|
import type { SwitchBotPlatformConfig, irDevicesConfig } from '../settings.js';
|
|
11
11
|
import type { irdevice } from '../types/irdevicelist.js';
|
|
12
12
|
|
|
@@ -53,16 +53,16 @@ export abstract class irdeviceBase {
|
|
|
53
53
|
async getDeviceLogSettings(device: irdevice & irDevicesConfig): Promise<void> {
|
|
54
54
|
if (this.platform.debugMode) {
|
|
55
55
|
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
56
|
-
this.debugWarnLog(
|
|
56
|
+
await this.debugWarnLog(`Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
57
57
|
} else if (device.logging) {
|
|
58
58
|
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
59
|
-
this.debugWarnLog(
|
|
59
|
+
await this.debugWarnLog(`Using Device Config Logging: ${this.deviceLogging}`);
|
|
60
60
|
} else if (this.config.logging) {
|
|
61
61
|
this.deviceLogging = this.accessory.context.logging = this.config.logging;
|
|
62
|
-
this.debugWarnLog(
|
|
62
|
+
await this.debugWarnLog(`Using Platform Config Logging: ${this.deviceLogging}`);
|
|
63
63
|
} else {
|
|
64
64
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
65
|
-
this.debugWarnLog(
|
|
65
|
+
await this.debugWarnLog(`Logging Not Set, Using: ${this.deviceLogging}`);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -137,7 +137,7 @@ export abstract class irdeviceBase {
|
|
|
137
137
|
const config = Object.assign({}, deviceConfig, irairConfig, irpurConfig, ircamConfig, irfanConfig, irlightConfig, otherConfig,
|
|
138
138
|
irtvConfig, irvcConfig, irwhConfig);
|
|
139
139
|
if (Object.entries(config).length !== 0) {
|
|
140
|
-
this.debugSuccessLog(
|
|
140
|
+
this.debugSuccessLog(`Config: ${JSON.stringify(config)}`);
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
|
|
@@ -172,7 +172,7 @@ export abstract class irdeviceBase {
|
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
const version = deviceFirmwareVersion.toString();
|
|
175
|
-
this.debugLog(`${this.device.remoteType}: ${accessory.displayName} Firmware Version: ${version?.replace(/^V|-.*$/g, '')}`);
|
|
175
|
+
await this.debugLog(`${this.device.remoteType}: ${accessory.displayName} Firmware Version: ${version?.replace(/^V|-.*$/g, '')}`);
|
|
176
176
|
let deviceVersion: string;
|
|
177
177
|
if (version?.includes('.') === false) {
|
|
178
178
|
const replace = version?.replace(/^V|-.*$/g, '');
|
|
@@ -201,21 +201,48 @@ export abstract class irdeviceBase {
|
|
|
201
201
|
});
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
async successfulStatusCodes(statusCode: any, deviceStatus: any) {
|
|
205
|
+
return (statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Update the characteristic value and log the change.
|
|
210
|
+
*
|
|
211
|
+
* @param Service: Service
|
|
212
|
+
* @param Characteristic: Characteristic
|
|
213
|
+
* @param CharacteristicValue: CharacteristicValue | undefined
|
|
214
|
+
* @param CharacteristicName: string
|
|
215
|
+
* @return: void
|
|
216
|
+
*
|
|
217
|
+
*/
|
|
218
|
+
async updateCharacteristic(Service: Service, Characteristic: any,
|
|
219
|
+
CharacteristicValue: CharacteristicValue | undefined, CharacteristicName: string): Promise<void> {
|
|
220
|
+
if (CharacteristicValue === undefined) {
|
|
221
|
+
await await this.debugLog(`${CharacteristicName}: ${CharacteristicValue}`);
|
|
222
|
+
} else {
|
|
223
|
+
Service.updateCharacteristic(Characteristic, CharacteristicValue);
|
|
224
|
+
await await this.debugLog(`updateCharacteristic ${CharacteristicName}: ${CharacteristicValue}`);
|
|
225
|
+
await await this.debugWarnLog(`context before: ${this.accessory.context[CharacteristicName]}`);
|
|
226
|
+
this.accessory.context[CharacteristicName] = CharacteristicValue;
|
|
227
|
+
await await this.debugWarnLog(`context after: ${this.accessory.context[CharacteristicName]}`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
204
231
|
async pushStatusCodes(statusCode: any, deviceStatus: any) {
|
|
205
|
-
this.debugWarnLog(
|
|
206
|
-
this.debugWarnLog(
|
|
207
|
-
this.debugWarnLog(
|
|
232
|
+
await this.debugWarnLog(`statusCode: ${statusCode}`);
|
|
233
|
+
await this.debugWarnLog(`deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
234
|
+
await this.debugWarnLog(`deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
208
235
|
}
|
|
209
236
|
|
|
210
237
|
async successfulPushChange(statusCode: any, deviceStatus: any, bodyChange: any) {
|
|
211
|
-
this.debugSuccessLog(
|
|
238
|
+
this.debugSuccessLog(`statusCode: ${statusCode} & deviceStatus `
|
|
212
239
|
+ `StatusCode: ${deviceStatus.statusCode}`);
|
|
213
|
-
this.successLog(
|
|
240
|
+
this.successLog('request to SwitchBot API,'
|
|
214
241
|
+ ` body: ${JSON.stringify(JSON.parse(bodyChange))} sent successfully`);
|
|
215
242
|
}
|
|
216
243
|
|
|
217
244
|
async pushChangeError(e: Error) {
|
|
218
|
-
this.errorLog(
|
|
245
|
+
this.errorLog(`failed pushChanges with ${this.device.connectionType}`
|
|
219
246
|
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
220
247
|
}
|
|
221
248
|
|
|
@@ -278,69 +305,66 @@ export abstract class irdeviceBase {
|
|
|
278
305
|
async statusCode(statusCode: number): Promise<void> {
|
|
279
306
|
switch (statusCode) {
|
|
280
307
|
case 151:
|
|
281
|
-
this.errorLog(
|
|
308
|
+
this.errorLog(`Command not supported by this deviceType, statusCode: ${statusCode}`);
|
|
282
309
|
break;
|
|
283
310
|
case 152:
|
|
284
|
-
this.errorLog(
|
|
311
|
+
this.errorLog(`Device not found, statusCode: ${statusCode}`);
|
|
285
312
|
break;
|
|
286
313
|
case 160:
|
|
287
|
-
this.errorLog(
|
|
314
|
+
this.errorLog(`Command is not supported, statusCode: ${statusCode}`);
|
|
288
315
|
break;
|
|
289
316
|
case 161:
|
|
290
|
-
this.errorLog(
|
|
317
|
+
this.errorLog(`Device is offline, statusCode: ${statusCode}`);
|
|
291
318
|
break;
|
|
292
319
|
case 171:
|
|
293
|
-
this.errorLog(
|
|
294
|
-
+ `Hub: ${this.device.hubDeviceId}`);
|
|
320
|
+
this.errorLog(`Hub Device is offline, statusCode: ${statusCode}. Hub: ${this.device.hubDeviceId}`);
|
|
295
321
|
break;
|
|
296
322
|
case 190:
|
|
297
|
-
this.errorLog(
|
|
298
|
-
+ `
|
|
323
|
+
this.errorLog('Device internal error due to device states not synchronized with server, Or command format is invalid,'
|
|
324
|
+
+ ` statusCode: ${statusCode}`);
|
|
299
325
|
break;
|
|
300
326
|
case 100:
|
|
301
|
-
this.debugLog(
|
|
327
|
+
await this.debugLog(`Command successfully sent, statusCode: ${statusCode}`);
|
|
302
328
|
break;
|
|
303
329
|
case 200:
|
|
304
|
-
this.debugLog(
|
|
330
|
+
await this.debugLog(`Request successful, statusCode: ${statusCode}`);
|
|
305
331
|
break;
|
|
306
332
|
case 400:
|
|
307
|
-
this.errorLog(
|
|
308
|
-
+ `
|
|
333
|
+
this.errorLog('Bad Request, The client has issued an invalid request. This is commonly used to specify validation errors in a request'
|
|
334
|
+
+ ` payload, statusCode: ${statusCode}`);
|
|
309
335
|
break;
|
|
310
336
|
case 401:
|
|
311
|
-
this.errorLog(
|
|
312
|
-
+ `but the request has not been authenticated, statusCode: ${statusCode}`);
|
|
337
|
+
this.errorLog(`Unauthorized, Authorization for the API is required, but the request has not been authenticated, statusCode: ${statusCode}`);
|
|
313
338
|
break;
|
|
314
339
|
case 403:
|
|
315
|
-
this.errorLog(
|
|
316
|
-
+ `
|
|
340
|
+
this.errorLog('Forbidden, The request has been authenticated but does not have appropriate permissions, or a requested resource is not'
|
|
341
|
+
+ ` found, statusCode: ${statusCode}`);
|
|
317
342
|
break;
|
|
318
343
|
case 404:
|
|
319
|
-
this.errorLog(
|
|
320
|
-
+ `statusCode: ${statusCode}`);
|
|
344
|
+
this.errorLog(`Not Found, Specifies the requested path does not exist, statusCode: ${statusCode}`);
|
|
321
345
|
break;
|
|
322
346
|
case 406:
|
|
323
|
-
this.errorLog(
|
|
324
|
-
+ `
|
|
347
|
+
this.errorLog('Not Acceptable, The client has requested a MIME type via the Accept header for a value not supported by the server,'
|
|
348
|
+
+ ` statusCode: ${statusCode}`);
|
|
325
349
|
break;
|
|
326
350
|
case 415:
|
|
327
|
-
this.errorLog(
|
|
328
|
-
+ `
|
|
351
|
+
this.errorLog('Unsupported Media Type, The client has defined a contentType header that is not supported by the server,'
|
|
352
|
+
+ ` statusCode: ${statusCode}`);
|
|
329
353
|
break;
|
|
330
354
|
case 422:
|
|
331
|
-
this.errorLog(
|
|
332
|
-
+ `
|
|
355
|
+
this.errorLog('Unprocessable Entity, The client has made a valid request, but the server cannot process it. This is often used for APIs'
|
|
356
|
+
+ ` for which certain limits have been exceeded, statusCode: ${statusCode}`);
|
|
333
357
|
break;
|
|
334
358
|
case 429:
|
|
335
|
-
this.errorLog(
|
|
336
|
-
+ `
|
|
359
|
+
this.errorLog('Too Many Requests, The client has exceeded the number of requests allowed for a given time window,'
|
|
360
|
+
+ ` statusCode: ${statusCode}`);
|
|
337
361
|
break;
|
|
338
362
|
case 500:
|
|
339
|
-
this.errorLog(
|
|
340
|
-
+ `
|
|
363
|
+
this.errorLog('Internal Server Error, An unexpected error on the SmartThings servers has occurred. These errors should be rare,'
|
|
364
|
+
+ ` statusCode: ${statusCode}`);
|
|
341
365
|
break;
|
|
342
366
|
default:
|
|
343
|
-
this.infoLog(
|
|
367
|
+
this.infoLog('Unknown statusCode: '
|
|
344
368
|
+ `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
|
|
345
369
|
}
|
|
346
370
|
}
|
|
@@ -348,65 +372,65 @@ export abstract class irdeviceBase {
|
|
|
348
372
|
/**
|
|
349
373
|
* Logging for Device
|
|
350
374
|
*/
|
|
351
|
-
infoLog(...log: any[]): void {
|
|
352
|
-
if (this.enablingDeviceLogging()) {
|
|
353
|
-
this.log.info(String(...log));
|
|
375
|
+
async infoLog(...log: any[]): Promise<void> {
|
|
376
|
+
if (await this.enablingDeviceLogging()) {
|
|
377
|
+
this.log.info(`${this.device.remoteType}: ${this.accessory.displayName}`, String(...log));
|
|
354
378
|
}
|
|
355
379
|
}
|
|
356
380
|
|
|
357
|
-
successLog(...log: any[]): void {
|
|
358
|
-
if (this.enablingDeviceLogging()) {
|
|
359
|
-
this.
|
|
381
|
+
async successLog(...log: any[]): Promise<void> {
|
|
382
|
+
if (await this.enablingDeviceLogging()) {
|
|
383
|
+
this.log.success(`${this.device.remoteType}: ${this.accessory.displayName}`, String(...log));
|
|
360
384
|
}
|
|
361
385
|
}
|
|
362
386
|
|
|
363
|
-
debugSuccessLog(...log: any[]): void {
|
|
364
|
-
if (this.enablingDeviceLogging()) {
|
|
387
|
+
async debugSuccessLog(...log: any[]): Promise<void> {
|
|
388
|
+
if (await this.enablingDeviceLogging()) {
|
|
365
389
|
if (this.deviceLogging?.includes('debug')) {
|
|
366
|
-
this.log.success(
|
|
390
|
+
this.log.success(`[DEBUG] ${this.device.remoteType}: ${this.accessory.displayName}`, String(...log));
|
|
367
391
|
}
|
|
368
392
|
}
|
|
369
393
|
}
|
|
370
394
|
|
|
371
|
-
warnLog(...log: any[]): void {
|
|
372
|
-
if (this.enablingDeviceLogging()) {
|
|
373
|
-
this.log.warn(String(...log));
|
|
395
|
+
async warnLog(...log: any[]): Promise<void> {
|
|
396
|
+
if (await this.enablingDeviceLogging()) {
|
|
397
|
+
this.log.warn(`${this.device.remoteType}: ${this.accessory.displayName}`, String(...log));
|
|
374
398
|
}
|
|
375
399
|
}
|
|
376
400
|
|
|
377
|
-
debugWarnLog(...log: any[]): void {
|
|
378
|
-
if (this.enablingDeviceLogging()) {
|
|
401
|
+
async debugWarnLog(...log: any[]): Promise<void> {
|
|
402
|
+
if (await this.enablingDeviceLogging()) {
|
|
379
403
|
if (this.deviceLogging?.includes('debug')) {
|
|
380
|
-
this.log.warn(
|
|
404
|
+
this.log.warn(`[DEBUG] ${this.device.remoteType}: ${this.accessory.displayName}`, String(...log));
|
|
381
405
|
}
|
|
382
406
|
}
|
|
383
407
|
}
|
|
384
408
|
|
|
385
|
-
errorLog(...log: any[]): void {
|
|
386
|
-
if (this.enablingDeviceLogging()) {
|
|
387
|
-
this.log.error(String(...log));
|
|
409
|
+
async errorLog(...log: any[]): Promise<void> {
|
|
410
|
+
if (await this.enablingDeviceLogging()) {
|
|
411
|
+
this.log.error(`${this.device.remoteType}: ${this.accessory.displayName}`, String(...log));
|
|
388
412
|
}
|
|
389
413
|
}
|
|
390
414
|
|
|
391
|
-
debugErrorLog(...log: any[]): void {
|
|
392
|
-
if (this.enablingDeviceLogging()) {
|
|
415
|
+
async debugErrorLog(...log: any[]): Promise<void> {
|
|
416
|
+
if (await this.enablingDeviceLogging()) {
|
|
393
417
|
if (this.deviceLogging?.includes('debug')) {
|
|
394
|
-
this.log.error(
|
|
418
|
+
this.log.error(`[DEBUG] ${this.device.remoteType}: ${this.accessory.displayName}`, String(...log));
|
|
395
419
|
}
|
|
396
420
|
}
|
|
397
421
|
}
|
|
398
422
|
|
|
399
|
-
debugLog(...log: any[]): void {
|
|
400
|
-
if (this.enablingDeviceLogging()) {
|
|
423
|
+
async debugLog(...log: any[]): Promise<void> {
|
|
424
|
+
if (await this.enablingDeviceLogging()) {
|
|
401
425
|
if (this.deviceLogging === 'debug') {
|
|
402
|
-
this.log.info(
|
|
426
|
+
this.log.info(`[DEBUG] ${this.device.remoteType}: ${this.accessory.displayName}`, String(...log));
|
|
403
427
|
} else {
|
|
404
|
-
this.log.debug(String(...log));
|
|
428
|
+
this.log.debug(`${this.device.remoteType}: ${this.accessory.displayName}`, String(...log));
|
|
405
429
|
}
|
|
406
430
|
}
|
|
407
431
|
}
|
|
408
432
|
|
|
409
|
-
enablingDeviceLogging(): boolean {
|
|
433
|
+
async enablingDeviceLogging(): Promise<boolean> {
|
|
410
434
|
return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
|
|
411
435
|
}
|
|
412
436
|
}
|
package/src/irdevice/light.ts
CHANGED
|
@@ -127,7 +127,7 @@ export class Light extends irdeviceBase {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
async OnSet(value: CharacteristicValue): Promise<void> {
|
|
130
|
-
this.debugLog(
|
|
130
|
+
await this.debugLog(`On: ${value}`);
|
|
131
131
|
|
|
132
132
|
this.LightBulb!.On = value;
|
|
133
133
|
if (this.LightBulb?.On) {
|
|
@@ -144,7 +144,7 @@ export class Light extends irdeviceBase {
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
async ProgrammableSwitchOutputStateSetOn(value: CharacteristicValue): Promise<void> {
|
|
147
|
-
this.debugLog(
|
|
147
|
+
await this.debugLog(`On: ${value}`);
|
|
148
148
|
|
|
149
149
|
this.ProgrammableSwitchOn!.ProgrammableSwitchOutputState = value;
|
|
150
150
|
if (this.ProgrammableSwitchOn?.ProgrammableSwitchOutputState === 1) {
|
|
@@ -158,7 +158,7 @@ export class Light extends irdeviceBase {
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
async ProgrammableSwitchOutputStateSetOff(value: CharacteristicValue): Promise<void> {
|
|
161
|
-
this.debugLog(
|
|
161
|
+
await this.debugLog(`On: ${value}`);
|
|
162
162
|
|
|
163
163
|
this.ProgrammableSwitchOff!.ProgrammableSwitchOutputState = value;
|
|
164
164
|
if (this.ProgrammableSwitchOff?.ProgrammableSwitchOutputState === 1) {
|
|
@@ -184,7 +184,7 @@ export class Light extends irdeviceBase {
|
|
|
184
184
|
* Light - "command" "channelSub" "default" = previous channel
|
|
185
185
|
*/
|
|
186
186
|
async pushLightOnChanges(On: boolean): Promise<void> {
|
|
187
|
-
this.debugLog(
|
|
187
|
+
await this.debugLog(`pushLightOnChanges On: ${On}, disablePushOn: ${this.disablePushOn}`);
|
|
188
188
|
if (On === true && this.disablePushOn === false) {
|
|
189
189
|
const commandType: string = await this.commandType();
|
|
190
190
|
const command: string = await this.commandOn();
|
|
@@ -198,7 +198,7 @@ export class Light extends irdeviceBase {
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
async pushLightOffChanges(On: boolean): Promise<void> {
|
|
201
|
-
this.debugLog(
|
|
201
|
+
await this.debugLog(`pushLightOffChanges On: ${On}, disablePushOff: ${this.disablePushOff}`);
|
|
202
202
|
if (On === false && this.disablePushOff === false) {
|
|
203
203
|
const commandType: string = await this.commandType();
|
|
204
204
|
const command: string = await this.commandOff();
|
|
@@ -212,9 +212,9 @@ export class Light extends irdeviceBase {
|
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
async pushChanges(bodyChange: any, On: boolean): Promise<void> {
|
|
215
|
-
this.debugLog(
|
|
215
|
+
this.debugLog('pushChanges');
|
|
216
216
|
if (this.device.connectionType === 'OpenAPI') {
|
|
217
|
-
this.infoLog(
|
|
217
|
+
this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
218
218
|
try {
|
|
219
219
|
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
220
220
|
const deviceStatus: any = await body.json();
|
|
@@ -232,43 +232,41 @@ export class Light extends irdeviceBase {
|
|
|
232
232
|
await this.pushChangeError(e);
|
|
233
233
|
}
|
|
234
234
|
} else {
|
|
235
|
-
this.warnLog(
|
|
235
|
+
this.warnLog('Connection Type: '
|
|
236
236
|
+ `${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
241
|
+
await this.debugLog('updateHomeKitCharacteristics');
|
|
241
242
|
if (!this.device.irlight?.stateless) {
|
|
242
243
|
// On
|
|
243
244
|
if (this.LightBulb?.On === undefined) {
|
|
244
|
-
this.debugLog(
|
|
245
|
+
await this.debugLog(`On: ${this.LightBulb?.On}`);
|
|
245
246
|
} else {
|
|
246
247
|
this.accessory.context.On = this.LightBulb.On;
|
|
247
248
|
this.LightBulb?.Service.updateCharacteristic(this.hap.Characteristic.On, this.LightBulb.On);
|
|
248
|
-
this.debugLog(
|
|
249
|
+
await this.debugLog(`updateCharacteristic On: ${this.LightBulb.On}`);
|
|
249
250
|
}
|
|
250
251
|
} else {
|
|
251
252
|
// On Stateful Programmable Switch
|
|
252
253
|
if (this.ProgrammableSwitchOn?.ProgrammableSwitchOutputState === undefined) {
|
|
253
|
-
this.debugLog(
|
|
254
|
-
+ ` ProgrammableSwitchOutputStateOn: ${this.ProgrammableSwitchOn?.ProgrammableSwitchOutputState}`);
|
|
254
|
+
await this.debugLog(`ProgrammableSwitchOutputStateOn: ${this.ProgrammableSwitchOn?.ProgrammableSwitchOutputState}`);
|
|
255
255
|
} else {
|
|
256
256
|
this.accessory.context.ProgrammableSwitchOutputStateOn = this.ProgrammableSwitchOn.ProgrammableSwitchOutputState;
|
|
257
257
|
this.ProgrammableSwitchOn?.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState,
|
|
258
258
|
this.ProgrammableSwitchOn.ProgrammableSwitchOutputState);
|
|
259
|
-
this.debugLog(
|
|
259
|
+
this.debugLog('updateCharacteristic'
|
|
260
260
|
+ ` ProgrammableSwitchOutputStateOn: ${this.ProgrammableSwitchOn.ProgrammableSwitchOutputState}`);
|
|
261
261
|
}
|
|
262
262
|
// Off Stateful Programmable Switch
|
|
263
263
|
if (this.ProgrammableSwitchOff?.ProgrammableSwitchOutputState === undefined) {
|
|
264
|
-
this.debugLog(
|
|
265
|
-
+ ` ProgrammableSwitchOutputStateOff: ${this.ProgrammableSwitchOff?.ProgrammableSwitchOutputState}`);
|
|
264
|
+
await this.debugLog(`ProgrammableSwitchOutputStateOff: ${this.ProgrammableSwitchOff?.ProgrammableSwitchOutputState}`);
|
|
266
265
|
} else {
|
|
267
266
|
this.accessory.context.ProgrammableSwitchOutputStateOff = this.ProgrammableSwitchOff.ProgrammableSwitchOutputState;
|
|
268
267
|
this.ProgrammableSwitchOff.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState,
|
|
269
268
|
this.ProgrammableSwitchOff.ProgrammableSwitchOutputState);
|
|
270
|
-
this.debugLog(
|
|
271
|
-
+ ` ProgrammableSwitchOutputStateOff: ${this.ProgrammableSwitchOff?.ProgrammableSwitchOutputState}`);
|
|
269
|
+
await this.debugLog(`updateCharacteristic ProgrammableSwitchOutputStateOff: ${this.ProgrammableSwitchOff?.ProgrammableSwitchOutputState}`);
|
|
272
270
|
}
|
|
273
271
|
}
|
|
274
272
|
}
|