@switchbot/homebridge-switchbot 2.7.1 → 2.8.0-beta.1
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/.prettierrc +1 -1
- package/.vscode/settings.json +1 -1
- package/CHANGELOG.md +10 -0
- package/config.schema.json +8 -0
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +49 -59
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +44 -50
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +60 -63
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +68 -70
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +22 -25
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +50 -58
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts +6 -0
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +168 -26
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +49 -56
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +18 -20
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +59 -61
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +40 -41
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +3 -3
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +65 -68
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +18 -20
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +20 -23
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +30 -33
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +48 -51
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +57 -61
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +29 -31
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +17 -20
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +27 -29
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +23 -26
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +19 -20
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +44 -47
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +17 -20
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +19 -20
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +44 -43
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +1 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/device/blindtilt.ts +106 -72
- package/src/device/bot.ts +94 -58
- package/src/device/ceilinglight.ts +102 -68
- package/src/device/colorbulb.ts +134 -82
- package/src/device/contact.ts +54 -33
- package/src/device/curtain.ts +130 -101
- package/src/device/hub.ts +198 -35
- package/src/device/humidifier.ts +128 -80
- package/src/device/iosensor.ts +43 -27
- package/src/device/lightstrip.ts +108 -67
- package/src/device/lock.ts +73 -45
- package/src/device/meter.ts +94 -75
- package/src/device/meterplus.ts +43 -27
- package/src/device/motion.ts +50 -32
- package/src/device/plug.ts +62 -39
- package/src/device/robotvacuumcleaner.ts +78 -54
- package/src/irdevice/airconditioner.ts +111 -83
- package/src/irdevice/airpurifier.ts +55 -34
- package/src/irdevice/camera.ts +35 -23
- package/src/irdevice/fan.ts +47 -33
- package/src/irdevice/light.ts +43 -29
- package/src/irdevice/other.ts +39 -23
- package/src/irdevice/tv.ts +65 -51
- package/src/irdevice/vacuumcleaner.ts +35 -23
- package/src/irdevice/waterheater.ts +43 -27
- package/src/platform.ts +85 -55
- package/src/settings.ts +41 -40
- package/src/utils.ts +1 -1
package/src/irdevice/camera.ts
CHANGED
|
@@ -20,7 +20,11 @@ export class Camera {
|
|
|
20
20
|
disablePushOff?: boolean;
|
|
21
21
|
deviceLogging!: string;
|
|
22
22
|
|
|
23
|
-
constructor(
|
|
23
|
+
constructor(
|
|
24
|
+
private readonly platform: SwitchBotPlatform,
|
|
25
|
+
private accessory: PlatformAccessory,
|
|
26
|
+
public device: irdevice & irDevicesConfig,
|
|
27
|
+
) {
|
|
24
28
|
// default placeholders
|
|
25
29
|
this.logs(device);
|
|
26
30
|
this.config(device);
|
|
@@ -80,30 +84,30 @@ export class Camera {
|
|
|
80
84
|
* Camera - "command" "channelSub" "default" = previous channel
|
|
81
85
|
*/
|
|
82
86
|
async pushOnChanges(): Promise<void> {
|
|
83
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOnChanges On: ${this.On},`
|
|
84
|
-
+ ` disablePushOn: ${this.disablePushOn}`);
|
|
87
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOnChanges On: ${this.On},` + ` disablePushOn: ${this.disablePushOn}`);
|
|
85
88
|
if (this.On && !this.disablePushOn) {
|
|
86
89
|
const commandType: string = await this.commandType();
|
|
87
90
|
const command: string = await this.commandOn();
|
|
88
91
|
const bodyChange = JSON.stringify({
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
command: command,
|
|
93
|
+
parameter: 'default',
|
|
94
|
+
commandType: commandType,
|
|
92
95
|
});
|
|
93
96
|
await this.pushChanges(bodyChange);
|
|
94
97
|
}
|
|
95
98
|
}
|
|
96
99
|
|
|
97
100
|
async pushOffChanges(): Promise<void> {
|
|
98
|
-
this.debugLog(
|
|
99
|
-
+ ` disablePushOff: ${this.disablePushOff}
|
|
101
|
+
this.debugLog(
|
|
102
|
+
`${this.device.remoteType}: ${this.accessory.displayName} pushOffChanges On: ${this.On},` + ` disablePushOff: ${this.disablePushOff}`,
|
|
103
|
+
);
|
|
100
104
|
if (!this.On && !this.disablePushOff) {
|
|
101
105
|
const commandType: string = await this.commandType();
|
|
102
106
|
const command: string = await this.commandOff();
|
|
103
107
|
const bodyChange = JSON.stringify({
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
108
|
+
command: command,
|
|
109
|
+
parameter: 'default',
|
|
110
|
+
commandType: commandType,
|
|
107
111
|
});
|
|
108
112
|
await this.pushChanges(bodyChange);
|
|
109
113
|
}
|
|
@@ -126,13 +130,16 @@ export class Camera {
|
|
|
126
130
|
this.updateHomeKitCharacteristics();
|
|
127
131
|
} catch (e: any) {
|
|
128
132
|
this.apiError(e);
|
|
129
|
-
this.errorLog(
|
|
130
|
-
|
|
133
|
+
this.errorLog(
|
|
134
|
+
`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}` +
|
|
135
|
+
` Connection, Error Message: ${JSON.stringify(e.message)}`,
|
|
131
136
|
);
|
|
132
137
|
}
|
|
133
138
|
} else {
|
|
134
|
-
this.warnLog(
|
|
135
|
-
|
|
139
|
+
this.warnLog(
|
|
140
|
+
`${this.device.remoteType}: ${this.accessory.displayName}` +
|
|
141
|
+
` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`,
|
|
142
|
+
);
|
|
136
143
|
}
|
|
137
144
|
}
|
|
138
145
|
|
|
@@ -146,7 +153,7 @@ export class Camera {
|
|
|
146
153
|
}
|
|
147
154
|
}
|
|
148
155
|
|
|
149
|
-
async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig
|
|
156
|
+
async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
|
|
150
157
|
if (device.disablePushOn === undefined) {
|
|
151
158
|
this.disablePushOn = false;
|
|
152
159
|
} else {
|
|
@@ -154,7 +161,7 @@ export class Camera {
|
|
|
154
161
|
}
|
|
155
162
|
}
|
|
156
163
|
|
|
157
|
-
async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig
|
|
164
|
+
async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
|
|
158
165
|
if (device.disablePushOff === undefined) {
|
|
159
166
|
this.disablePushOff = false;
|
|
160
167
|
} else {
|
|
@@ -207,8 +214,10 @@ export class Camera {
|
|
|
207
214
|
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline, statusCode: ${statusCode}`);
|
|
208
215
|
break;
|
|
209
216
|
case 171:
|
|
210
|
-
this.errorLog(
|
|
211
|
-
|
|
217
|
+
this.errorLog(
|
|
218
|
+
`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
|
|
219
|
+
`Hub: ${this.device.hubDeviceId}`,
|
|
220
|
+
);
|
|
212
221
|
break;
|
|
213
222
|
case 190:
|
|
214
223
|
this.errorLog(
|
|
@@ -223,8 +232,10 @@ export class Camera {
|
|
|
223
232
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
|
|
224
233
|
break;
|
|
225
234
|
default:
|
|
226
|
-
this.infoLog(
|
|
227
|
-
|
|
235
|
+
this.infoLog(
|
|
236
|
+
`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: ` +
|
|
237
|
+
`${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
|
|
238
|
+
);
|
|
228
239
|
}
|
|
229
240
|
}
|
|
230
241
|
|
|
@@ -234,8 +245,9 @@ export class Camera {
|
|
|
234
245
|
|
|
235
246
|
FirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): string {
|
|
236
247
|
let FirmwareRevision: string;
|
|
237
|
-
this.debugLog(
|
|
238
|
-
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}
|
|
248
|
+
this.debugLog(
|
|
249
|
+
`${this.device.remoteType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
|
|
250
|
+
);
|
|
239
251
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
240
252
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
241
253
|
if (accessory.context.FirmwareRevision) {
|
package/src/irdevice/fan.ts
CHANGED
|
@@ -30,7 +30,11 @@ export class Fan {
|
|
|
30
30
|
disablePushOff?: boolean;
|
|
31
31
|
deviceLogging!: string;
|
|
32
32
|
|
|
33
|
-
constructor(
|
|
33
|
+
constructor(
|
|
34
|
+
private readonly platform: SwitchBotPlatform,
|
|
35
|
+
private accessory: PlatformAccessory,
|
|
36
|
+
public device: irdevice & irDevicesConfig,
|
|
37
|
+
) {
|
|
34
38
|
// default placeholders
|
|
35
39
|
this.logs(device);
|
|
36
40
|
this.config(device);
|
|
@@ -170,30 +174,33 @@ export class Fan {
|
|
|
170
174
|
* Fan - "command" "highSpeed" "default" = fan speed to high
|
|
171
175
|
*/
|
|
172
176
|
async pushFanOnChanges(): Promise<void> {
|
|
173
|
-
this.debugLog(
|
|
174
|
-
+ ` disablePushOn: ${this.disablePushOn}
|
|
177
|
+
this.debugLog(
|
|
178
|
+
`${this.device.remoteType}: ${this.accessory.displayName} pushFanOnChanges Active: ${this.Active},` + ` disablePushOn: ${this.disablePushOn}`,
|
|
179
|
+
);
|
|
175
180
|
if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
176
181
|
const commandType: string = await this.commandType();
|
|
177
182
|
const command: string = await this.commandOn();
|
|
178
183
|
const bodyChange = JSON.stringify({
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
184
|
+
command: command,
|
|
185
|
+
parameter: 'default',
|
|
186
|
+
commandType: commandType,
|
|
182
187
|
});
|
|
183
188
|
await this.pushChanges(bodyChange);
|
|
184
189
|
}
|
|
185
190
|
}
|
|
186
191
|
|
|
187
192
|
async pushFanOffChanges(): Promise<void> {
|
|
188
|
-
this.debugLog(
|
|
189
|
-
|
|
193
|
+
this.debugLog(
|
|
194
|
+
`${this.device.remoteType}: ${this.accessory.displayName} pushLightOffChanges Active: ${this.Active},` +
|
|
195
|
+
` disablePushOff: ${this.disablePushOff}`,
|
|
196
|
+
);
|
|
190
197
|
if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOff) {
|
|
191
198
|
const commandType: string = await this.commandType();
|
|
192
199
|
const command: string = await this.commandOff();
|
|
193
200
|
const bodyChange = JSON.stringify({
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
201
|
+
command: command,
|
|
202
|
+
parameter: 'default',
|
|
203
|
+
commandType: commandType,
|
|
197
204
|
});
|
|
198
205
|
await this.pushChanges(bodyChange);
|
|
199
206
|
}
|
|
@@ -201,27 +208,27 @@ export class Fan {
|
|
|
201
208
|
|
|
202
209
|
async pushFanSpeedUpChanges(): Promise<void> {
|
|
203
210
|
const bodyChange = JSON.stringify({
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
211
|
+
command: 'highSpeed',
|
|
212
|
+
parameter: 'default',
|
|
213
|
+
commandType: 'command',
|
|
207
214
|
});
|
|
208
215
|
await this.pushChanges(bodyChange);
|
|
209
216
|
}
|
|
210
217
|
|
|
211
218
|
async pushFanSpeedDownChanges(): Promise<void> {
|
|
212
219
|
const bodyChange = JSON.stringify({
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
220
|
+
command: 'lowSpeed',
|
|
221
|
+
parameter: 'default',
|
|
222
|
+
commandType: 'command',
|
|
216
223
|
});
|
|
217
224
|
await this.pushChanges(bodyChange);
|
|
218
225
|
}
|
|
219
226
|
|
|
220
227
|
async pushFanSwingChanges(): Promise<void> {
|
|
221
228
|
const bodyChange = JSON.stringify({
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
229
|
+
command: 'swing',
|
|
230
|
+
parameter: 'default',
|
|
231
|
+
commandType: 'command',
|
|
225
232
|
});
|
|
226
233
|
await this.pushChanges(bodyChange);
|
|
227
234
|
}
|
|
@@ -243,13 +250,16 @@ export class Fan {
|
|
|
243
250
|
this.updateHomeKitCharacteristics();
|
|
244
251
|
} catch (e: any) {
|
|
245
252
|
this.apiError(e);
|
|
246
|
-
this.errorLog(
|
|
247
|
-
|
|
253
|
+
this.errorLog(
|
|
254
|
+
`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}` +
|
|
255
|
+
` Connection, Error Message: ${JSON.stringify(e.message)}`,
|
|
248
256
|
);
|
|
249
257
|
}
|
|
250
258
|
} else {
|
|
251
|
-
this.warnLog(
|
|
252
|
-
|
|
259
|
+
this.warnLog(
|
|
260
|
+
`${this.device.remoteType}: ${this.accessory.displayName}` +
|
|
261
|
+
` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`,
|
|
262
|
+
);
|
|
253
263
|
}
|
|
254
264
|
}
|
|
255
265
|
|
|
@@ -277,7 +287,7 @@ export class Fan {
|
|
|
277
287
|
}
|
|
278
288
|
}
|
|
279
289
|
|
|
280
|
-
async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig
|
|
290
|
+
async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
|
|
281
291
|
if (device.disablePushOn === undefined) {
|
|
282
292
|
this.disablePushOn = false;
|
|
283
293
|
} else {
|
|
@@ -285,7 +295,7 @@ export class Fan {
|
|
|
285
295
|
}
|
|
286
296
|
}
|
|
287
297
|
|
|
288
|
-
async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig
|
|
298
|
+
async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
|
|
289
299
|
if (device.disablePushOff === undefined) {
|
|
290
300
|
this.disablePushOff = false;
|
|
291
301
|
} else {
|
|
@@ -338,8 +348,10 @@ export class Fan {
|
|
|
338
348
|
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline, statusCode: ${statusCode}`);
|
|
339
349
|
break;
|
|
340
350
|
case 171:
|
|
341
|
-
this.errorLog(
|
|
342
|
-
|
|
351
|
+
this.errorLog(
|
|
352
|
+
`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
|
|
353
|
+
`Hub: ${this.device.hubDeviceId}`,
|
|
354
|
+
);
|
|
343
355
|
break;
|
|
344
356
|
case 190:
|
|
345
357
|
this.errorLog(
|
|
@@ -354,8 +366,10 @@ export class Fan {
|
|
|
354
366
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
|
|
355
367
|
break;
|
|
356
368
|
default:
|
|
357
|
-
this.infoLog(
|
|
358
|
-
|
|
369
|
+
this.infoLog(
|
|
370
|
+
`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: ` +
|
|
371
|
+
`${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
|
|
372
|
+
);
|
|
359
373
|
}
|
|
360
374
|
}
|
|
361
375
|
|
|
@@ -367,8 +381,9 @@ export class Fan {
|
|
|
367
381
|
|
|
368
382
|
FirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): string {
|
|
369
383
|
let FirmwareRevision: string;
|
|
370
|
-
this.debugLog(
|
|
371
|
-
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}
|
|
384
|
+
this.debugLog(
|
|
385
|
+
`${this.device.remoteType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
|
|
386
|
+
);
|
|
372
387
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
373
388
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
374
389
|
if (accessory.context.FirmwareRevision) {
|
|
@@ -389,7 +404,6 @@ export class Fan {
|
|
|
389
404
|
}
|
|
390
405
|
}
|
|
391
406
|
|
|
392
|
-
|
|
393
407
|
async config(device: irdevice & irDevicesConfig): Promise<void> {
|
|
394
408
|
let config = {};
|
|
395
409
|
if (device.irfan) {
|
package/src/irdevice/light.ts
CHANGED
|
@@ -20,7 +20,11 @@ export class Light {
|
|
|
20
20
|
disablePushOff?: boolean;
|
|
21
21
|
deviceLogging!: string;
|
|
22
22
|
|
|
23
|
-
constructor(
|
|
23
|
+
constructor(
|
|
24
|
+
private readonly platform: SwitchBotPlatform,
|
|
25
|
+
private accessory: PlatformAccessory,
|
|
26
|
+
public device: irdevice & irDevicesConfig,
|
|
27
|
+
) {
|
|
24
28
|
// default placeholders
|
|
25
29
|
this.logs(device);
|
|
26
30
|
this.config(device);
|
|
@@ -84,30 +88,32 @@ export class Light {
|
|
|
84
88
|
* Light - "command" "channelSub" "default" = previous channel
|
|
85
89
|
*/
|
|
86
90
|
async pushLightOnChanges(): Promise<void> {
|
|
87
|
-
this.debugLog(
|
|
88
|
-
+ ` disablePushOn: ${this.disablePushOn}
|
|
91
|
+
this.debugLog(
|
|
92
|
+
`${this.device.remoteType}: ${this.accessory.displayName} pushLightOnChanges On: ${this.On},` + ` disablePushOn: ${this.disablePushOn}`,
|
|
93
|
+
);
|
|
89
94
|
if (this.On && !this.disablePushOn) {
|
|
90
95
|
const commandType: string = await this.commandType();
|
|
91
96
|
const command: string = await this.commandOn();
|
|
92
97
|
const bodyChange = JSON.stringify({
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
98
|
+
command: command,
|
|
99
|
+
parameter: 'default',
|
|
100
|
+
commandType: commandType,
|
|
96
101
|
});
|
|
97
102
|
await this.pushChanges(bodyChange);
|
|
98
103
|
}
|
|
99
104
|
}
|
|
100
105
|
|
|
101
106
|
async pushLightOffChanges(): Promise<void> {
|
|
102
|
-
this.debugLog(
|
|
103
|
-
+ ` disablePushOff: ${this.disablePushOff}
|
|
107
|
+
this.debugLog(
|
|
108
|
+
`${this.device.remoteType}: ${this.accessory.displayName} pushLightOffChanges On: ${this.On},` + ` disablePushOff: ${this.disablePushOff}`,
|
|
109
|
+
);
|
|
104
110
|
if (!this.On && !this.disablePushOff) {
|
|
105
111
|
const commandType: string = await this.commandType();
|
|
106
112
|
const command: string = await this.commandOff();
|
|
107
113
|
const bodyChange = JSON.stringify({
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
114
|
+
command: command,
|
|
115
|
+
parameter: 'default',
|
|
116
|
+
commandType: commandType,
|
|
111
117
|
});
|
|
112
118
|
await this.pushChanges(bodyChange);
|
|
113
119
|
}
|
|
@@ -115,18 +121,18 @@ export class Light {
|
|
|
115
121
|
|
|
116
122
|
async pushLightBrightnessUpChanges(): Promise<void> {
|
|
117
123
|
const bodyChange = JSON.stringify({
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
124
|
+
command: 'brightnessUp',
|
|
125
|
+
parameter: 'default',
|
|
126
|
+
commandType: 'command',
|
|
121
127
|
});
|
|
122
128
|
await this.pushChanges(bodyChange);
|
|
123
129
|
}
|
|
124
130
|
|
|
125
131
|
async pushLightBrightnessDownChanges(): Promise<void> {
|
|
126
132
|
const bodyChange = JSON.stringify({
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
133
|
+
command: 'brightnessDown',
|
|
134
|
+
parameter: 'default',
|
|
135
|
+
commandType: 'command',
|
|
130
136
|
});
|
|
131
137
|
await this.pushChanges(bodyChange);
|
|
132
138
|
}
|
|
@@ -149,13 +155,16 @@ export class Light {
|
|
|
149
155
|
this.updateHomeKitCharacteristics();
|
|
150
156
|
} catch (e: any) {
|
|
151
157
|
this.apiError(e);
|
|
152
|
-
this.errorLog(
|
|
153
|
-
|
|
158
|
+
this.errorLog(
|
|
159
|
+
`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}` +
|
|
160
|
+
` Connection, Error Message: ${JSON.stringify(e.message)}`,
|
|
154
161
|
);
|
|
155
162
|
}
|
|
156
163
|
} else {
|
|
157
|
-
this.warnLog(
|
|
158
|
-
|
|
164
|
+
this.warnLog(
|
|
165
|
+
`${this.device.remoteType}: ${this.accessory.displayName}` +
|
|
166
|
+
` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`,
|
|
167
|
+
);
|
|
159
168
|
}
|
|
160
169
|
}
|
|
161
170
|
|
|
@@ -169,7 +178,7 @@ export class Light {
|
|
|
169
178
|
}
|
|
170
179
|
}
|
|
171
180
|
|
|
172
|
-
async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig
|
|
181
|
+
async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
|
|
173
182
|
if (device.disablePushOn === undefined) {
|
|
174
183
|
this.disablePushOn = false;
|
|
175
184
|
} else {
|
|
@@ -177,7 +186,7 @@ export class Light {
|
|
|
177
186
|
}
|
|
178
187
|
}
|
|
179
188
|
|
|
180
|
-
async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig
|
|
189
|
+
async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
|
|
181
190
|
if (device.disablePushOff === undefined) {
|
|
182
191
|
this.disablePushOff = false;
|
|
183
192
|
} else {
|
|
@@ -230,8 +239,10 @@ export class Light {
|
|
|
230
239
|
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline, statusCode: ${statusCode}`);
|
|
231
240
|
break;
|
|
232
241
|
case 171:
|
|
233
|
-
this.errorLog(
|
|
234
|
-
|
|
242
|
+
this.errorLog(
|
|
243
|
+
`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
|
|
244
|
+
`Hub: ${this.device.hubDeviceId}`,
|
|
245
|
+
);
|
|
235
246
|
break;
|
|
236
247
|
case 190:
|
|
237
248
|
this.errorLog(
|
|
@@ -246,8 +257,10 @@ export class Light {
|
|
|
246
257
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
|
|
247
258
|
break;
|
|
248
259
|
default:
|
|
249
|
-
this.infoLog(
|
|
250
|
-
|
|
260
|
+
this.infoLog(
|
|
261
|
+
`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: ` +
|
|
262
|
+
`${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
|
|
263
|
+
);
|
|
251
264
|
}
|
|
252
265
|
}
|
|
253
266
|
|
|
@@ -257,8 +270,9 @@ export class Light {
|
|
|
257
270
|
|
|
258
271
|
FirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): string {
|
|
259
272
|
let FirmwareRevision: string;
|
|
260
|
-
this.debugLog(
|
|
261
|
-
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}
|
|
273
|
+
this.debugLog(
|
|
274
|
+
`${this.device.remoteType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
|
|
275
|
+
);
|
|
262
276
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
263
277
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
264
278
|
if (accessory.context.FirmwareRevision) {
|
package/src/irdevice/other.ts
CHANGED
|
@@ -21,7 +21,11 @@ export class Others {
|
|
|
21
21
|
deviceLogging!: string;
|
|
22
22
|
otherDeviceType?: string;
|
|
23
23
|
|
|
24
|
-
constructor(
|
|
24
|
+
constructor(
|
|
25
|
+
private readonly platform: SwitchBotPlatform,
|
|
26
|
+
private accessory: PlatformAccessory,
|
|
27
|
+
public device: irdevice & irDevicesConfig,
|
|
28
|
+
) {
|
|
25
29
|
// default placeholders
|
|
26
30
|
this.logs(device);
|
|
27
31
|
this.deviceType(device);
|
|
@@ -87,16 +91,18 @@ export class Others {
|
|
|
87
91
|
* Other - "command" "channelSub" "default" = previous channel
|
|
88
92
|
*/
|
|
89
93
|
async pushOnChanges(): Promise<void> {
|
|
90
|
-
this.debugLog(
|
|
91
|
-
|
|
94
|
+
this.debugLog(
|
|
95
|
+
`${this.device.remoteType}: ${this.accessory.displayName} pushOnChanges Active: ${this.Active},` +
|
|
96
|
+
` disablePushOn: ${this.disablePushOn}, customize: ${this.device.customize}, customOn: ${this.device.customOn}`,
|
|
97
|
+
);
|
|
92
98
|
if (this.device.customize) {
|
|
93
99
|
if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
94
100
|
const commandType: string = await this.commandType();
|
|
95
101
|
const command: string = await this.commandOn();
|
|
96
102
|
const bodyChange = JSON.stringify({
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
103
|
+
command: command,
|
|
104
|
+
parameter: 'default',
|
|
105
|
+
commandType: commandType,
|
|
100
106
|
});
|
|
101
107
|
await this.pushChanges(bodyChange);
|
|
102
108
|
}
|
|
@@ -106,16 +112,18 @@ export class Others {
|
|
|
106
112
|
}
|
|
107
113
|
|
|
108
114
|
async pushOffChanges(): Promise<void> {
|
|
109
|
-
this.debugLog(
|
|
110
|
-
|
|
115
|
+
this.debugLog(
|
|
116
|
+
`${this.device.remoteType}: ${this.accessory.displayName} pushOffChanges Active: ${this.Active},` +
|
|
117
|
+
` disablePushOff: ${this.disablePushOff}, customize: ${this.device.customize}, customOff: ${this.device.customOff}`,
|
|
118
|
+
);
|
|
111
119
|
if (this.device.customize) {
|
|
112
120
|
if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOff) {
|
|
113
121
|
const commandType: string = await this.commandType();
|
|
114
122
|
const command: string = await this.commandOff();
|
|
115
123
|
const bodyChange = JSON.stringify({
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
124
|
+
command: command,
|
|
125
|
+
parameter: 'default',
|
|
126
|
+
commandType: commandType,
|
|
119
127
|
});
|
|
120
128
|
await this.pushChanges(bodyChange);
|
|
121
129
|
}
|
|
@@ -141,13 +149,16 @@ export class Others {
|
|
|
141
149
|
this.updateHomeKitCharacteristics();
|
|
142
150
|
} catch (e: any) {
|
|
143
151
|
this.apiError(e);
|
|
144
|
-
this.errorLog(
|
|
145
|
-
|
|
152
|
+
this.errorLog(
|
|
153
|
+
`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}` +
|
|
154
|
+
` Connection, Error Message: ${JSON.stringify(e.message)}`,
|
|
146
155
|
);
|
|
147
156
|
}
|
|
148
157
|
} else {
|
|
149
|
-
this.warnLog(
|
|
150
|
-
|
|
158
|
+
this.warnLog(
|
|
159
|
+
`${this.device.remoteType}: ${this.accessory.displayName}` +
|
|
160
|
+
` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`,
|
|
161
|
+
);
|
|
151
162
|
}
|
|
152
163
|
}
|
|
153
164
|
|
|
@@ -161,7 +172,7 @@ export class Others {
|
|
|
161
172
|
}
|
|
162
173
|
}
|
|
163
174
|
|
|
164
|
-
async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig
|
|
175
|
+
async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
|
|
165
176
|
if (device.disablePushOn === undefined) {
|
|
166
177
|
this.disablePushOn = false;
|
|
167
178
|
} else {
|
|
@@ -169,7 +180,7 @@ export class Others {
|
|
|
169
180
|
}
|
|
170
181
|
}
|
|
171
182
|
|
|
172
|
-
async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig
|
|
183
|
+
async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
|
|
173
184
|
if (device.disablePushOff === undefined) {
|
|
174
185
|
this.disablePushOff = false;
|
|
175
186
|
} else {
|
|
@@ -222,8 +233,10 @@ export class Others {
|
|
|
222
233
|
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline, statusCode: ${statusCode}`);
|
|
223
234
|
break;
|
|
224
235
|
case 171:
|
|
225
|
-
this.errorLog(
|
|
226
|
-
|
|
236
|
+
this.errorLog(
|
|
237
|
+
`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
|
|
238
|
+
`Hub: ${this.device.hubDeviceId}`,
|
|
239
|
+
);
|
|
227
240
|
break;
|
|
228
241
|
case 190:
|
|
229
242
|
this.errorLog(
|
|
@@ -238,8 +251,10 @@ export class Others {
|
|
|
238
251
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
|
|
239
252
|
break;
|
|
240
253
|
default:
|
|
241
|
-
this.infoLog(
|
|
242
|
-
|
|
254
|
+
this.infoLog(
|
|
255
|
+
`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: ` +
|
|
256
|
+
`${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
|
|
257
|
+
);
|
|
243
258
|
}
|
|
244
259
|
}
|
|
245
260
|
|
|
@@ -261,8 +276,9 @@ export class Others {
|
|
|
261
276
|
|
|
262
277
|
FirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): string {
|
|
263
278
|
let FirmwareRevision: string;
|
|
264
|
-
this.debugLog(
|
|
265
|
-
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}
|
|
279
|
+
this.debugLog(
|
|
280
|
+
`${this.device.remoteType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
|
|
281
|
+
);
|
|
266
282
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
267
283
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
268
284
|
if (accessory.context.FirmwareRevision) {
|