@switchbot/homebridge-switchbot 2.0.0 → 2.1.0-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 +11 -0
- package/config.schema.json +31 -3
- package/dist/irdevice/airconditioner.d.ts +3 -0
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +38 -4
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +3 -0
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +38 -4
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +3 -0
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +38 -4
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +3 -0
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +38 -4
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +3 -0
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +38 -4
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +3 -0
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +50 -36
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +3 -0
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +38 -4
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +3 -0
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +38 -4
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +3 -0
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +38 -4
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +16 -13
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +3 -2
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +1 -1
- package/src/irdevice/airconditioner.ts +38 -4
- package/src/irdevice/airpurifier.ts +38 -4
- package/src/irdevice/camera.ts +38 -4
- package/src/irdevice/fan.ts +38 -4
- package/src/irdevice/light.ts +38 -4
- package/src/irdevice/other.ts +50 -32
- package/src/irdevice/tv.ts +38 -4
- package/src/irdevice/vacuumcleaner.ts +38 -4
- package/src/irdevice/waterheater.ts +38 -4
- package/src/platform.ts +16 -13
- package/src/settings.ts +3 -2
|
@@ -127,21 +127,25 @@ export class AirPurifier {
|
|
|
127
127
|
*/
|
|
128
128
|
async pushAirPurifierOnChanges(): Promise<void> {
|
|
129
129
|
if (this.Active !== 1) {
|
|
130
|
+
const commandType: string = await this.commandType();
|
|
131
|
+
const command: string = await this.commandOn();
|
|
130
132
|
const body = superStringify({
|
|
131
|
-
'command':
|
|
133
|
+
'command': command,
|
|
132
134
|
'parameter': 'default',
|
|
133
|
-
'commandType':
|
|
135
|
+
'commandType': commandType,
|
|
134
136
|
});
|
|
135
137
|
await this.pushChanges(body);
|
|
136
138
|
}
|
|
137
139
|
}
|
|
138
140
|
|
|
139
141
|
async pushAirPurifierOffChanges(): Promise<void> {
|
|
142
|
+
const commandType: string = await this.commandType();
|
|
143
|
+
const command: string = await this.commandOff();
|
|
140
144
|
if (this.Active !== 0) {
|
|
141
145
|
const body = superStringify({
|
|
142
|
-
'command':
|
|
146
|
+
'command': command,
|
|
143
147
|
'parameter': 'default',
|
|
144
|
-
'commandType':
|
|
148
|
+
'commandType': commandType,
|
|
145
149
|
});
|
|
146
150
|
await this.pushChanges(body);
|
|
147
151
|
}
|
|
@@ -263,6 +267,36 @@ export class AirPurifier {
|
|
|
263
267
|
}
|
|
264
268
|
}
|
|
265
269
|
|
|
270
|
+
async commandType() {
|
|
271
|
+
let commandType: string;
|
|
272
|
+
if (this.device.customize) {
|
|
273
|
+
commandType = 'customize';
|
|
274
|
+
} else {
|
|
275
|
+
commandType = 'command';
|
|
276
|
+
}
|
|
277
|
+
return commandType;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
async commandOn() {
|
|
281
|
+
let command: string;
|
|
282
|
+
if (this.device.customize && this.device.customOn) {
|
|
283
|
+
command = this.device.customOn;
|
|
284
|
+
} else {
|
|
285
|
+
command = 'turnOn';
|
|
286
|
+
}
|
|
287
|
+
return command;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
async commandOff() {
|
|
291
|
+
let command: string;
|
|
292
|
+
if (this.device.customize && this.device.customOn) {
|
|
293
|
+
command = this.device.customOn;
|
|
294
|
+
} else {
|
|
295
|
+
command = 'turnOff';
|
|
296
|
+
}
|
|
297
|
+
return command;
|
|
298
|
+
}
|
|
299
|
+
|
|
266
300
|
async statusCode({ res }: { res: IncomingMessage }): Promise<void> {
|
|
267
301
|
switch (res.statusCode) {
|
|
268
302
|
case 151:
|
package/src/irdevice/camera.ts
CHANGED
|
@@ -77,21 +77,25 @@ export class Camera {
|
|
|
77
77
|
*/
|
|
78
78
|
async pushOnChanges(): Promise<void> {
|
|
79
79
|
if (this.On) {
|
|
80
|
+
const commandType: string = await this.commandType();
|
|
81
|
+
const command: string = await this.commandOn();
|
|
80
82
|
const body = superStringify({
|
|
81
|
-
'command':
|
|
83
|
+
'command': command,
|
|
82
84
|
'parameter': 'default',
|
|
83
|
-
'commandType':
|
|
85
|
+
'commandType': commandType,
|
|
84
86
|
});
|
|
85
87
|
await this.pushChanges(body);
|
|
86
88
|
}
|
|
87
89
|
}
|
|
88
90
|
|
|
89
91
|
async pushOffChanges(): Promise<void> {
|
|
92
|
+
const commandType: string = await this.commandType();
|
|
93
|
+
const command: string = await this.commandOff();
|
|
90
94
|
if (!this.On) {
|
|
91
95
|
const body = superStringify({
|
|
92
|
-
'command':
|
|
96
|
+
'command': command,
|
|
93
97
|
'parameter': 'default',
|
|
94
|
-
'commandType':
|
|
98
|
+
'commandType': commandType,
|
|
95
99
|
});
|
|
96
100
|
await this.pushChanges(body);
|
|
97
101
|
}
|
|
@@ -160,6 +164,36 @@ export class Camera {
|
|
|
160
164
|
}
|
|
161
165
|
}
|
|
162
166
|
|
|
167
|
+
async commandType() {
|
|
168
|
+
let commandType: string;
|
|
169
|
+
if (this.device.customize) {
|
|
170
|
+
commandType = 'customize';
|
|
171
|
+
} else {
|
|
172
|
+
commandType = 'command';
|
|
173
|
+
}
|
|
174
|
+
return commandType;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
async commandOn() {
|
|
178
|
+
let command: string;
|
|
179
|
+
if (this.device.customize && this.device.customOn) {
|
|
180
|
+
command = this.device.customOn;
|
|
181
|
+
} else {
|
|
182
|
+
command = 'turnOn';
|
|
183
|
+
}
|
|
184
|
+
return command;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
async commandOff() {
|
|
188
|
+
let command: string;
|
|
189
|
+
if (this.device.customize && this.device.customOn) {
|
|
190
|
+
command = this.device.customOn;
|
|
191
|
+
} else {
|
|
192
|
+
command = 'turnOff';
|
|
193
|
+
}
|
|
194
|
+
return command;
|
|
195
|
+
}
|
|
196
|
+
|
|
163
197
|
async statusCode({ res }: { res: IncomingMessage }): Promise<void> {
|
|
164
198
|
switch (res.statusCode) {
|
|
165
199
|
case 151:
|
package/src/irdevice/fan.ts
CHANGED
|
@@ -167,20 +167,24 @@ export class Fan {
|
|
|
167
167
|
*/
|
|
168
168
|
async pushFanOnChanges(): Promise<void> {
|
|
169
169
|
if (this.Active !== 1) {
|
|
170
|
+
const commandType: string = await this.commandType();
|
|
171
|
+
const command: string = await this.commandOn();
|
|
170
172
|
const body = superStringify({
|
|
171
|
-
'command':
|
|
173
|
+
'command': command,
|
|
172
174
|
'parameter': 'default',
|
|
173
|
-
'commandType':
|
|
175
|
+
'commandType': commandType,
|
|
174
176
|
});
|
|
175
177
|
await this.pushTVChanges(body);
|
|
176
178
|
}
|
|
177
179
|
}
|
|
178
180
|
|
|
179
181
|
async pushFanOffChanges(): Promise<void> {
|
|
182
|
+
const commandType: string = await this.commandType();
|
|
183
|
+
const command: string = await this.commandOff();
|
|
180
184
|
const body = superStringify({
|
|
181
|
-
'command':
|
|
185
|
+
'command': command,
|
|
182
186
|
'parameter': 'default',
|
|
183
|
-
'commandType':
|
|
187
|
+
'commandType': commandType,
|
|
184
188
|
});
|
|
185
189
|
await this.pushTVChanges(body);
|
|
186
190
|
}
|
|
@@ -289,6 +293,36 @@ export class Fan {
|
|
|
289
293
|
}
|
|
290
294
|
}
|
|
291
295
|
|
|
296
|
+
async commandType() {
|
|
297
|
+
let commandType: string;
|
|
298
|
+
if (this.device.customize) {
|
|
299
|
+
commandType = 'customize';
|
|
300
|
+
} else {
|
|
301
|
+
commandType = 'command';
|
|
302
|
+
}
|
|
303
|
+
return commandType;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
async commandOn() {
|
|
307
|
+
let command: string;
|
|
308
|
+
if (this.device.customize && this.device.customOn) {
|
|
309
|
+
command = this.device.customOn;
|
|
310
|
+
} else {
|
|
311
|
+
command = 'turnOn';
|
|
312
|
+
}
|
|
313
|
+
return command;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
async commandOff() {
|
|
317
|
+
let command: string;
|
|
318
|
+
if (this.device.customize && this.device.customOn) {
|
|
319
|
+
command = this.device.customOn;
|
|
320
|
+
} else {
|
|
321
|
+
command = 'turnOff';
|
|
322
|
+
}
|
|
323
|
+
return command;
|
|
324
|
+
}
|
|
325
|
+
|
|
292
326
|
async statusCode({ res }: { res: IncomingMessage }): Promise<void> {
|
|
293
327
|
switch (res.statusCode) {
|
|
294
328
|
case 151:
|
package/src/irdevice/light.ts
CHANGED
|
@@ -77,10 +77,12 @@ export class Light {
|
|
|
77
77
|
*/
|
|
78
78
|
async pushLightOnChanges(): Promise<void> {
|
|
79
79
|
if (this.On) {
|
|
80
|
+
const commandType: string = await this.commandType();
|
|
81
|
+
const command: string = await this.commandOn();
|
|
80
82
|
const body = superStringify({
|
|
81
|
-
'command':
|
|
83
|
+
'command': command,
|
|
82
84
|
'parameter': 'default',
|
|
83
|
-
'commandType':
|
|
85
|
+
'commandType': commandType,
|
|
84
86
|
});
|
|
85
87
|
await this.pushChanges(body);
|
|
86
88
|
}
|
|
@@ -88,10 +90,12 @@ export class Light {
|
|
|
88
90
|
|
|
89
91
|
async pushLightOffChanges(): Promise<void> {
|
|
90
92
|
if (!this.On) {
|
|
93
|
+
const commandType: string = await this.commandType();
|
|
94
|
+
const command: string = await this.commandOff();
|
|
91
95
|
const body = superStringify({
|
|
92
|
-
'command':
|
|
96
|
+
'command': command,
|
|
93
97
|
'parameter': 'default',
|
|
94
|
-
'commandType':
|
|
98
|
+
'commandType': commandType,
|
|
95
99
|
});
|
|
96
100
|
await this.pushChanges(body);
|
|
97
101
|
}
|
|
@@ -179,6 +183,36 @@ export class Light {
|
|
|
179
183
|
}
|
|
180
184
|
}
|
|
181
185
|
|
|
186
|
+
async commandType() {
|
|
187
|
+
let commandType: string;
|
|
188
|
+
if (this.device.customize) {
|
|
189
|
+
commandType = 'customize';
|
|
190
|
+
} else {
|
|
191
|
+
commandType = 'command';
|
|
192
|
+
}
|
|
193
|
+
return commandType;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
async commandOn() {
|
|
197
|
+
let command: string;
|
|
198
|
+
if (this.device.customize && this.device.customOn) {
|
|
199
|
+
command = this.device.customOn;
|
|
200
|
+
} else {
|
|
201
|
+
command = 'turnOn';
|
|
202
|
+
}
|
|
203
|
+
return command;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
async commandOff() {
|
|
207
|
+
let command: string;
|
|
208
|
+
if (this.device.customize && this.device.customOn) {
|
|
209
|
+
command = this.device.customOn;
|
|
210
|
+
} else {
|
|
211
|
+
command = 'turnOff';
|
|
212
|
+
}
|
|
213
|
+
return command;
|
|
214
|
+
}
|
|
215
|
+
|
|
182
216
|
async statusCode({ res }: { res: IncomingMessage }): Promise<void> {
|
|
183
217
|
switch (res.statusCode) {
|
|
184
218
|
case 151:
|
package/src/irdevice/other.ts
CHANGED
|
@@ -84,22 +84,16 @@ export class Others {
|
|
|
84
84
|
* Other - "command" "channelSub" "default" = previous channel
|
|
85
85
|
*/
|
|
86
86
|
async pushOnChanges(): Promise<void> {
|
|
87
|
-
if (this.
|
|
88
|
-
if (this.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
} else {
|
|
99
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} On Command not set, commandOn: ${this.device.other.commandOn}`);
|
|
100
|
-
}
|
|
101
|
-
} else {
|
|
102
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} On Command not set, other: ${this.device.other}`);
|
|
87
|
+
if (this.device.customize) {
|
|
88
|
+
if (!this.Active) {
|
|
89
|
+
const commandType: string = await this.commandType();
|
|
90
|
+
const command: string = await this.commandOn();
|
|
91
|
+
const body = superStringify({
|
|
92
|
+
'command': command,
|
|
93
|
+
'parameter': 'default',
|
|
94
|
+
'commandType': commandType,
|
|
95
|
+
});
|
|
96
|
+
await this.pushChanges(body);
|
|
103
97
|
}
|
|
104
98
|
} else {
|
|
105
99
|
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} On Command not set`);
|
|
@@ -107,22 +101,16 @@ export class Others {
|
|
|
107
101
|
}
|
|
108
102
|
|
|
109
103
|
async pushOffChanges(): Promise<void> {
|
|
110
|
-
if (this.
|
|
111
|
-
if (this.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
} else {
|
|
122
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Off Command not set, commandOff: ${this.device.other.commandOff}`);
|
|
123
|
-
}
|
|
124
|
-
} else {
|
|
125
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Off Command not set, other: ${this.device.other}`);
|
|
104
|
+
if (this.device.customize) {
|
|
105
|
+
if (this.Active) {
|
|
106
|
+
const commandType: string = await this.commandType();
|
|
107
|
+
const command: string = await this.commandOff();
|
|
108
|
+
const body = superStringify({
|
|
109
|
+
'command': command,
|
|
110
|
+
'parameter': 'default',
|
|
111
|
+
'commandType': commandType,
|
|
112
|
+
});
|
|
113
|
+
await this.pushChanges(body);
|
|
126
114
|
}
|
|
127
115
|
} else {
|
|
128
116
|
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Off Command not set.`);
|
|
@@ -191,6 +179,36 @@ export class Others {
|
|
|
191
179
|
}
|
|
192
180
|
}
|
|
193
181
|
|
|
182
|
+
async commandType() {
|
|
183
|
+
let commandType: string;
|
|
184
|
+
if (this.device.customize) {
|
|
185
|
+
commandType = 'customize';
|
|
186
|
+
} else {
|
|
187
|
+
commandType = 'command';
|
|
188
|
+
}
|
|
189
|
+
return commandType;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
async commandOn() {
|
|
193
|
+
let command: string;
|
|
194
|
+
if (this.device.customize && this.device.customOn) {
|
|
195
|
+
command = this.device.customOn;
|
|
196
|
+
} else {
|
|
197
|
+
command = 'turnOn';
|
|
198
|
+
}
|
|
199
|
+
return command;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
async commandOff() {
|
|
203
|
+
let command: string;
|
|
204
|
+
if (this.device.customize && this.device.customOn) {
|
|
205
|
+
command = this.device.customOn;
|
|
206
|
+
} else {
|
|
207
|
+
command = 'turnOff';
|
|
208
|
+
}
|
|
209
|
+
return command;
|
|
210
|
+
}
|
|
211
|
+
|
|
194
212
|
async statusCode({ res }: { res: IncomingMessage }): Promise<void> {
|
|
195
213
|
switch (res.statusCode) {
|
|
196
214
|
case 151:
|
package/src/irdevice/tv.ts
CHANGED
|
@@ -221,20 +221,24 @@ export class TV {
|
|
|
221
221
|
*/
|
|
222
222
|
async pushTvOnChanges(): Promise<void> {
|
|
223
223
|
if (this.Active !== 1) {
|
|
224
|
+
const commandType: string = await this.commandType();
|
|
225
|
+
const command: string = await this.commandOn();
|
|
224
226
|
const body = superStringify({
|
|
225
|
-
'command':
|
|
227
|
+
'command': command,
|
|
226
228
|
'parameter': 'default',
|
|
227
|
-
'commandType':
|
|
229
|
+
'commandType': commandType,
|
|
228
230
|
});
|
|
229
231
|
await this.pushTVChanges(body);
|
|
230
232
|
}
|
|
231
233
|
}
|
|
232
234
|
|
|
233
235
|
async pushTvOffChanges(): Promise<void> {
|
|
236
|
+
const commandType: string = await this.commandType();
|
|
237
|
+
const command: string = await this.commandOff();
|
|
234
238
|
const body = superStringify({
|
|
235
|
-
'command':
|
|
239
|
+
'command': command,
|
|
236
240
|
'parameter': 'default',
|
|
237
|
-
'commandType':
|
|
241
|
+
'commandType': commandType,
|
|
238
242
|
});
|
|
239
243
|
await this.pushTVChanges(body);
|
|
240
244
|
}
|
|
@@ -392,6 +396,36 @@ export class TV {
|
|
|
392
396
|
}
|
|
393
397
|
}
|
|
394
398
|
|
|
399
|
+
async commandType() {
|
|
400
|
+
let commandType: string;
|
|
401
|
+
if (this.device.customize) {
|
|
402
|
+
commandType = 'customize';
|
|
403
|
+
} else {
|
|
404
|
+
commandType = 'command';
|
|
405
|
+
}
|
|
406
|
+
return commandType;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
async commandOn() {
|
|
410
|
+
let command: string;
|
|
411
|
+
if (this.device.customize && this.device.customOn) {
|
|
412
|
+
command = this.device.customOn;
|
|
413
|
+
} else {
|
|
414
|
+
command = 'turnOn';
|
|
415
|
+
}
|
|
416
|
+
return command;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
async commandOff() {
|
|
420
|
+
let command: string;
|
|
421
|
+
if (this.device.customize && this.device.customOn) {
|
|
422
|
+
command = this.device.customOn;
|
|
423
|
+
} else {
|
|
424
|
+
command = 'turnOff';
|
|
425
|
+
}
|
|
426
|
+
return command;
|
|
427
|
+
}
|
|
428
|
+
|
|
395
429
|
async statusCode({ res }: { res: IncomingMessage }): Promise<void> {
|
|
396
430
|
switch (res.statusCode) {
|
|
397
431
|
case 151:
|
|
@@ -73,10 +73,12 @@ export class VacuumCleaner {
|
|
|
73
73
|
*/
|
|
74
74
|
async pushOnChanges(): Promise<void> {
|
|
75
75
|
if (this.On) {
|
|
76
|
+
const commandType: string = await this.commandType();
|
|
77
|
+
const command: string = await this.commandOn();
|
|
76
78
|
const body = superStringify({
|
|
77
|
-
'command':
|
|
79
|
+
'command': command,
|
|
78
80
|
'parameter': 'default',
|
|
79
|
-
'commandType':
|
|
81
|
+
'commandType': commandType,
|
|
80
82
|
});
|
|
81
83
|
await this.pushChanges(body);
|
|
82
84
|
}
|
|
@@ -84,10 +86,12 @@ export class VacuumCleaner {
|
|
|
84
86
|
|
|
85
87
|
async pushOffChanges(): Promise<void> {
|
|
86
88
|
if (!this.On) {
|
|
89
|
+
const commandType: string = await this.commandType();
|
|
90
|
+
const command: string = await this.commandOff();
|
|
87
91
|
const body = superStringify({
|
|
88
|
-
'command':
|
|
92
|
+
'command': command,
|
|
89
93
|
'parameter': 'default',
|
|
90
|
-
'commandType':
|
|
94
|
+
'commandType': commandType,
|
|
91
95
|
});
|
|
92
96
|
await this.pushChanges(body);
|
|
93
97
|
}
|
|
@@ -157,6 +161,36 @@ export class VacuumCleaner {
|
|
|
157
161
|
}
|
|
158
162
|
}
|
|
159
163
|
|
|
164
|
+
async commandType() {
|
|
165
|
+
let commandType: string;
|
|
166
|
+
if (this.device.customize) {
|
|
167
|
+
commandType = 'customize';
|
|
168
|
+
} else {
|
|
169
|
+
commandType = 'command';
|
|
170
|
+
}
|
|
171
|
+
return commandType;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async commandOn() {
|
|
175
|
+
let command: string;
|
|
176
|
+
if (this.device.customize && this.device.customOn) {
|
|
177
|
+
command = this.device.customOn;
|
|
178
|
+
} else {
|
|
179
|
+
command = 'turnOn';
|
|
180
|
+
}
|
|
181
|
+
return command;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
async commandOff() {
|
|
185
|
+
let command: string;
|
|
186
|
+
if (this.device.customize && this.device.customOn) {
|
|
187
|
+
command = this.device.customOn;
|
|
188
|
+
} else {
|
|
189
|
+
command = 'turnOff';
|
|
190
|
+
}
|
|
191
|
+
return command;
|
|
192
|
+
}
|
|
193
|
+
|
|
160
194
|
async statusCode({ res }: { res: IncomingMessage }): Promise<void> {
|
|
161
195
|
switch (res.statusCode) {
|
|
162
196
|
case 151:
|
|
@@ -78,10 +78,12 @@ export class WaterHeater {
|
|
|
78
78
|
*/
|
|
79
79
|
async pushWaterHeaterOnChanges(): Promise<void> {
|
|
80
80
|
if (this.Active !== 1) {
|
|
81
|
+
const commandType: string = await this.commandType();
|
|
82
|
+
const command: string = await this.commandOn();
|
|
81
83
|
const body = superStringify({
|
|
82
|
-
'command':
|
|
84
|
+
'command': command,
|
|
83
85
|
'parameter': 'default',
|
|
84
|
-
'commandType':
|
|
86
|
+
'commandType': commandType,
|
|
85
87
|
});
|
|
86
88
|
await this.pushChanges(body);
|
|
87
89
|
}
|
|
@@ -89,10 +91,12 @@ export class WaterHeater {
|
|
|
89
91
|
|
|
90
92
|
async pushWaterHeaterOffChanges(): Promise<void> {
|
|
91
93
|
if (this.Active !== 0) {
|
|
94
|
+
const commandType: string = await this.commandType();
|
|
95
|
+
const command: string = await this.commandOff();
|
|
92
96
|
const body = superStringify({
|
|
93
|
-
'command':
|
|
97
|
+
'command': command,
|
|
94
98
|
'parameter': 'default',
|
|
95
|
-
'commandType':
|
|
99
|
+
'commandType': commandType,
|
|
96
100
|
});
|
|
97
101
|
await this.pushChanges(body);
|
|
98
102
|
}
|
|
@@ -160,6 +164,36 @@ export class WaterHeater {
|
|
|
160
164
|
}
|
|
161
165
|
}
|
|
162
166
|
|
|
167
|
+
async commandType() {
|
|
168
|
+
let commandType: string;
|
|
169
|
+
if (this.device.customize) {
|
|
170
|
+
commandType = 'customize';
|
|
171
|
+
} else {
|
|
172
|
+
commandType = 'command';
|
|
173
|
+
}
|
|
174
|
+
return commandType;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
async commandOn() {
|
|
178
|
+
let command: string;
|
|
179
|
+
if (this.device.customize && this.device.customOn) {
|
|
180
|
+
command = this.device.customOn;
|
|
181
|
+
} else {
|
|
182
|
+
command = 'turnOn';
|
|
183
|
+
}
|
|
184
|
+
return command;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
async commandOff() {
|
|
188
|
+
let command: string;
|
|
189
|
+
if (this.device.customize && this.device.customOn) {
|
|
190
|
+
command = this.device.customOn;
|
|
191
|
+
} else {
|
|
192
|
+
command = 'turnOff';
|
|
193
|
+
}
|
|
194
|
+
return command;
|
|
195
|
+
}
|
|
196
|
+
|
|
163
197
|
async statusCode({ res }: { res: IncomingMessage }): Promise<void> {
|
|
164
198
|
switch (res.statusCode) {
|
|
165
199
|
case 151:
|
package/src/platform.ts
CHANGED
|
@@ -58,7 +58,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
58
58
|
|
|
59
59
|
// HOOBS notice
|
|
60
60
|
if (__dirname.includes('hoobs')) {
|
|
61
|
-
this.
|
|
61
|
+
this.warnLog('This plugin has not been tested under HOOBS, it is highly recommended that you switch to Homebridge: '
|
|
62
|
+
+ 'https://tinyurl.com/HOOBS2Homebridge');
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
// verify the config
|
|
@@ -66,7 +67,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
66
67
|
this.verifyConfig();
|
|
67
68
|
this.debugLog('Config OK');
|
|
68
69
|
} catch (e: any) {
|
|
69
|
-
this.errorLog(`Verify Config, Error Message: ${e.message}`);
|
|
70
|
+
this.errorLog(`Verify Config, Error Message: ${e.message}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
|
|
70
71
|
this.debugErrorLog(`Verify Config, Error: ${e}`);
|
|
71
72
|
return;
|
|
72
73
|
}
|
|
@@ -91,7 +92,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
91
92
|
this.discoverDevices();
|
|
92
93
|
}
|
|
93
94
|
} catch (e: any) {
|
|
94
|
-
this.errorLog(`Failed to Discover, Error Message: ${e.message}`);
|
|
95
|
+
this.errorLog(`Failed to Discover, Error Message: ${e.message}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
|
|
95
96
|
this.debugErrorLog(`Failed to Discover, Error: ${e}`);
|
|
96
97
|
}
|
|
97
98
|
});
|
|
@@ -340,7 +341,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
340
341
|
this.errorLog('SwitchBot Token Supplied, Issue with Auth.');
|
|
341
342
|
}
|
|
342
343
|
} else {
|
|
343
|
-
this.errorLog(`SwitchBot Device Request Issue: ${this.deviceStatus}`);
|
|
344
|
+
this.errorLog(`SwitchBot Device Request Issue: ${this.deviceStatus}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
|
|
344
345
|
}
|
|
345
346
|
// IR Devices
|
|
346
347
|
/*if (devicesAPI.body.infraredRemoteList.length !== 0) {
|
|
@@ -388,15 +389,15 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
388
389
|
}
|
|
389
390
|
}
|
|
390
391
|
} else {
|
|
391
|
-
this.errorLog(`SwitchBot IR Device Request Issue: ${this.deviceStatus}`);
|
|
392
|
+
this.errorLog(`SwitchBot IR Device Request Issue: ${this.deviceStatus}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
|
|
392
393
|
}
|
|
393
394
|
} catch (e:any) {
|
|
394
|
-
this.errorLog(`API Request: ${e}`);
|
|
395
|
+
this.errorLog(`API Request: ${e}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
|
|
395
396
|
}
|
|
396
397
|
});
|
|
397
398
|
});
|
|
398
399
|
req.on('error', (e: any) => {
|
|
399
|
-
this.errorLog(`req: ${e}`);
|
|
400
|
+
this.errorLog(`req: ${e}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
|
|
400
401
|
});
|
|
401
402
|
req.end();
|
|
402
403
|
} else if (!this.config.credentials?.token && this.config.options?.devices) {
|
|
@@ -414,7 +415,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
414
415
|
this.errorLog('Neither SwitchBot Token or Device Config are not set.');
|
|
415
416
|
}
|
|
416
417
|
} catch (e: any) {
|
|
417
|
-
this.debugErrorLog(`Failed to Discover Devices, Error Message: ${superStringify(e.message)}`
|
|
418
|
+
this.debugErrorLog(`Failed to Discover Devices, Error Message: ${superStringify(e.message)}, Submit Bugs Here: `
|
|
419
|
+
+ 'https://tinyurl.com/SwitchBotBug');
|
|
418
420
|
this.debugErrorLog(`Failed to Discover Devices, Error: ${e}`);
|
|
419
421
|
}
|
|
420
422
|
}
|
|
@@ -486,7 +488,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
486
488
|
break;
|
|
487
489
|
default:
|
|
488
490
|
this.warnLog(`Device: ${device.deviceName} with Device Type: ${device.deviceType}, is currently not supported.`);
|
|
489
|
-
|
|
491
|
+
// eslint-disable-next-line max-len
|
|
492
|
+
this.warnLog('Submit Feature Requests Here: ' + 'https://tinyurl.com/SwitchBotFeatureRequest');
|
|
490
493
|
}
|
|
491
494
|
}
|
|
492
495
|
|
|
@@ -549,7 +552,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
549
552
|
default:
|
|
550
553
|
this.debugLog(`Unsupported Device: ${superStringify(device)}`);
|
|
551
554
|
this.warnLog(`Device: ${device.deviceName} with Device Type: ${device.remoteType}, is currently not supported.`);
|
|
552
|
-
this.warnLog('Submit Feature Requests Here: https://
|
|
555
|
+
this.warnLog('Submit Feature Requests Here: ' + 'https://tinyurl.com/SwitchBotFeatureRequest');
|
|
553
556
|
}
|
|
554
557
|
}
|
|
555
558
|
|
|
@@ -1852,13 +1855,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1852
1855
|
async statusCode({ res }: { res: IncomingMessage }): Promise<void> {
|
|
1853
1856
|
switch (res.statusCode) {
|
|
1854
1857
|
case 151:
|
|
1855
|
-
this.errorLog('Command not supported by this device type.');
|
|
1858
|
+
this.errorLog('Command not supported by this device type, Submit Feature Request Here: ' + 'https://tinyurl.com/SwitchBotFeatureRequest');
|
|
1856
1859
|
break;
|
|
1857
1860
|
case 152:
|
|
1858
1861
|
this.errorLog('Device not found.');
|
|
1859
1862
|
break;
|
|
1860
1863
|
case 160:
|
|
1861
|
-
this.errorLog('Command is not supported.');
|
|
1864
|
+
this.errorLog('Command is not supported, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug');
|
|
1862
1865
|
break;
|
|
1863
1866
|
case 161:
|
|
1864
1867
|
this.errorLog('Device is offline.');
|
|
@@ -1876,7 +1879,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1876
1879
|
break;
|
|
1877
1880
|
default:
|
|
1878
1881
|
if (this.debugMode) {
|
|
1879
|
-
this.debugLog('Unknown statusCode.');
|
|
1882
|
+
this.debugLog('Unknown statusCode, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug');
|
|
1880
1883
|
}
|
|
1881
1884
|
}
|
|
1882
1885
|
}
|