@switchbot/homebridge-switchbot 3.7.1-beta.1 → 3.7.1-beta.2
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/device.d.ts.map +1 -1
- package/dist/device/device.js +247 -394
- package/dist/device/device.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js +30 -133
- package/dist/irdevice/irdevice.js.map +1 -1
- package/package.json +1 -1
- package/src/device/device.ts +283 -395
- package/src/irdevice/irdevice.ts +54 -134
package/src/irdevice/irdevice.ts
CHANGED
|
@@ -67,76 +67,33 @@ export abstract class irdeviceBase {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
async getDeviceConfigSettings(device: irdevice & irDevicesConfig): Promise<void> {
|
|
70
|
-
const deviceConfig =
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
if (device.disablePushDetail === true) {
|
|
99
|
-
deviceConfig['disablePushDetail'] = device.disablePushDetail;
|
|
100
|
-
}
|
|
101
|
-
let irairConfig = {};
|
|
102
|
-
if (device.irair) {
|
|
103
|
-
irairConfig = device.irair;
|
|
104
|
-
}
|
|
105
|
-
let irpurConfig = {};
|
|
106
|
-
if (device.irpur) {
|
|
107
|
-
irpurConfig = device.irpur;
|
|
108
|
-
}
|
|
109
|
-
let ircamConfig = {};
|
|
110
|
-
if (device.ircam) {
|
|
111
|
-
ircamConfig = device.ircam;
|
|
112
|
-
}
|
|
113
|
-
let irfanConfig = {};
|
|
114
|
-
if (device.irfan) {
|
|
115
|
-
irfanConfig = device.irfan;
|
|
116
|
-
}
|
|
117
|
-
let irlightConfig = {};
|
|
118
|
-
if (device.irlight) {
|
|
119
|
-
irlightConfig = device.irlight;
|
|
120
|
-
}
|
|
121
|
-
let otherConfig = {};
|
|
122
|
-
if (device.other) {
|
|
123
|
-
otherConfig = device.other;
|
|
124
|
-
}
|
|
125
|
-
let irtvConfig = {};
|
|
126
|
-
if (device.irtv) {
|
|
127
|
-
irtvConfig = device.irtv;
|
|
128
|
-
}
|
|
129
|
-
let irvcConfig = {};
|
|
130
|
-
if (device.irvc) {
|
|
131
|
-
irvcConfig = device.irvc;
|
|
132
|
-
}
|
|
133
|
-
let irwhConfig = {};
|
|
134
|
-
if (device.irwh) {
|
|
135
|
-
irwhConfig = device.irwh;
|
|
136
|
-
}
|
|
137
|
-
const config = Object.assign({}, deviceConfig, irairConfig, irpurConfig, ircamConfig, irfanConfig, irlightConfig, otherConfig,
|
|
138
|
-
irtvConfig, irvcConfig, irwhConfig);
|
|
139
|
-
if (Object.entries(config).length !== 0) {
|
|
70
|
+
const deviceConfig = Object.assign(
|
|
71
|
+
{},
|
|
72
|
+
device.logging !== 'standard' && { logging: device.logging },
|
|
73
|
+
device.connectionType !== '' && { connectionType: device.connectionType },
|
|
74
|
+
device.external === true && { external: device.external },
|
|
75
|
+
device.customize === true && { customize: device.customize },
|
|
76
|
+
device.commandType !== '' && { commandType: device.commandType },
|
|
77
|
+
device.customOn !== '' && { customOn: device.customOn },
|
|
78
|
+
device.customOff !== '' && { customOff: device.customOff },
|
|
79
|
+
device.disablePushOn === true && { disablePushOn: device.disablePushOn },
|
|
80
|
+
device.disablePushOff === true && { disablePushOff: device.disablePushOff },
|
|
81
|
+
device.disablePushDetail === true && { disablePushDetail: device.disablePushDetail },
|
|
82
|
+
);
|
|
83
|
+
const config = Object.assign(
|
|
84
|
+
{},
|
|
85
|
+
deviceConfig,
|
|
86
|
+
device.irair,
|
|
87
|
+
device.irpur,
|
|
88
|
+
device.ircam,
|
|
89
|
+
device.irfan,
|
|
90
|
+
device.irlight,
|
|
91
|
+
device.other,
|
|
92
|
+
device.irtv,
|
|
93
|
+
device.irvc,
|
|
94
|
+
device.irwh,
|
|
95
|
+
);
|
|
96
|
+
if (Object.keys(config).length !== 0) {
|
|
140
97
|
this.debugSuccessLog(`Config: ${JSON.stringify(config)}`);
|
|
141
98
|
}
|
|
142
99
|
}
|
|
@@ -280,70 +237,33 @@ export abstract class irdeviceBase {
|
|
|
280
237
|
}
|
|
281
238
|
|
|
282
239
|
async statusCode(statusCode: number): Promise<void> {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
this.errorLog('Bad Request, The client has issued an invalid request. This is commonly used to specify validation errors in a request'
|
|
311
|
-
+ ` payload, statusCode: ${statusCode}`);
|
|
312
|
-
break;
|
|
313
|
-
case 401:
|
|
314
|
-
this.errorLog(`Unauthorized, Authorization for the API is required, but the request has not been authenticated, statusCode: ${statusCode}`);
|
|
315
|
-
break;
|
|
316
|
-
case 403:
|
|
317
|
-
this.errorLog('Forbidden, The request has been authenticated but does not have appropriate permissions, or a requested resource is not'
|
|
318
|
-
+ ` found, statusCode: ${statusCode}`);
|
|
319
|
-
break;
|
|
320
|
-
case 404:
|
|
321
|
-
this.errorLog(`Not Found, Specifies the requested path does not exist, statusCode: ${statusCode}`);
|
|
322
|
-
break;
|
|
323
|
-
case 406:
|
|
324
|
-
this.errorLog('Not Acceptable, The client has requested a MIME type via the Accept header for a value not supported by the server,'
|
|
325
|
-
+ ` statusCode: ${statusCode}`);
|
|
326
|
-
break;
|
|
327
|
-
case 415:
|
|
328
|
-
this.errorLog('Unsupported Media Type, The client has defined a contentType header that is not supported by the server,'
|
|
329
|
-
+ ` statusCode: ${statusCode}`);
|
|
330
|
-
break;
|
|
331
|
-
case 422:
|
|
332
|
-
this.errorLog('Unprocessable Entity, The client has made a valid request, but the server cannot process it. This is often used for APIs'
|
|
333
|
-
+ ` for which certain limits have been exceeded, statusCode: ${statusCode}`);
|
|
334
|
-
break;
|
|
335
|
-
case 429:
|
|
336
|
-
this.errorLog('Too Many Requests, The client has exceeded the number of requests allowed for a given time window,'
|
|
337
|
-
+ ` statusCode: ${statusCode}`);
|
|
338
|
-
break;
|
|
339
|
-
case 500:
|
|
340
|
-
this.errorLog('Internal Server Error, An unexpected error on the SmartThings servers has occurred. These errors should be rare,'
|
|
341
|
-
+ ` statusCode: ${statusCode}`);
|
|
342
|
-
break;
|
|
343
|
-
default:
|
|
344
|
-
this.infoLog('Unknown statusCode: '
|
|
345
|
-
+ `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
|
|
346
|
-
}
|
|
240
|
+
const statusMessages = {
|
|
241
|
+
151: 'Command not supported by this deviceType',
|
|
242
|
+
152: 'Device not found',
|
|
243
|
+
160: 'Command is not supported',
|
|
244
|
+
161: 'Device is offline',
|
|
245
|
+
171: `Hub Device is offline. Hub: ${this.device.hubDeviceId}`,
|
|
246
|
+
190: 'Device internal error due to device states not synchronized with server, or command format is invalid',
|
|
247
|
+
100: 'Command successfully sent',
|
|
248
|
+
200: 'Request successful',
|
|
249
|
+
400: 'Bad Request, an invalid payload request',
|
|
250
|
+
401: 'Unauthorized, Authorization for the API is required, but the request has not been authenticated',
|
|
251
|
+
403: 'Forbidden, The request has been authenticated but does not have appropriate permissions, or a requested resource is not found',
|
|
252
|
+
404: 'Not Found, Specifies the requested path does not exist',
|
|
253
|
+
406: 'Not Acceptable, a MIME type has been requested via the Accept header for a value not supported by the server',
|
|
254
|
+
415: 'Unsupported Media Type, a contentType header has been defined that is not supported by the server',
|
|
255
|
+
422: 'Unprocessable Entity: The server cannot process the request, often due to exceeded API limits.',
|
|
256
|
+
429: 'Too Many Requests, exceeded the number of requests allowed for a given time window',
|
|
257
|
+
500: 'Internal Server Error, An unexpected error occurred. These errors should be rare',
|
|
258
|
+
};
|
|
259
|
+
if (statusCode === 171 && (this.device.hubDeviceId === this.device.deviceId || this.device.hubDeviceId === '000000000000')) {
|
|
260
|
+
this.debugErrorLog(`statusCode 171 changed to 161: hubDeviceId ${this.device.hubDeviceId} matches deviceId`
|
|
261
|
+
+ ` ${this.device.deviceId}, device is its own hub.`);
|
|
262
|
+
statusCode = 161;
|
|
263
|
+
}
|
|
264
|
+
const logMessage = statusMessages[statusCode] || `Unknown statusCode: ${statusCode}, Submit Bugs Here: https://tinyurl.com/SwitchBotBug`;
|
|
265
|
+
const logMethod = [100, 200].includes(statusCode) ? 'debugLog' : statusMessages[statusCode] ? 'errorLog' : 'infoLog';
|
|
266
|
+
this[logMethod](`${logMessage}, statusCode: ${statusCode}`);
|
|
347
267
|
}
|
|
348
268
|
|
|
349
269
|
/**
|