@switchbot/homebridge-switchbot 3.1.1-beta.2 → 3.1.1-beta.3
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/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +2 -4
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +2 -4
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +5 -10
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +5 -10
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +1 -2
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +2 -4
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +1 -2
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +4 -8
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +1 -2
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +4 -8
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +2 -4
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +1 -2
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +1 -2
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +1 -2
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +2 -4
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +3 -6
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +1 -2
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +1 -2
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +1 -2
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +1 -2
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +1 -2
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +1 -2
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +1 -2
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +1 -2
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +1 -2
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +5 -10
- package/dist/platform.js.map +1 -1
- package/package.json +1 -1
- package/src/device/blindtilt.ts +2 -4
- package/src/device/bot.ts +2 -4
- package/src/device/ceilinglight.ts +5 -10
- package/src/device/colorbulb.ts +5 -10
- package/src/device/contact.ts +1 -2
- package/src/device/curtain.ts +2 -4
- package/src/device/hub.ts +1 -2
- package/src/device/humidifier.ts +4 -8
- package/src/device/iosensor.ts +1 -2
- package/src/device/lightstrip.ts +4 -8
- package/src/device/lock.ts +2 -4
- package/src/device/meter.ts +1 -2
- package/src/device/meterplus.ts +1 -2
- package/src/device/motion.ts +1 -2
- package/src/device/plug.ts +2 -4
- package/src/device/robotvacuumcleaner.ts +3 -6
- package/src/irdevice/airconditioner.ts +1 -2
- package/src/irdevice/airpurifier.ts +1 -2
- package/src/irdevice/camera.ts +1 -2
- package/src/irdevice/fan.ts +1 -2
- package/src/irdevice/light.ts +1 -2
- package/src/irdevice/other.ts +1 -2
- package/src/irdevice/tv.ts +1 -2
- package/src/irdevice/vacuumcleaner.ts +1 -2
- package/src/irdevice/waterheater.ts +1 -2
- package/src/platform.ts +5 -10
package/src/irdevice/tv.ts
CHANGED
|
@@ -369,13 +369,12 @@ export class TV {
|
|
|
369
369
|
if (this.device.connectionType === 'OpenAPI') {
|
|
370
370
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
371
371
|
try {
|
|
372
|
-
const { body, statusCode
|
|
372
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
373
373
|
body: bodyChange,
|
|
374
374
|
method: 'POST',
|
|
375
375
|
headers: this.platform.generateHeaders(),
|
|
376
376
|
});
|
|
377
377
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
378
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
379
378
|
const deviceStatus: any = await body.json();
|
|
380
379
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
381
380
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -116,13 +116,12 @@ export class VacuumCleaner {
|
|
|
116
116
|
if (this.device.connectionType === 'OpenAPI') {
|
|
117
117
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
118
118
|
try {
|
|
119
|
-
const { body, statusCode
|
|
119
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
120
120
|
body: bodyChange,
|
|
121
121
|
method: 'POST',
|
|
122
122
|
headers: this.platform.generateHeaders(),
|
|
123
123
|
});
|
|
124
124
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
125
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
126
125
|
const deviceStatus: any = await body.json();
|
|
127
126
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
128
127
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -125,13 +125,12 @@ export class WaterHeater {
|
|
|
125
125
|
if (this.device.connectionType === 'OpenAPI') {
|
|
126
126
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
127
127
|
try {
|
|
128
|
-
const { body, statusCode
|
|
128
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
129
129
|
body: bodyChange,
|
|
130
130
|
method: 'POST',
|
|
131
131
|
headers: this.platform.generateHeaders(),
|
|
132
132
|
});
|
|
133
133
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
134
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
135
134
|
const deviceStatus: any = await body.json();
|
|
136
135
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
137
136
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
package/src/platform.ts
CHANGED
|
@@ -203,7 +203,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
try {
|
|
206
|
-
const { body, statusCode
|
|
206
|
+
const { body, statusCode } = await request(
|
|
207
207
|
'https://api.switch-bot.com/v1.1/webhook/setupWebhook', {
|
|
208
208
|
method: 'POST',
|
|
209
209
|
headers: this.generateHeaders(),
|
|
@@ -217,7 +217,6 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
217
217
|
this.debugLog(`setupWebhook: url:${url}`);
|
|
218
218
|
this.debugLog(`setupWebhook: body:${JSON.stringify(response)}`);
|
|
219
219
|
this.debugLog(`setupWebhook: statusCode:${statusCode}`);
|
|
220
|
-
this.debugLog(`setupWebhook: headers:${JSON.stringify(headers)}`);
|
|
221
220
|
if (statusCode !== 200 || response?.statusCode !== 100) {
|
|
222
221
|
this.errorLog(`Failed to configure webhook. Existing webhook well be overridden. HTTP:${statusCode} API:${response?.statusCode} `
|
|
223
222
|
+ `message:${response?.message}`);
|
|
@@ -227,7 +226,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
227
226
|
}
|
|
228
227
|
|
|
229
228
|
try {
|
|
230
|
-
const { body, statusCode
|
|
229
|
+
const { body, statusCode } = await request(
|
|
231
230
|
'https://api.switch-bot.com/v1.1/webhook/updateWebhook', {
|
|
232
231
|
method: 'POST',
|
|
233
232
|
headers: this.generateHeaders(),
|
|
@@ -243,7 +242,6 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
243
242
|
this.debugLog(`updateWebhook: url:${url}`);
|
|
244
243
|
this.debugLog(`updateWebhook: body:${JSON.stringify(response)}`);
|
|
245
244
|
this.debugLog(`updateWebhook: statusCode:${statusCode}`);
|
|
246
|
-
this.debugLog(`updateWebhook: headers:${JSON.stringify(headers)}`);
|
|
247
245
|
if (statusCode !== 200 || response?.statusCode !== 100) {
|
|
248
246
|
this.errorLog(`Failed to update webhook. HTTP:${statusCode} API:${response?.statusCode} message:${response?.message}`);
|
|
249
247
|
}
|
|
@@ -252,7 +250,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
252
250
|
}
|
|
253
251
|
|
|
254
252
|
try {
|
|
255
|
-
const { body, statusCode
|
|
253
|
+
const { body, statusCode } = await request(
|
|
256
254
|
'https://api.switch-bot.com/v1.1/webhook/queryWebhook', {
|
|
257
255
|
method: 'POST',
|
|
258
256
|
headers: this.generateHeaders(),
|
|
@@ -263,7 +261,6 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
263
261
|
const response: any = await body.json();
|
|
264
262
|
this.debugLog(`queryWebhook: body:${JSON.stringify(response)}`);
|
|
265
263
|
this.debugLog(`queryWebhook: statusCode:${statusCode}`);
|
|
266
|
-
this.debugLog(`queryWebhook: headers:${JSON.stringify(headers)}`);
|
|
267
264
|
if (statusCode !== 200 || response?.statusCode !== 100) {
|
|
268
265
|
this.errorLog(`Failed to query webhook. HTTP:${statusCode} API:${response?.statusCode} message:${response?.message}`);
|
|
269
266
|
} else {
|
|
@@ -275,7 +272,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
275
272
|
|
|
276
273
|
this.api.on('shutdown', async () => {
|
|
277
274
|
try {
|
|
278
|
-
const { body, statusCode
|
|
275
|
+
const { body, statusCode } = await request(
|
|
279
276
|
'https://api.switch-bot.com/v1.1/webhook/deleteWebhook', {
|
|
280
277
|
method: 'POST',
|
|
281
278
|
headers: this.generateHeaders(),
|
|
@@ -288,7 +285,6 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
288
285
|
this.debugLog(`deleteWebhook: url:${url}`);
|
|
289
286
|
this.debugLog(`deleteWebhook: body:${JSON.stringify(response)}`);
|
|
290
287
|
this.debugLog(`deleteWebhook: statusCode:${statusCode}`);
|
|
291
|
-
this.debugLog(`deleteWebhook: headers:${JSON.stringify(headers)}`);
|
|
292
288
|
if (statusCode !== 200 || response?.statusCode !== 100) {
|
|
293
289
|
this.errorLog(`Failed to delete webhook. HTTP:${statusCode} API:${response?.statusCode} message:${response?.message}`);
|
|
294
290
|
} else {
|
|
@@ -490,11 +486,10 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
490
486
|
async discoverDevices() {
|
|
491
487
|
if (this.config.credentials?.token) {
|
|
492
488
|
try {
|
|
493
|
-
const { body, statusCode
|
|
489
|
+
const { body, statusCode } = await request(Devices, {
|
|
494
490
|
headers: this.generateHeaders(),
|
|
495
491
|
});
|
|
496
492
|
this.debugWarnLog(`statusCode: ${statusCode}`);
|
|
497
|
-
this.debugWarnLog(`headers: ${JSON.stringify(headers)}`);
|
|
498
493
|
const devicesAPI: any = await body.json();
|
|
499
494
|
this.debugWarnLog(`devicesAPI: ${JSON.stringify(devicesAPI)}`);
|
|
500
495
|
this.debugWarnLog(`devicesAPI Body: ${JSON.stringify(devicesAPI.body)}`);
|