@switchbot/homebridge-switchbot 4.3.2-beta.3 → 4.3.2-beta.4
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/airpurifier.d.ts +54 -0
- package/dist/device/airpurifier.d.ts.map +1 -0
- package/dist/device/airpurifier.js +527 -0
- package/dist/device/airpurifier.js.map +1 -0
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +2 -8
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +2 -8
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +2 -8
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +2 -8
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +1 -4
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +2 -8
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +2 -8
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +1 -4
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +2 -8
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +1 -4
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +2 -8
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +2 -8
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +1 -4
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +1 -4
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/meterpro.d.ts.map +1 -1
- package/dist/device/meterpro.js +1 -4
- package/dist/device/meterpro.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +1 -4
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +2 -8
- package/dist/device/plug.js.map +1 -1
- package/dist/device/relayswitch.d.ts.map +1 -1
- package/dist/device/relayswitch.js +2 -8
- package/dist/device/relayswitch.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +2 -8
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +1 -4
- package/dist/device/waterdetector.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 +4 -4
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/platform.d.ts +2 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +68 -7
- package/dist/platform.js.map +1 -1
- package/docs/variables/default.html +1 -1
- package/package.json +2 -2
- package/src/device/airpurifier.ts +563 -0
- package/src/device/blindtilt.ts +2 -6
- package/src/device/bot.ts +2 -6
- package/src/device/ceilinglight.ts +2 -6
- package/src/device/colorbulb.ts +2 -6
- package/src/device/contact.ts +1 -3
- package/src/device/curtain.ts +2 -6
- package/src/device/fan.ts +2 -6
- package/src/device/hub.ts +1 -3
- package/src/device/humidifier.ts +2 -6
- package/src/device/iosensor.ts +1 -3
- package/src/device/lightstrip.ts +2 -6
- package/src/device/lock.ts +2 -6
- package/src/device/meter.ts +1 -3
- package/src/device/meterplus.ts +1 -3
- package/src/device/meterpro.ts +1 -3
- package/src/device/motion.ts +1 -3
- package/src/device/plug.ts +2 -6
- package/src/device/relayswitch.ts +2 -6
- package/src/device/robotvacuumcleaner.ts +2 -6
- package/src/device/waterdetector.ts +1 -3
- package/src/irdevice/airpurifier.ts +4 -4
- package/src/platform.ts +70 -7
|
@@ -269,9 +269,7 @@ export class CeilingLight extends deviceBase {
|
|
|
269
269
|
* Asks the SwitchBot API for the latest device information
|
|
270
270
|
*/
|
|
271
271
|
async refreshStatus(): Promise<void> {
|
|
272
|
-
if (
|
|
273
|
-
this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
|
|
274
|
-
} else if (this.BLE) {
|
|
272
|
+
if (this.BLE) {
|
|
275
273
|
await this.BLERefreshStatus()
|
|
276
274
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
277
275
|
await this.openAPIRefreshStatus()
|
|
@@ -392,9 +390,7 @@ export class CeilingLight extends deviceBase {
|
|
|
392
390
|
*
|
|
393
391
|
*/
|
|
394
392
|
async pushChanges(): Promise<void> {
|
|
395
|
-
if (
|
|
396
|
-
this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`)
|
|
397
|
-
} else if (this.BLE) {
|
|
393
|
+
if (this.BLE) {
|
|
398
394
|
await this.BLEpushChanges()
|
|
399
395
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
400
396
|
await this.openAPIpushChanges()
|
package/src/device/colorbulb.ts
CHANGED
|
@@ -303,9 +303,7 @@ export class ColorBulb extends deviceBase {
|
|
|
303
303
|
* Asks the SwitchBot API for the latest device information
|
|
304
304
|
*/
|
|
305
305
|
async refreshStatus(): Promise<void> {
|
|
306
|
-
if (
|
|
307
|
-
this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
|
|
308
|
-
} else if (this.BLE) {
|
|
306
|
+
if (this.BLE) {
|
|
309
307
|
await this.BLERefreshStatus()
|
|
310
308
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
311
309
|
await this.openAPIRefreshStatus()
|
|
@@ -427,9 +425,7 @@ export class ColorBulb extends deviceBase {
|
|
|
427
425
|
*
|
|
428
426
|
*/
|
|
429
427
|
async pushChanges(): Promise<void> {
|
|
430
|
-
if (
|
|
431
|
-
this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`)
|
|
432
|
-
} else if (this.BLE) {
|
|
428
|
+
if (this.BLE) {
|
|
433
429
|
await this.BLEpushChanges()
|
|
434
430
|
if (this.LightBulb.On) {
|
|
435
431
|
// Push Brightness Update
|
package/src/device/contact.ts
CHANGED
|
@@ -284,9 +284,7 @@ export class Contact extends deviceBase {
|
|
|
284
284
|
* Asks the SwitchBot API for the latest device information
|
|
285
285
|
*/
|
|
286
286
|
async refreshStatus(): Promise<void> {
|
|
287
|
-
if (
|
|
288
|
-
this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
|
|
289
|
-
} else if (this.BLE) {
|
|
287
|
+
if (this.BLE) {
|
|
290
288
|
await this.BLERefreshStatus()
|
|
291
289
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
292
290
|
await this.openAPIRefreshStatus()
|
package/src/device/curtain.ts
CHANGED
|
@@ -468,9 +468,7 @@ export class Curtain extends deviceBase {
|
|
|
468
468
|
* Asks the SwitchBot API for the latest device information
|
|
469
469
|
*/
|
|
470
470
|
async refreshStatus(): Promise<void> {
|
|
471
|
-
if (
|
|
472
|
-
this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
|
|
473
|
-
} else if (this.BLE) {
|
|
471
|
+
if (this.BLE) {
|
|
474
472
|
await this.BLERefreshStatus()
|
|
475
473
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
476
474
|
await this.openAPIRefreshStatus()
|
|
@@ -585,9 +583,7 @@ export class Curtain extends deviceBase {
|
|
|
585
583
|
* Pushes the requested changes to the SwitchBot API
|
|
586
584
|
*/
|
|
587
585
|
async pushChanges(): Promise<void> {
|
|
588
|
-
if (
|
|
589
|
-
this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`)
|
|
590
|
-
} else if (this.BLE) {
|
|
586
|
+
if (this.BLE) {
|
|
591
587
|
await this.BLEpushChanges()
|
|
592
588
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
593
589
|
await this.openAPIpushChanges()
|
package/src/device/fan.ts
CHANGED
|
@@ -306,9 +306,7 @@ export class Fan extends deviceBase {
|
|
|
306
306
|
* Asks the SwitchBot API for the latest device information
|
|
307
307
|
*/
|
|
308
308
|
async refreshStatus(): Promise<void> {
|
|
309
|
-
if (
|
|
310
|
-
this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
|
|
311
|
-
} else if (this.BLE) {
|
|
309
|
+
if (this.BLE) {
|
|
312
310
|
await this.BLERefreshStatus()
|
|
313
311
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
314
312
|
await this.openAPIRefreshStatus()
|
|
@@ -429,9 +427,7 @@ export class Fan extends deviceBase {
|
|
|
429
427
|
*/
|
|
430
428
|
|
|
431
429
|
async pushChanges(): Promise<void> {
|
|
432
|
-
if (
|
|
433
|
-
this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`)
|
|
434
|
-
} else if (this.BLE) {
|
|
430
|
+
if (this.BLE) {
|
|
435
431
|
await this.BLEpushChanges()
|
|
436
432
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
437
433
|
await this.openAPIpushChanges()
|
package/src/device/hub.ts
CHANGED
|
@@ -273,9 +273,7 @@ export class Hub extends deviceBase {
|
|
|
273
273
|
* Asks the SwitchBot API for the latest device information
|
|
274
274
|
*/
|
|
275
275
|
async refreshStatus(): Promise<void> {
|
|
276
|
-
if (
|
|
277
|
-
this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
|
|
278
|
-
} else if (this.BLE) {
|
|
276
|
+
if (this.BLE) {
|
|
279
277
|
await this.BLERefreshStatus()
|
|
280
278
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
281
279
|
await this.openAPIRefreshStatus()
|
package/src/device/humidifier.ts
CHANGED
|
@@ -303,9 +303,7 @@ export class Humidifier extends deviceBase {
|
|
|
303
303
|
* Asks the SwitchBot API for the latest device information
|
|
304
304
|
*/
|
|
305
305
|
async refreshStatus(): Promise<void> {
|
|
306
|
-
if (
|
|
307
|
-
this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
|
|
308
|
-
} else if (this.BLE) {
|
|
306
|
+
if (this.BLE) {
|
|
309
307
|
await this.BLERefreshStatus()
|
|
310
308
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
311
309
|
await this.openAPIRefreshStatus()
|
|
@@ -417,9 +415,7 @@ export class Humidifier extends deviceBase {
|
|
|
417
415
|
* Pushes the requested changes to the SwitchBot API
|
|
418
416
|
*/
|
|
419
417
|
async pushChanges(): Promise<void> {
|
|
420
|
-
if (
|
|
421
|
-
this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`)
|
|
422
|
-
} else if (this.BLE) {
|
|
418
|
+
if (this.BLE) {
|
|
423
419
|
await this.BLEpushChanges()
|
|
424
420
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
425
421
|
await this.openAPIpushChanges()
|
package/src/device/iosensor.ts
CHANGED
|
@@ -267,9 +267,7 @@ export class IOSensor extends deviceBase {
|
|
|
267
267
|
* Asks the SwitchBot API for the latest device information
|
|
268
268
|
*/
|
|
269
269
|
async refreshStatus(): Promise<void> {
|
|
270
|
-
if (
|
|
271
|
-
this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
|
|
272
|
-
} else if (this.BLE) {
|
|
270
|
+
if (this.BLE) {
|
|
273
271
|
await this.BLERefreshStatus()
|
|
274
272
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
275
273
|
await this.openAPIRefreshStatus()
|
package/src/device/lightstrip.ts
CHANGED
|
@@ -305,9 +305,7 @@ export class StripLight extends deviceBase {
|
|
|
305
305
|
* Asks the SwitchBot API for the latest device information
|
|
306
306
|
*/
|
|
307
307
|
async refreshStatus(): Promise<void> {
|
|
308
|
-
if (
|
|
309
|
-
this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
|
|
310
|
-
} else if (this.BLE) {
|
|
308
|
+
if (this.BLE) {
|
|
311
309
|
await this.BLERefreshStatus()
|
|
312
310
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
313
311
|
await this.openAPIRefreshStatus()
|
|
@@ -428,9 +426,7 @@ export class StripLight extends deviceBase {
|
|
|
428
426
|
*
|
|
429
427
|
*/
|
|
430
428
|
async pushChanges(): Promise<void> {
|
|
431
|
-
if (
|
|
432
|
-
this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`)
|
|
433
|
-
} else if (this.BLE) {
|
|
429
|
+
if (this.BLE) {
|
|
434
430
|
await this.BLEpushChanges()
|
|
435
431
|
if (this.LightBulb.On) {
|
|
436
432
|
// Push Brightness Update
|
package/src/device/lock.ts
CHANGED
|
@@ -308,9 +308,7 @@ export class Lock extends deviceBase {
|
|
|
308
308
|
* Asks the SwitchBot API for the latest device information
|
|
309
309
|
*/
|
|
310
310
|
async refreshStatus(): Promise<void> {
|
|
311
|
-
if (
|
|
312
|
-
this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
|
|
313
|
-
} else if (this.BLE) {
|
|
311
|
+
if (this.BLE) {
|
|
314
312
|
await this.BLERefreshStatus()
|
|
315
313
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
316
314
|
await this.openAPIRefreshStatus()
|
|
@@ -428,9 +426,7 @@ export class Lock extends deviceBase {
|
|
|
428
426
|
* Lock - "command" "unlock" "default" = set to ???? state - LockCurrentState
|
|
429
427
|
*/
|
|
430
428
|
async pushChanges(): Promise<void> {
|
|
431
|
-
if (
|
|
432
|
-
this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`)
|
|
433
|
-
} else if (this.BLE) {
|
|
429
|
+
if (this.BLE) {
|
|
434
430
|
await this.BLEpushChanges()
|
|
435
431
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
436
432
|
await this.openAPIpushChanges()
|
package/src/device/meter.ts
CHANGED
|
@@ -264,9 +264,7 @@ export class Meter extends deviceBase {
|
|
|
264
264
|
* Asks the SwitchBot API for the latest device information
|
|
265
265
|
*/
|
|
266
266
|
async refreshStatus(): Promise<void> {
|
|
267
|
-
if (
|
|
268
|
-
this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
|
|
269
|
-
} else if (this.BLE) {
|
|
267
|
+
if (this.BLE) {
|
|
270
268
|
await this.BLERefreshStatus()
|
|
271
269
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
272
270
|
await this.openAPIRefreshStatus()
|
package/src/device/meterplus.ts
CHANGED
|
@@ -268,9 +268,7 @@ export class MeterPlus extends deviceBase {
|
|
|
268
268
|
* Asks the SwitchBot API for the latest device information
|
|
269
269
|
*/
|
|
270
270
|
async refreshStatus(): Promise<void> {
|
|
271
|
-
if (
|
|
272
|
-
this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
|
|
273
|
-
} else if (this.BLE) {
|
|
271
|
+
if (this.BLE) {
|
|
274
272
|
await this.BLERefreshStatus()
|
|
275
273
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
276
274
|
await this.openAPIRefreshStatus()
|
package/src/device/meterpro.ts
CHANGED
|
@@ -346,9 +346,7 @@ export class MeterPro extends deviceBase {
|
|
|
346
346
|
* Asks the SwitchBot API for the latest device information
|
|
347
347
|
*/
|
|
348
348
|
async refreshStatus(): Promise<void> {
|
|
349
|
-
if (
|
|
350
|
-
this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
|
|
351
|
-
} else if (this.BLE) {
|
|
349
|
+
if (this.BLE) {
|
|
352
350
|
await this.BLERefreshStatus()
|
|
353
351
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
354
352
|
await this.openAPIRefreshStatus()
|
package/src/device/motion.ts
CHANGED
|
@@ -239,9 +239,7 @@ export class Motion extends deviceBase {
|
|
|
239
239
|
* Asks the SwitchBot API for the latest device information
|
|
240
240
|
*/
|
|
241
241
|
async refreshStatus(): Promise<void> {
|
|
242
|
-
if (
|
|
243
|
-
this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
|
|
244
|
-
} else if (this.BLE) {
|
|
242
|
+
if (this.BLE) {
|
|
245
243
|
await this.BLERefreshStatus()
|
|
246
244
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
247
245
|
await this.openAPIRefreshStatus()
|
package/src/device/plug.ts
CHANGED
|
@@ -163,9 +163,7 @@ export class Plug extends deviceBase {
|
|
|
163
163
|
* Asks the SwitchBot API for the latest device information
|
|
164
164
|
*/
|
|
165
165
|
async refreshStatus(): Promise<void> {
|
|
166
|
-
if (
|
|
167
|
-
this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
|
|
168
|
-
} else if (this.BLE) {
|
|
166
|
+
if (this.BLE) {
|
|
169
167
|
await this.BLERefreshStatus()
|
|
170
168
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
171
169
|
await this.openAPIRefreshStatus()
|
|
@@ -287,9 +285,7 @@ export class Plug extends deviceBase {
|
|
|
287
285
|
*/
|
|
288
286
|
|
|
289
287
|
async pushChanges(): Promise<void> {
|
|
290
|
-
if (
|
|
291
|
-
this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`)
|
|
292
|
-
} else if (this.BLE) {
|
|
288
|
+
if (this.BLE) {
|
|
293
289
|
await this.BLEpushChanges()
|
|
294
290
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
295
291
|
await this.openAPIpushChanges()
|
|
@@ -292,9 +292,7 @@ export class RelaySwitch extends deviceBase {
|
|
|
292
292
|
* Asks the SwitchBot API for the latest device information
|
|
293
293
|
*/
|
|
294
294
|
async refreshStatus(): Promise<void> {
|
|
295
|
-
if (
|
|
296
|
-
this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
|
|
297
|
-
} else if (this.BLE) {
|
|
295
|
+
if (this.BLE) {
|
|
298
296
|
await this.BLERefreshStatus()
|
|
299
297
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
300
298
|
await this.openAPIRefreshStatus()
|
|
@@ -411,9 +409,7 @@ export class RelaySwitch extends deviceBase {
|
|
|
411
409
|
* RelaySwitch "command" "turnOn" "default" = set to ON state
|
|
412
410
|
*/
|
|
413
411
|
async pushChanges(): Promise<void> {
|
|
414
|
-
if (
|
|
415
|
-
this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`)
|
|
416
|
-
} else if (this.BLE) {
|
|
412
|
+
if (this.BLE) {
|
|
417
413
|
await this.BLEpushChanges()
|
|
418
414
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
419
415
|
await this.openAPIpushChanges()
|
|
@@ -252,9 +252,7 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
252
252
|
* Asks the SwitchBot API for the latest device information
|
|
253
253
|
*/
|
|
254
254
|
async refreshStatus(): Promise<void> {
|
|
255
|
-
if (
|
|
256
|
-
this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
|
|
257
|
-
} else if (this.BLE) {
|
|
255
|
+
if (this.BLE) {
|
|
258
256
|
await this.BLERefreshStatus()
|
|
259
257
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
260
258
|
await this.openAPIRefreshStatus()
|
|
@@ -373,9 +371,7 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
373
371
|
* Robot Vacuum Cleaner S1 "command" "PowLevel" "{0-3}" = set suction power level: 0 (Quiet), 1 (Standard), 2 (Strong), 3 (MAX)
|
|
374
372
|
*/
|
|
375
373
|
async pushChanges(): Promise<void> {
|
|
376
|
-
if (
|
|
377
|
-
this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`)
|
|
378
|
-
} else if (this.BLE) {
|
|
374
|
+
if (this.BLE) {
|
|
379
375
|
await this.BLEpushChanges()
|
|
380
376
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
381
377
|
await this.openAPIpushChanges()
|
|
@@ -246,9 +246,7 @@ export class WaterDetector extends deviceBase {
|
|
|
246
246
|
* Asks the SwitchBot API for the latest device information
|
|
247
247
|
*/
|
|
248
248
|
async refreshStatus(): Promise<void> {
|
|
249
|
-
if (
|
|
250
|
-
this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
|
|
251
|
-
} else if (this.BLE) {
|
|
249
|
+
if (this.BLE) {
|
|
252
250
|
await this.BLERefreshStatus()
|
|
253
251
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
254
252
|
await this.openAPIRefreshStatus()
|
|
@@ -15,7 +15,7 @@ import { irdeviceBase } from './irdevice.js'
|
|
|
15
15
|
* An instance of this class is created for each accessory your platform registers
|
|
16
16
|
* Each accessory may expose multiple services of different service types.
|
|
17
17
|
*/
|
|
18
|
-
export class
|
|
18
|
+
export class AirPurifierIR extends irdeviceBase {
|
|
19
19
|
// Services
|
|
20
20
|
private AirPurifier: {
|
|
21
21
|
Name: CharacteristicValue
|
|
@@ -111,13 +111,13 @@ export class AirPurifier extends irdeviceBase {
|
|
|
111
111
|
async TargetAirPurifierStateSet(value: CharacteristicValue): Promise<void> {
|
|
112
112
|
switch (value) {
|
|
113
113
|
case this.hap.Characteristic.CurrentAirPurifierState.PURIFYING_AIR:
|
|
114
|
-
this.CurrentMode =
|
|
114
|
+
this.CurrentMode = AirPurifierIR.PURIFYING_AIR
|
|
115
115
|
break
|
|
116
116
|
case this.hap.Characteristic.CurrentAirPurifierState.IDLE:
|
|
117
|
-
this.CurrentMode =
|
|
117
|
+
this.CurrentMode = AirPurifierIR.IDLE
|
|
118
118
|
break
|
|
119
119
|
case this.hap.Characteristic.CurrentAirPurifierState.INACTIVE:
|
|
120
|
-
this.CurrentMode =
|
|
120
|
+
this.CurrentMode = AirPurifierIR.INACTIVE
|
|
121
121
|
break
|
|
122
122
|
default:
|
|
123
123
|
break
|
package/src/platform.ts
CHANGED
|
@@ -24,6 +24,7 @@ import { EveHomeKitTypes } from 'homebridge-lib/EveHomeKitTypes'
|
|
|
24
24
|
import { LogLevel, SwitchBotBLE, SwitchBotModel, SwitchBotOpenAPI } from 'node-switchbot'
|
|
25
25
|
import { queueScheduler } from 'rxjs'
|
|
26
26
|
|
|
27
|
+
import { AirPurifier } from './device/airpurifier.js'
|
|
27
28
|
import { BlindTilt } from './device/blindtilt.js'
|
|
28
29
|
import { Bot } from './device/bot.js'
|
|
29
30
|
import { CeilingLight } from './device/ceilinglight.js'
|
|
@@ -45,7 +46,7 @@ import { RelaySwitch } from './device/relayswitch.js'
|
|
|
45
46
|
import { RobotVacuumCleaner } from './device/robotvacuumcleaner.js'
|
|
46
47
|
import { WaterDetector } from './device/waterdetector.js'
|
|
47
48
|
import { AirConditioner } from './irdevice/airconditioner.js'
|
|
48
|
-
import {
|
|
49
|
+
import { AirPurifierIR } from './irdevice/airpurifier.js'
|
|
49
50
|
import { Camera } from './irdevice/camera.js'
|
|
50
51
|
import { IRFan } from './irdevice/fan.js'
|
|
51
52
|
import { Light } from './irdevice/light.js'
|
|
@@ -616,6 +617,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
616
617
|
'Ceiling Light Pro': this.createCeilingLight.bind(this),
|
|
617
618
|
'Strip Light': this.createStripLight.bind(this),
|
|
618
619
|
'Battery Circulator Fan': this.createFan.bind(this),
|
|
620
|
+
'Air Purifier PM2.5': this.createAirPurifier.bind(this),
|
|
619
621
|
}
|
|
620
622
|
|
|
621
623
|
if (deviceTypeHandlers[device.deviceType!]) {
|
|
@@ -649,8 +651,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
649
651
|
'DIY Air Conditioner': this.createAirConditioner.bind(this),
|
|
650
652
|
'Light': this.createLight.bind(this),
|
|
651
653
|
'DIY Light': this.createLight.bind(this),
|
|
652
|
-
'Air Purifier': this.
|
|
653
|
-
'DIY Air Purifier': this.
|
|
654
|
+
'Air Purifier': this.createAirPurifierIR.bind(this),
|
|
655
|
+
'DIY Air Purifier': this.createAirPurifierIR.bind(this),
|
|
654
656
|
'Water Heater': this.createWaterHeater.bind(this),
|
|
655
657
|
'DIY Water Heater': this.createWaterHeater.bind(this),
|
|
656
658
|
'Vacuum Cleaner': this.createVacuumCleaner.bind(this),
|
|
@@ -1891,6 +1893,68 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1891
1893
|
}
|
|
1892
1894
|
}
|
|
1893
1895
|
|
|
1896
|
+
private async createAirPurifier(device: device & devicesConfig) {
|
|
1897
|
+
const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`)
|
|
1898
|
+
|
|
1899
|
+
// see if an accessory with the same uuid has already been registered and restored from
|
|
1900
|
+
// the cached devices we stored in the `configureAccessory` method above
|
|
1901
|
+
const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid)
|
|
1902
|
+
|
|
1903
|
+
if (existingAccessory) {
|
|
1904
|
+
// the accessory already exists
|
|
1905
|
+
if (await this.registerDevice(device)) {
|
|
1906
|
+
// if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
|
|
1907
|
+
existingAccessory.context.device = device
|
|
1908
|
+
existingAccessory.context.deviceId = device.deviceId
|
|
1909
|
+
existingAccessory.context.deviceType = device.deviceType
|
|
1910
|
+
existingAccessory.context.model = SwitchBotModel.BatteryCirculatorFan
|
|
1911
|
+
existingAccessory.displayName = device.configDeviceName
|
|
1912
|
+
? await this.validateAndCleanDisplayName(device.configDeviceName, 'configDeviceName', device.configDeviceName)
|
|
1913
|
+
: await this.validateAndCleanDisplayName(device.deviceName, 'deviceName', device.deviceName)
|
|
1914
|
+
existingAccessory.context.connectionType = await this.connectionType(device)
|
|
1915
|
+
existingAccessory.context.version = device.firmware ?? device.version ?? this.version ?? '0.0.0'
|
|
1916
|
+
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} deviceId: ${device.deviceId}`)
|
|
1917
|
+
this.api.updatePlatformAccessories([existingAccessory])
|
|
1918
|
+
// create the accessory handler for the restored accessory
|
|
1919
|
+
// this is imported from `platformAccessory.ts`
|
|
1920
|
+
new AirPurifier(this, existingAccessory, device)
|
|
1921
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${existingAccessory.UUID})`)
|
|
1922
|
+
} else {
|
|
1923
|
+
this.unregisterPlatformAccessories(existingAccessory)
|
|
1924
|
+
}
|
|
1925
|
+
} else if (await this.registerDevice(device)) {
|
|
1926
|
+
// create a new accessory
|
|
1927
|
+
const accessory = new this.api.platformAccessory(device.configDeviceName
|
|
1928
|
+
? await this.validateAndCleanDisplayName(device.configDeviceName, 'configDeviceName', device.configDeviceName)
|
|
1929
|
+
: await this.validateAndCleanDisplayName(device.deviceName, 'deviceName', device.deviceName), uuid)
|
|
1930
|
+
|
|
1931
|
+
// store a copy of the device object in the `accessory.context`
|
|
1932
|
+
// the `context` property can be used to store any data about the accessory you may need
|
|
1933
|
+
accessory.context.device = device
|
|
1934
|
+
accessory.context.deviceId = device.deviceId
|
|
1935
|
+
accessory.context.deviceType = device.deviceType
|
|
1936
|
+
accessory.context.model = SwitchBotModel.BatteryCirculatorFan
|
|
1937
|
+
accessory.displayName = device.configDeviceName
|
|
1938
|
+
? await this.validateAndCleanDisplayName(device.configDeviceName, 'configDeviceName', device.configDeviceName)
|
|
1939
|
+
: await this.validateAndCleanDisplayName(device.deviceName, 'deviceName', device.deviceName)
|
|
1940
|
+
accessory.context.connectionType = await this.connectionType(device)
|
|
1941
|
+
accessory.context.connectionType = await this.connectionType(device)
|
|
1942
|
+
accessory.context.version = device.firmware ?? device.version ?? this.version ?? '0.0.0'
|
|
1943
|
+
const newOrExternal = !device.external ? 'Adding new' : 'Loading external'
|
|
1944
|
+
this.infoLog(`${newOrExternal} accessory: ${accessory.displayName} deviceId: ${device.deviceId}`)
|
|
1945
|
+
// create the accessory handler for the newly create accessory
|
|
1946
|
+
// this is imported from `platformAccessory.ts`
|
|
1947
|
+
new AirPurifier(this, accessory, device)
|
|
1948
|
+
this.debugLog(`${device.deviceType} uuid: ${device.deviceId}-${device.deviceType}, (${accessory.UUID})`)
|
|
1949
|
+
|
|
1950
|
+
// publish device externally or link the accessory to your platform
|
|
1951
|
+
this.externalOrPlatform(device, accessory)
|
|
1952
|
+
this.accessories.push(accessory)
|
|
1953
|
+
} else {
|
|
1954
|
+
this.debugLog(`Device not registered: ${device.deviceName} ${device.deviceType} deviceId: ${device.deviceId}`)
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
|
|
1894
1958
|
private async createRobotVacuumCleaner(device: device & devicesConfig) {
|
|
1895
1959
|
const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.deviceType}`)
|
|
1896
1960
|
|
|
@@ -2207,7 +2271,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2207
2271
|
}
|
|
2208
2272
|
}
|
|
2209
2273
|
|
|
2210
|
-
private async
|
|
2274
|
+
private async createAirPurifierIR(device: irdevice & irDevicesConfig) {
|
|
2211
2275
|
const uuid = this.api.hap.uuid.generate(`${device.deviceId}-${device.remoteType}`)
|
|
2212
2276
|
|
|
2213
2277
|
// see if an accessory with the same uuid has already been registered and restored from
|
|
@@ -2230,7 +2294,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2230
2294
|
this.api.updatePlatformAccessories([existingAccessory])
|
|
2231
2295
|
// create the accessory handler for the restored accessory
|
|
2232
2296
|
// this is imported from `platformAccessory.ts`
|
|
2233
|
-
new
|
|
2297
|
+
new AirPurifierIR(this, existingAccessory, device)
|
|
2234
2298
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${existingAccessory.UUID})`)
|
|
2235
2299
|
} else {
|
|
2236
2300
|
this.unregisterPlatformAccessories(existingAccessory)
|
|
@@ -2256,7 +2320,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2256
2320
|
this.infoLog(`${newOrExternal} accessory: ${accessory.displayName} deviceId: ${device.deviceId}`)
|
|
2257
2321
|
// create the accessory handler for the newly create accessory
|
|
2258
2322
|
// this is imported from `platformAccessory.ts`
|
|
2259
|
-
new
|
|
2323
|
+
new AirPurifierIR(this, accessory, device)
|
|
2260
2324
|
this.debugLog(`${device.remoteType} uuid: ${device.deviceId}-${device.remoteType}, (${accessory.UUID})`)
|
|
2261
2325
|
|
|
2262
2326
|
// publish device externally or link the accessory to your platform
|
|
@@ -2685,7 +2749,6 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2685
2749
|
hubDeviceId: '',
|
|
2686
2750
|
version: 0,
|
|
2687
2751
|
deviceName: '',
|
|
2688
|
-
enableCloudService: false,
|
|
2689
2752
|
}, statusCode: 500 }
|
|
2690
2753
|
}
|
|
2691
2754
|
|