@switchbot/homebridge-switchbot 2.6.0 → 2.6.2-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.
- package/.github/npm-version-script.js +81 -0
- package/CHANGELOG.md +9 -1
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +7 -6
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +4 -3
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +13 -9
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +12 -8
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +4 -3
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +9 -6
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +9 -6
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +3 -2
- package/dist/device/lock.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +3 -2
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +3 -2
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +9 -8
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +9 -8
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +7 -6
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +13 -12
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +11 -10
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +7 -6
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +25 -24
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +7 -6
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +7 -6
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +1 -0
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +0 -8
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +1 -9
- package/dist/settings.js.map +1 -1
- package/nodemon.json +1 -1
- package/package.json +1 -1
- package/src/device/blindtilt.ts +7 -6
- package/src/device/bot.ts +4 -3
- package/src/device/ceilinglight.ts +13 -9
- package/src/device/colorbulb.ts +12 -8
- package/src/device/curtain.ts +4 -3
- package/src/device/humidifier.ts +9 -6
- package/src/device/lightstrip.ts +9 -6
- package/src/device/lock.ts +3 -2
- package/src/device/plug.ts +3 -2
- package/src/device/robotvacuumcleaner.ts +3 -2
- package/src/irdevice/airconditioner.ts +9 -8
- package/src/irdevice/airpurifier.ts +9 -8
- package/src/irdevice/camera.ts +7 -6
- package/src/irdevice/fan.ts +13 -12
- package/src/irdevice/light.ts +11 -10
- package/src/irdevice/other.ts +7 -6
- package/src/irdevice/tv.ts +25 -24
- package/src/irdevice/vacuumcleaner.ts +7 -6
- package/src/irdevice/waterheater.ts +7 -6
- package/src/platform.ts +1 -0
- package/src/settings.ts +0 -10
package/src/irdevice/fan.ts
CHANGED
|
@@ -175,12 +175,12 @@ export class Fan {
|
|
|
175
175
|
if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
176
176
|
const commandType: string = await this.commandType();
|
|
177
177
|
const command: string = await this.commandOn();
|
|
178
|
-
const
|
|
178
|
+
const bodyChange = JSON.stringify({
|
|
179
179
|
'command': command,
|
|
180
180
|
'parameter': 'default',
|
|
181
181
|
'commandType': commandType,
|
|
182
182
|
});
|
|
183
|
-
await this.pushChanges(
|
|
183
|
+
await this.pushChanges(bodyChange);
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
|
|
@@ -190,48 +190,49 @@ export class Fan {
|
|
|
190
190
|
if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOff) {
|
|
191
191
|
const commandType: string = await this.commandType();
|
|
192
192
|
const command: string = await this.commandOff();
|
|
193
|
-
const
|
|
193
|
+
const bodyChange = JSON.stringify({
|
|
194
194
|
'command': command,
|
|
195
195
|
'parameter': 'default',
|
|
196
196
|
'commandType': commandType,
|
|
197
197
|
});
|
|
198
|
-
await this.pushChanges(
|
|
198
|
+
await this.pushChanges(bodyChange);
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
async pushFanSpeedUpChanges(): Promise<void> {
|
|
203
|
-
const
|
|
203
|
+
const bodyChange = JSON.stringify({
|
|
204
204
|
'command': 'highSpeed',
|
|
205
205
|
'parameter': 'default',
|
|
206
206
|
'commandType': 'command',
|
|
207
207
|
});
|
|
208
|
-
await this.pushChanges(
|
|
208
|
+
await this.pushChanges(bodyChange);
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
async pushFanSpeedDownChanges(): Promise<void> {
|
|
212
|
-
const
|
|
212
|
+
const bodyChange = JSON.stringify({
|
|
213
213
|
'command': 'lowSpeed',
|
|
214
214
|
'parameter': 'default',
|
|
215
215
|
'commandType': 'command',
|
|
216
216
|
});
|
|
217
|
-
await this.pushChanges(
|
|
217
|
+
await this.pushChanges(bodyChange);
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
async pushFanSwingChanges(): Promise<void> {
|
|
221
|
-
const
|
|
221
|
+
const bodyChange = JSON.stringify({
|
|
222
222
|
'command': 'swing',
|
|
223
223
|
'parameter': 'default',
|
|
224
224
|
'commandType': 'command',
|
|
225
225
|
});
|
|
226
|
-
await this.pushChanges(
|
|
226
|
+
await this.pushChanges(bodyChange);
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
async pushChanges(
|
|
229
|
+
async pushChanges(bodyChange: any): Promise<void> {
|
|
230
230
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
|
|
231
231
|
if (this.device.connectionType === 'OpenAPI') {
|
|
232
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${
|
|
232
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
233
233
|
try {
|
|
234
234
|
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
235
|
+
body: bodyChange,
|
|
235
236
|
method: 'POST',
|
|
236
237
|
headers: this.platform.generateHeaders(),
|
|
237
238
|
});
|
package/src/irdevice/light.ts
CHANGED
|
@@ -89,12 +89,12 @@ export class Light {
|
|
|
89
89
|
if (this.On && !this.disablePushOn) {
|
|
90
90
|
const commandType: string = await this.commandType();
|
|
91
91
|
const command: string = await this.commandOn();
|
|
92
|
-
const
|
|
92
|
+
const bodyChange = JSON.stringify({
|
|
93
93
|
'command': command,
|
|
94
94
|
'parameter': 'default',
|
|
95
95
|
'commandType': commandType,
|
|
96
96
|
});
|
|
97
|
-
await this.pushChanges(
|
|
97
|
+
await this.pushChanges(bodyChange);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
@@ -104,39 +104,40 @@ export class Light {
|
|
|
104
104
|
if (!this.On && !this.disablePushOff) {
|
|
105
105
|
const commandType: string = await this.commandType();
|
|
106
106
|
const command: string = await this.commandOff();
|
|
107
|
-
const
|
|
107
|
+
const bodyChange = JSON.stringify({
|
|
108
108
|
'command': command,
|
|
109
109
|
'parameter': 'default',
|
|
110
110
|
'commandType': commandType,
|
|
111
111
|
});
|
|
112
|
-
await this.pushChanges(
|
|
112
|
+
await this.pushChanges(bodyChange);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
async pushLightBrightnessUpChanges(): Promise<void> {
|
|
117
|
-
const
|
|
117
|
+
const bodyChange = JSON.stringify({
|
|
118
118
|
'command': 'brightnessUp',
|
|
119
119
|
'parameter': 'default',
|
|
120
120
|
'commandType': 'command',
|
|
121
121
|
});
|
|
122
|
-
await this.pushChanges(
|
|
122
|
+
await this.pushChanges(bodyChange);
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
async pushLightBrightnessDownChanges(): Promise<void> {
|
|
126
|
-
const
|
|
126
|
+
const bodyChange = JSON.stringify({
|
|
127
127
|
'command': 'brightnessDown',
|
|
128
128
|
'parameter': 'default',
|
|
129
129
|
'commandType': 'command',
|
|
130
130
|
});
|
|
131
|
-
await this.pushChanges(
|
|
131
|
+
await this.pushChanges(bodyChange);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
async pushChanges(
|
|
134
|
+
async pushChanges(bodyChange: any): Promise<void> {
|
|
135
135
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
|
|
136
136
|
if (this.device.connectionType === 'OpenAPI') {
|
|
137
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${
|
|
137
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
138
138
|
try {
|
|
139
139
|
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
140
|
+
body: bodyChange,
|
|
140
141
|
method: 'POST',
|
|
141
142
|
headers: this.platform.generateHeaders(),
|
|
142
143
|
});
|
package/src/irdevice/other.ts
CHANGED
|
@@ -93,12 +93,12 @@ export class Others {
|
|
|
93
93
|
if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
94
94
|
const commandType: string = await this.commandType();
|
|
95
95
|
const command: string = await this.commandOn();
|
|
96
|
-
const
|
|
96
|
+
const bodyChange = JSON.stringify({
|
|
97
97
|
'command': command,
|
|
98
98
|
'parameter': 'default',
|
|
99
99
|
'commandType': commandType,
|
|
100
100
|
});
|
|
101
|
-
await this.pushChanges(
|
|
101
|
+
await this.pushChanges(bodyChange);
|
|
102
102
|
}
|
|
103
103
|
} else {
|
|
104
104
|
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} On Command not set`);
|
|
@@ -112,24 +112,25 @@ export class Others {
|
|
|
112
112
|
if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOff) {
|
|
113
113
|
const commandType: string = await this.commandType();
|
|
114
114
|
const command: string = await this.commandOff();
|
|
115
|
-
const
|
|
115
|
+
const bodyChange = JSON.stringify({
|
|
116
116
|
'command': command,
|
|
117
117
|
'parameter': 'default',
|
|
118
118
|
'commandType': commandType,
|
|
119
119
|
});
|
|
120
|
-
await this.pushChanges(
|
|
120
|
+
await this.pushChanges(bodyChange);
|
|
121
121
|
}
|
|
122
122
|
} else {
|
|
123
123
|
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Off Command not set.`);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
async pushChanges(
|
|
127
|
+
async pushChanges(bodyChange: any): Promise<void> {
|
|
128
128
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
|
|
129
129
|
if (this.device.connectionType === 'OpenAPI') {
|
|
130
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${
|
|
130
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
131
131
|
try {
|
|
132
132
|
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
133
|
+
body: bodyChange,
|
|
133
134
|
method: 'POST',
|
|
134
135
|
headers: this.platform.generateHeaders(),
|
|
135
136
|
});
|
package/src/irdevice/tv.ts
CHANGED
|
@@ -227,12 +227,12 @@ export class TV {
|
|
|
227
227
|
if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
228
228
|
const commandType: string = await this.commandType();
|
|
229
229
|
const command: string = await this.commandOn();
|
|
230
|
-
const
|
|
230
|
+
const bodyChange = JSON.stringify({
|
|
231
231
|
'command': command,
|
|
232
232
|
'parameter': 'default',
|
|
233
233
|
'commandType': commandType,
|
|
234
234
|
});
|
|
235
|
-
await this.pushTVChanges(
|
|
235
|
+
await this.pushTVChanges(bodyChange);
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
|
|
@@ -242,129 +242,130 @@ export class TV {
|
|
|
242
242
|
if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOff) {
|
|
243
243
|
const commandType: string = await this.commandType();
|
|
244
244
|
const command: string = await this.commandOff();
|
|
245
|
-
const
|
|
245
|
+
const bodyChange = JSON.stringify({
|
|
246
246
|
'command': command,
|
|
247
247
|
'parameter': 'default',
|
|
248
248
|
'commandType': commandType,
|
|
249
249
|
});
|
|
250
|
-
await this.pushTVChanges(
|
|
250
|
+
await this.pushTVChanges(bodyChange);
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
async pushOkChanges(): Promise<void> {
|
|
255
255
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOkChanges disablePushDetail: ${this.disablePushDetail}`);
|
|
256
256
|
if (!this.disablePushDetail) {
|
|
257
|
-
const
|
|
257
|
+
const bodyChange = JSON.stringify({
|
|
258
258
|
'command': 'Ok',
|
|
259
259
|
'parameter': 'default',
|
|
260
260
|
'commandType': 'command',
|
|
261
261
|
});
|
|
262
|
-
await this.pushTVChanges(
|
|
262
|
+
await this.pushTVChanges(bodyChange);
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
265
|
|
|
266
266
|
async pushBackChanges(): Promise<void> {
|
|
267
267
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushBackChanges disablePushDetail: ${this.disablePushDetail}`);
|
|
268
268
|
if (!this.disablePushDetail) {
|
|
269
|
-
const
|
|
269
|
+
const bodyChange = JSON.stringify({
|
|
270
270
|
'command': 'Back',
|
|
271
271
|
'parameter': 'default',
|
|
272
272
|
'commandType': 'command',
|
|
273
273
|
});
|
|
274
|
-
await this.pushTVChanges(
|
|
274
|
+
await this.pushTVChanges(bodyChange);
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
277
|
|
|
278
278
|
async pushMenuChanges(): Promise<void> {
|
|
279
279
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushMenuChanges disablePushDetail: ${this.disablePushDetail}`);
|
|
280
280
|
if (!this.disablePushDetail) {
|
|
281
|
-
const
|
|
281
|
+
const bodyChange = JSON.stringify({
|
|
282
282
|
'command': 'Menu',
|
|
283
283
|
'parameter': 'default',
|
|
284
284
|
'commandType': 'command',
|
|
285
285
|
});
|
|
286
|
-
await this.pushTVChanges(
|
|
286
|
+
await this.pushTVChanges(bodyChange);
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
289
|
|
|
290
290
|
async pushUpChanges(): Promise<void> {
|
|
291
291
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushUpChanges disablePushDetail: ${this.disablePushDetail}`);
|
|
292
292
|
if (!this.disablePushDetail) {
|
|
293
|
-
const
|
|
293
|
+
const bodyChange = JSON.stringify({
|
|
294
294
|
'command': 'Up',
|
|
295
295
|
'parameter': 'default',
|
|
296
296
|
'commandType': 'command',
|
|
297
297
|
});
|
|
298
|
-
await this.pushTVChanges(
|
|
298
|
+
await this.pushTVChanges(bodyChange);
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
301
|
|
|
302
302
|
async pushDownChanges(): Promise<void> {
|
|
303
303
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushDownChanges disablePushDetail: ${this.disablePushDetail}`);
|
|
304
304
|
if (!this.disablePushDetail) {
|
|
305
|
-
const
|
|
305
|
+
const bodyChange = JSON.stringify({
|
|
306
306
|
'command': 'Down',
|
|
307
307
|
'parameter': 'default',
|
|
308
308
|
'commandType': 'command',
|
|
309
309
|
});
|
|
310
|
-
await this.pushTVChanges(
|
|
310
|
+
await this.pushTVChanges(bodyChange);
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
313
|
|
|
314
314
|
async pushRightChanges(): Promise<void> {
|
|
315
315
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushRightChanges disablePushDetail: ${this.disablePushDetail}`);
|
|
316
316
|
if (!this.disablePushDetail) {
|
|
317
|
-
const
|
|
317
|
+
const bodyChange = JSON.stringify({
|
|
318
318
|
'command': 'Right',
|
|
319
319
|
'parameter': 'default',
|
|
320
320
|
'commandType': 'command',
|
|
321
321
|
});
|
|
322
|
-
await this.pushTVChanges(
|
|
322
|
+
await this.pushTVChanges(bodyChange);
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
|
|
326
326
|
async pushLeftChanges(): Promise<void> {
|
|
327
327
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushLeftChanges disablePushDetail: ${this.disablePushDetail}`);
|
|
328
328
|
if (!this.disablePushDetail) {
|
|
329
|
-
const
|
|
329
|
+
const bodyChange = JSON.stringify({
|
|
330
330
|
'command': 'Left',
|
|
331
331
|
'parameter': 'default',
|
|
332
332
|
'commandType': 'command',
|
|
333
333
|
});
|
|
334
|
-
await this.pushTVChanges(
|
|
334
|
+
await this.pushTVChanges(bodyChange);
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
337
|
|
|
338
338
|
async pushVolumeUpChanges(): Promise<void> {
|
|
339
339
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushVolumeUpChanges disablePushDetail: ${this.disablePushDetail}`);
|
|
340
340
|
if (!this.disablePushDetail) {
|
|
341
|
-
const
|
|
341
|
+
const bodyChange = JSON.stringify({
|
|
342
342
|
'command': 'volumeAdd',
|
|
343
343
|
'parameter': 'default',
|
|
344
344
|
'commandType': 'command',
|
|
345
345
|
});
|
|
346
|
-
await this.pushTVChanges(
|
|
346
|
+
await this.pushTVChanges(bodyChange);
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
async pushVolumeDownChanges(): Promise<void> {
|
|
351
351
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushVolumeDownChanges disablePushDetail: ${this.disablePushDetail}`);
|
|
352
352
|
if (!this.disablePushDetail) {
|
|
353
|
-
const
|
|
353
|
+
const bodyChange = JSON.stringify({
|
|
354
354
|
'command': 'volumeSub',
|
|
355
355
|
'parameter': 'default',
|
|
356
356
|
'commandType': 'command',
|
|
357
357
|
});
|
|
358
|
-
await this.pushTVChanges(
|
|
358
|
+
await this.pushTVChanges(bodyChange);
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
361
|
|
|
362
|
-
async pushTVChanges(
|
|
362
|
+
async pushTVChanges(bodyChange: any): Promise<void> {
|
|
363
363
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushTVChanges`);
|
|
364
364
|
if (this.device.connectionType === 'OpenAPI') {
|
|
365
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${
|
|
365
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
366
366
|
try {
|
|
367
367
|
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
368
|
+
body: bodyChange,
|
|
368
369
|
method: 'POST',
|
|
369
370
|
headers: this.platform.generateHeaders(),
|
|
370
371
|
});
|
|
@@ -81,12 +81,12 @@ export class VacuumCleaner {
|
|
|
81
81
|
if (this.On && !this.disablePushOn) {
|
|
82
82
|
const commandType: string = await this.commandType();
|
|
83
83
|
const command: string = await this.commandOn();
|
|
84
|
-
const
|
|
84
|
+
const bodyChange = JSON.stringify({
|
|
85
85
|
'command': command,
|
|
86
86
|
'parameter': 'default',
|
|
87
87
|
'commandType': commandType,
|
|
88
88
|
});
|
|
89
|
-
await this.pushChanges(
|
|
89
|
+
await this.pushChanges(bodyChange);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -96,21 +96,22 @@ export class VacuumCleaner {
|
|
|
96
96
|
if (!this.On && !this.disablePushOff) {
|
|
97
97
|
const commandType: string = await this.commandType();
|
|
98
98
|
const command: string = await this.commandOff();
|
|
99
|
-
const
|
|
99
|
+
const bodyChange = JSON.stringify({
|
|
100
100
|
'command': command,
|
|
101
101
|
'parameter': 'default',
|
|
102
102
|
'commandType': commandType,
|
|
103
103
|
});
|
|
104
|
-
await this.pushChanges(
|
|
104
|
+
await this.pushChanges(bodyChange);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
async pushChanges(
|
|
108
|
+
async pushChanges(bodyChange: any): Promise<void> {
|
|
109
109
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
|
|
110
110
|
if (this.device.connectionType === 'OpenAPI') {
|
|
111
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${
|
|
111
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
112
112
|
try {
|
|
113
113
|
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
114
|
+
body: bodyChange,
|
|
114
115
|
method: 'POST',
|
|
115
116
|
headers: this.platform.generateHeaders(),
|
|
116
117
|
});
|
|
@@ -86,12 +86,12 @@ export class WaterHeater {
|
|
|
86
86
|
if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
87
87
|
const commandType: string = await this.commandType();
|
|
88
88
|
const command: string = await this.commandOn();
|
|
89
|
-
const
|
|
89
|
+
const bodyChange = JSON.stringify({
|
|
90
90
|
'command': command,
|
|
91
91
|
'parameter': 'default',
|
|
92
92
|
'commandType': commandType,
|
|
93
93
|
});
|
|
94
|
-
await this.pushChanges(
|
|
94
|
+
await this.pushChanges(bodyChange);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
|
|
@@ -101,21 +101,22 @@ export class WaterHeater {
|
|
|
101
101
|
if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOff) {
|
|
102
102
|
const commandType: string = await this.commandType();
|
|
103
103
|
const command: string = await this.commandOff();
|
|
104
|
-
const
|
|
104
|
+
const bodyChange = JSON.stringify({
|
|
105
105
|
'command': command,
|
|
106
106
|
'parameter': 'default',
|
|
107
107
|
'commandType': commandType,
|
|
108
108
|
});
|
|
109
|
-
await this.pushChanges(
|
|
109
|
+
await this.pushChanges(bodyChange);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
async pushChanges(
|
|
113
|
+
async pushChanges(bodyChange: any): Promise<void> {
|
|
114
114
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
|
|
115
115
|
if (this.device.connectionType === 'OpenAPI') {
|
|
116
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${
|
|
116
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
117
117
|
try {
|
|
118
118
|
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
119
|
+
body: bodyChange,
|
|
119
120
|
method: 'POST',
|
|
120
121
|
headers: this.platform.generateHeaders(),
|
|
121
122
|
});
|
package/src/platform.ts
CHANGED
|
@@ -414,6 +414,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
414
414
|
this.createMeter(device);
|
|
415
415
|
break;
|
|
416
416
|
case 'MeterPlus':
|
|
417
|
+
case 'Meter Plus (JP)':
|
|
417
418
|
this.debugLog(`Discovered ${device.deviceType}: ${device.deviceId}`);
|
|
418
419
|
this.createMeterPlus(device);
|
|
419
420
|
break;
|
package/src/settings.ts
CHANGED
|
@@ -16,16 +16,6 @@ export const PLUGIN_NAME = '@switchbot/homebridge-switchbot';
|
|
|
16
16
|
*/
|
|
17
17
|
export const Devices = 'https://api.switch-bot.com/v1.1/devices';
|
|
18
18
|
|
|
19
|
-
/**
|
|
20
|
-
* This is the main url used to access SwitchBot API
|
|
21
|
-
*/
|
|
22
|
-
export const HostDomain = 'api.switch-bot.com';
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* This is the main url used to access SwitchBot API
|
|
26
|
-
*/
|
|
27
|
-
export const DevicePath = '/v1.1/devices';
|
|
28
|
-
|
|
29
19
|
//Config
|
|
30
20
|
export interface SwitchBotPlatformConfig extends PlatformConfig {
|
|
31
21
|
credentials?: credentials;
|