@switchbot/homebridge-switchbot 2.2.2-beta.1 → 2.2.2-beta.11
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/bot.js +2 -2
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.js +4 -4
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.js +4 -4
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/curtain.js +1 -1
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/humidifier.d.ts +6 -6
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +15 -9
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/lock.js +1 -1
- package/dist/device/lock.js.map +1 -1
- package/dist/device/plug.js +1 -1
- package/dist/device/plug.js.map +1 -1
- package/dist/device/striplight.d.ts +7 -0
- package/dist/device/striplight.d.ts.map +1 -1
- package/dist/device/striplight.js +142 -125
- package/dist/device/striplight.js.map +1 -1
- package/dist/irdevice/airconditioner.js +2 -2
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.js +2 -2
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.js +2 -2
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.js +2 -2
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.js +2 -2
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.js +2 -2
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.js +2 -2
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +2 -2
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.js +2 -2
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.js +10 -10
- package/dist/platform.js.map +1 -1
- package/package.json +1 -1
- package/src/device/bot.ts +2 -2
- package/src/device/ceilinglight.ts +4 -4
- package/src/device/colorbulb.ts +4 -4
- package/src/device/curtain.ts +1 -1
- package/src/device/humidifier.ts +13 -9
- package/src/device/lock.ts +1 -1
- package/src/device/plug.ts +1 -1
- package/src/device/striplight.ts +143 -122
- package/src/irdevice/airconditioner.ts +2 -2
- package/src/irdevice/airpurifier.ts +2 -2
- package/src/irdevice/camera.ts +2 -2
- package/src/irdevice/fan.ts +2 -2
- package/src/irdevice/light.ts +2 -2
- package/src/irdevice/other.ts +2 -2
- package/src/irdevice/tv.ts +2 -2
- package/src/irdevice/vacuumcleaner.ts +2 -2
- package/src/irdevice/waterheater.ts +2 -2
- package/src/platform.ts +10 -10
package/src/device/striplight.ts
CHANGED
|
@@ -54,6 +54,7 @@ export class StripLight {
|
|
|
54
54
|
|
|
55
55
|
// Others
|
|
56
56
|
cacheKelvin!: number;
|
|
57
|
+
change!: string;
|
|
57
58
|
|
|
58
59
|
// Updates
|
|
59
60
|
stripLightUpdateInProgress!: boolean;
|
|
@@ -474,68 +475,117 @@ export class StripLight {
|
|
|
474
475
|
+ ` Connection, Error Message: ${superStringify(e.message)}`);
|
|
475
476
|
await this.BLEPushConnection();
|
|
476
477
|
});
|
|
478
|
+
// Push Brightness Update
|
|
479
|
+
if (this.On) {
|
|
480
|
+
await this.BLEpushBrightnessChanges();
|
|
481
|
+
}
|
|
482
|
+
// Push Hue & Saturation Update
|
|
483
|
+
if (this.On) {
|
|
484
|
+
await this.BLEpushRGBChanges();
|
|
485
|
+
}
|
|
477
486
|
} else {
|
|
478
487
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No BLEpushChanges.` + `On: ${this.On}, `
|
|
479
488
|
+`OnCached: ${this.accessory.context.On}`);
|
|
480
489
|
}
|
|
481
490
|
}
|
|
482
491
|
|
|
492
|
+
async BLEpushBrightnessChanges(): Promise<void> {
|
|
493
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLEpushBrightnessChanges`);
|
|
494
|
+
if (this.Brightness !== this.accessory.context.Brightness) {
|
|
495
|
+
const switchbot = await this.platform.connectBLE();
|
|
496
|
+
// Convert to BLE Address
|
|
497
|
+
this.device.bleMac = this.device
|
|
498
|
+
.deviceId!.match(/.{1,2}/g)!
|
|
499
|
+
.join(':')
|
|
500
|
+
.toLowerCase();
|
|
501
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
|
|
502
|
+
switchbot
|
|
503
|
+
.discover({
|
|
504
|
+
model: 'u',
|
|
505
|
+
id: this.device.bleMac,
|
|
506
|
+
})
|
|
507
|
+
.then((device_list: any) => {
|
|
508
|
+
this.infoLog(`${this.accessory.displayName} Target Brightness: ${this.Brightness}`);
|
|
509
|
+
return device_list[0].setBrightness(this.Brightness);
|
|
510
|
+
})
|
|
511
|
+
.then(() => {
|
|
512
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Done.`);
|
|
513
|
+
this.On = false;
|
|
514
|
+
})
|
|
515
|
+
.catch(async (e: any) => {
|
|
516
|
+
this.apiError(e);
|
|
517
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed BLEpushBrightnessChanges with ${this.device.connectionType}`
|
|
518
|
+
+ ` Connection, Error Message: ${superStringify(e.message)}`);
|
|
519
|
+
await this.BLEPushConnection();
|
|
520
|
+
});
|
|
521
|
+
} else {
|
|
522
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No BLEpushBrightnessChanges.` + `Brightness: ${this.Brightness}, `
|
|
523
|
+
+`BrightnessCached: ${this.accessory.context.Brightness}`);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
async BLEpushRGBChanges(): Promise<void> {
|
|
528
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLEpushRGBChanges`);
|
|
529
|
+
if (this.Hue !== this.accessory.context.Hue || this.Saturation !== this.accessory.context.Saturation) {
|
|
530
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${superStringify(this.Hue)}`);
|
|
531
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${superStringify(this.Saturation)}`);
|
|
532
|
+
|
|
533
|
+
const [red, green, blue] = hs2rgb(Number(this.Hue), Number(this.Saturation));
|
|
534
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} rgb: ${superStringify([red, green, blue])}`);
|
|
535
|
+
|
|
536
|
+
const switchbot = await this.platform.connectBLE();
|
|
537
|
+
// Convert to BLE Address
|
|
538
|
+
this.device.bleMac = this.device
|
|
539
|
+
.deviceId!.match(/.{1,2}/g)!
|
|
540
|
+
.join(':')
|
|
541
|
+
.toLowerCase();
|
|
542
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
|
|
543
|
+
switchbot
|
|
544
|
+
.discover({
|
|
545
|
+
model: 'u',
|
|
546
|
+
id: this.device.bleMac,
|
|
547
|
+
})
|
|
548
|
+
.then((device_list: any) => {
|
|
549
|
+
this.infoLog(`${this.accessory.displayName} Target RGB: ${this.Brightness, red, green, blue}`);
|
|
550
|
+
return device_list[0].setRGB(this.Brightness, red, green, blue);
|
|
551
|
+
})
|
|
552
|
+
.then(() => {
|
|
553
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Done.`);
|
|
554
|
+
this.On = false;
|
|
555
|
+
})
|
|
556
|
+
.catch(async (e: any) => {
|
|
557
|
+
this.apiError(e);
|
|
558
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed BLEpushRGBChanges with ${this.device.connectionType}`
|
|
559
|
+
+ ` Connection, Error Message: ${superStringify(e.message)}`);
|
|
560
|
+
await this.BLEPushConnection();
|
|
561
|
+
});
|
|
562
|
+
} else {
|
|
563
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No BLEpushRGBChanges. Hue: ${this.Hue}, `
|
|
564
|
+
+ `HueCached: ${this.accessory.context.Hue}, Saturation: ${this.Saturation}, SaturationCached: ${this.accessory.context.Saturation}`);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
|
|
483
568
|
async openAPIpushChanges() {
|
|
569
|
+
const change = 'openAPIpushChanges';
|
|
484
570
|
try {
|
|
485
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}
|
|
571
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ${change}`);
|
|
486
572
|
if (this.On !== this.accessory.context.On) {
|
|
487
573
|
// Make Push On request to the API
|
|
488
|
-
const
|
|
489
|
-
|
|
490
|
-
const data = this.platform.config.credentials?.token + t + nonce;
|
|
491
|
-
const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret)
|
|
492
|
-
.update(Buffer.from(data, 'utf-8'))
|
|
493
|
-
.digest();
|
|
494
|
-
const sign = signTerm.toString('base64');
|
|
495
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} sign: ${sign}`);
|
|
496
|
-
|
|
497
|
-
let command = '';
|
|
498
|
-
if (this.On) {
|
|
574
|
+
const command = this.On ? 'turnOn' : 'turnOff';
|
|
575
|
+
/*if (this.On) {
|
|
499
576
|
command = 'turnOn';
|
|
500
577
|
} else {
|
|
501
578
|
command = 'turnOff';
|
|
502
|
-
}
|
|
579
|
+
}*/
|
|
503
580
|
const body = superStringify({
|
|
504
581
|
'command': `${command}`,
|
|
505
582
|
'parameter': 'default',
|
|
506
583
|
'commandType': 'command',
|
|
507
584
|
});
|
|
508
|
-
this.
|
|
509
|
-
const options = {
|
|
510
|
-
hostname: HostDomain,
|
|
511
|
-
port: 443,
|
|
512
|
-
path: `${DevicePath}/${this.device.deviceId}/commands`,
|
|
513
|
-
method: 'POST',
|
|
514
|
-
headers: {
|
|
515
|
-
'Authorization': this.platform.config.credentials?.token,
|
|
516
|
-
'sign': sign,
|
|
517
|
-
'nonce': nonce,
|
|
518
|
-
't': t,
|
|
519
|
-
'Content-Type': 'application/json',
|
|
520
|
-
'Content-Length': body.length,
|
|
521
|
-
},
|
|
522
|
-
};
|
|
523
|
-
const req = https.request(options, res => {
|
|
524
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIpushChanges statusCode: ${res.statusCode}`);
|
|
525
|
-
this.statusCode({ res });
|
|
526
|
-
res.on('data', d => {
|
|
527
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} d: ${d}`);
|
|
528
|
-
});
|
|
529
|
-
});
|
|
530
|
-
req.on('error', (e: any) => {
|
|
531
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
|
|
532
|
-
});
|
|
533
|
-
req.write(body);
|
|
534
|
-
req.end();
|
|
535
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIpushChanges: ${superStringify(req)}`);
|
|
585
|
+
await this.request({ body, change });
|
|
536
586
|
} else {
|
|
537
587
|
this.debugLog(
|
|
538
|
-
`${this.device.deviceType}: ${this.accessory.displayName} No
|
|
588
|
+
`${this.device.deviceType}: ${this.accessory.displayName} No ${change}.` + `On: ${this.On}, `
|
|
539
589
|
+`OnCached: ${this.accessory.context.On}`,
|
|
540
590
|
);
|
|
541
591
|
}
|
|
@@ -549,15 +599,16 @@ export class StripLight {
|
|
|
549
599
|
}
|
|
550
600
|
} catch (e: any) {
|
|
551
601
|
this.apiError(e);
|
|
552
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed
|
|
602
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed ${change} with ${this.device.connectionType}`
|
|
553
603
|
+ ` Connection, Error Message: ${superStringify(e.message)}`,
|
|
554
604
|
);
|
|
555
605
|
}
|
|
556
606
|
}
|
|
557
607
|
|
|
558
608
|
async pushHueSaturationChanges(): Promise<void> {
|
|
609
|
+
const change = 'pushHueSaturationChanges';
|
|
559
610
|
try {
|
|
560
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}
|
|
611
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ${change}`);
|
|
561
612
|
if (this.Hue !== this.accessory.context.Hue || this.Saturation !== this.accessory.context.Saturation) {
|
|
562
613
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${superStringify(this.Hue)}`);
|
|
563
614
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${superStringify(this.Saturation)}`);
|
|
@@ -565,115 +616,85 @@ export class StripLight {
|
|
|
565
616
|
const [red, green, blue] = hs2rgb(Number(this.Hue), Number(this.Saturation));
|
|
566
617
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} rgb: ${superStringify([red, green, blue])}`);
|
|
567
618
|
// Make Push On request to the API
|
|
568
|
-
const t = Date.now();
|
|
569
|
-
const nonce = 'requestID';
|
|
570
|
-
const data = this.platform.config.credentials?.token + t + nonce;
|
|
571
|
-
const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret)
|
|
572
|
-
.update(Buffer.from(data, 'utf-8'))
|
|
573
|
-
.digest();
|
|
574
|
-
const sign = signTerm.toString('base64');
|
|
575
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} sign: ${sign}`);
|
|
576
619
|
const body = superStringify({
|
|
577
620
|
'command': 'setColor',
|
|
578
621
|
'parameter': `${red}:${green}:${blue}`,
|
|
579
622
|
'commandType': 'command',
|
|
580
623
|
});
|
|
581
|
-
this.
|
|
582
|
-
const options = {
|
|
583
|
-
hostname: HostDomain,
|
|
584
|
-
port: 443,
|
|
585
|
-
path: `${DevicePath}/${this.device.deviceId}/commands`,
|
|
586
|
-
method: 'POST',
|
|
587
|
-
headers: {
|
|
588
|
-
'Authorization': this.platform.config.credentials?.token,
|
|
589
|
-
'sign': sign,
|
|
590
|
-
'nonce': nonce,
|
|
591
|
-
't': t,
|
|
592
|
-
'Content-Type': 'application/json',
|
|
593
|
-
'Content-Length': body.length,
|
|
594
|
-
},
|
|
595
|
-
};
|
|
596
|
-
const req = https.request(options, res => {
|
|
597
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushHueSaturationChanges statusCode: ${res.statusCode}`);
|
|
598
|
-
this.statusCode({ res });
|
|
599
|
-
res.on('data', d => {
|
|
600
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} d: ${d}`);
|
|
601
|
-
});
|
|
602
|
-
});
|
|
603
|
-
req.on('error', (e: any) => {
|
|
604
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
|
|
605
|
-
});
|
|
606
|
-
req.write(body);
|
|
607
|
-
req.end();
|
|
608
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushHueSaturationChanges: ${superStringify(req)}`);
|
|
624
|
+
await this.request({ body, change });
|
|
609
625
|
} else {
|
|
610
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No
|
|
626
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No ${change}. Hue: ${this.Hue}, `
|
|
611
627
|
+ `HueCached: ${this.accessory.context.Hue}, Saturation: ${this.Saturation}, SaturationCached: ${this.accessory.context.Saturation}`);
|
|
612
628
|
}
|
|
613
629
|
} catch (e: any) {
|
|
614
630
|
this.apiError(e);
|
|
615
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed
|
|
631
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed ${change} with ${this.device.connectionType}`
|
|
616
632
|
+ ` Connection, Error Message: ${superStringify(e.message)}`);
|
|
617
633
|
}
|
|
618
634
|
}
|
|
619
635
|
|
|
620
636
|
async pushBrightnessChanges(): Promise<void> {
|
|
637
|
+
const change = 'pushBrightnessChanges';
|
|
621
638
|
try {
|
|
622
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}
|
|
639
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ${change}`);
|
|
623
640
|
if (this.Brightness !== this.accessory.context.Brightness) {
|
|
624
641
|
// Make Push On request to the API
|
|
625
|
-
const t = Date.now();
|
|
626
|
-
const nonce = 'requestID';
|
|
627
|
-
const data = this.platform.config.credentials?.token + t + nonce;
|
|
628
|
-
const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret)
|
|
629
|
-
.update(Buffer.from(data, 'utf-8'))
|
|
630
|
-
.digest();
|
|
631
|
-
const sign = signTerm.toString('base64');
|
|
632
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} sign: ${sign}`);
|
|
633
642
|
const body = superStringify({
|
|
634
643
|
'command': 'setBrightness',
|
|
635
644
|
'parameter': `${this.Brightness}`,
|
|
636
645
|
'commandType': 'command',
|
|
637
646
|
});
|
|
638
|
-
this.
|
|
639
|
-
const options = {
|
|
640
|
-
hostname: HostDomain,
|
|
641
|
-
port: 443,
|
|
642
|
-
path: `${DevicePath}/${this.device.deviceId}/commands`,
|
|
643
|
-
method: 'POST',
|
|
644
|
-
headers: {
|
|
645
|
-
'Authorization': this.platform.config.credentials?.token,
|
|
646
|
-
'sign': sign,
|
|
647
|
-
'nonce': nonce,
|
|
648
|
-
't': t,
|
|
649
|
-
'Content-Type': 'application/json',
|
|
650
|
-
'Content-Length': body.length,
|
|
651
|
-
},
|
|
652
|
-
};
|
|
653
|
-
const req = https.request(options, res => {
|
|
654
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushBrightnessChanges statusCode: ${res.statusCode}`);
|
|
655
|
-
this.statusCode({ res });
|
|
656
|
-
res.on('data', d => {
|
|
657
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} d: ${d}`);
|
|
658
|
-
});
|
|
659
|
-
});
|
|
660
|
-
req.on('error', (e: any) => {
|
|
661
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
|
|
662
|
-
});
|
|
663
|
-
req.write(body);
|
|
664
|
-
req.end();
|
|
665
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushBrightnessChanges: ${superStringify(req)}`);
|
|
647
|
+
await this.request({ body, change });
|
|
666
648
|
} else {
|
|
667
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No
|
|
649
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No ${change},` + `Brightness: ${this.Brightness}, `
|
|
668
650
|
+`BrightnessCached: ${this.accessory.context.Brightness}`);
|
|
669
651
|
}
|
|
670
652
|
} catch (e: any) {
|
|
671
653
|
this.apiError(e);
|
|
672
|
-
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed
|
|
654
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed ${change} with ${this.device.connectionType}`
|
|
673
655
|
+ ` Connection, Error Message: ${superStringify(e.message)}`);
|
|
674
656
|
}
|
|
675
657
|
}
|
|
676
658
|
|
|
659
|
+
async request({ body, change }: { body: any; change: string; }): Promise<void> {
|
|
660
|
+
const t = Date.now();
|
|
661
|
+
const nonce = 'requestID';
|
|
662
|
+
const data = this.platform.config.credentials?.token + t + nonce;
|
|
663
|
+
const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret)
|
|
664
|
+
.update(Buffer.from(data, 'utf-8'))
|
|
665
|
+
.digest();
|
|
666
|
+
const sign = signTerm.toString('base64');
|
|
667
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} sign: ${sign}`);
|
|
668
|
+
const options = {
|
|
669
|
+
hostname: HostDomain,
|
|
670
|
+
port: 443,
|
|
671
|
+
path: `${DevicePath}/${this.device.deviceId}/commands`,
|
|
672
|
+
method: 'POST',
|
|
673
|
+
headers: {
|
|
674
|
+
'Authorization': this.platform.config.credentials?.token,
|
|
675
|
+
'sign': sign,
|
|
676
|
+
'nonce': nonce,
|
|
677
|
+
't': t,
|
|
678
|
+
'Content-Type': 'application/json',
|
|
679
|
+
'Content-Length': body.length,
|
|
680
|
+
},
|
|
681
|
+
};
|
|
682
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
|
|
683
|
+
const req = https.request(options, res => {
|
|
684
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ${change} statusCode: ${res.statusCode}`);
|
|
685
|
+
this.statusCode({ res });
|
|
686
|
+
res.on('data', d => {
|
|
687
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} d: ${d}`);
|
|
688
|
+
});
|
|
689
|
+
});
|
|
690
|
+
req.on('error', (e: any) => {
|
|
691
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
|
|
692
|
+
});
|
|
693
|
+
req.write(body);
|
|
694
|
+
req.end();
|
|
695
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ${change} req: ${superStringify(req)}`);
|
|
696
|
+
}
|
|
697
|
+
|
|
677
698
|
/**
|
|
678
699
|
* Handle requests to set the value of the "On" characteristic
|
|
679
700
|
*/
|
|
@@ -1004,7 +1025,7 @@ export class StripLight {
|
|
|
1004
1025
|
} else {
|
|
1005
1026
|
this.Brightness = this.accessory.context.Brightness;
|
|
1006
1027
|
}
|
|
1007
|
-
if (this.
|
|
1028
|
+
if (this.Saturation === undefined) {
|
|
1008
1029
|
this.Saturation = 0;
|
|
1009
1030
|
} else {
|
|
1010
1031
|
this.Saturation = this.accessory.context.Saturation;
|
|
@@ -559,9 +559,9 @@ export class AirConditioner {
|
|
|
559
559
|
|
|
560
560
|
async allowPushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
561
561
|
if (device.allowPushOff) {
|
|
562
|
-
this.
|
|
562
|
+
this.allowPushOff = true;
|
|
563
563
|
} else {
|
|
564
|
-
this.
|
|
564
|
+
this.allowPushOff = false;
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
567
|
|
|
@@ -288,9 +288,9 @@ export class AirPurifier {
|
|
|
288
288
|
|
|
289
289
|
async allowPushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
290
290
|
if (device.allowPushOff) {
|
|
291
|
-
this.
|
|
291
|
+
this.allowPushOff = true;
|
|
292
292
|
} else {
|
|
293
|
-
this.
|
|
293
|
+
this.allowPushOff = false;
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
296
|
|
package/src/irdevice/camera.ts
CHANGED
|
@@ -185,9 +185,9 @@ export class Camera {
|
|
|
185
185
|
|
|
186
186
|
async allowPushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
187
187
|
if (device.allowPushOff) {
|
|
188
|
-
this.
|
|
188
|
+
this.allowPushOff = true;
|
|
189
189
|
} else {
|
|
190
|
-
this.
|
|
190
|
+
this.allowPushOff = false;
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
|
package/src/irdevice/fan.ts
CHANGED
|
@@ -316,9 +316,9 @@ export class Fan {
|
|
|
316
316
|
|
|
317
317
|
async allowPushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
318
318
|
if (device.allowPushOff) {
|
|
319
|
-
this.
|
|
319
|
+
this.allowPushOff = true;
|
|
320
320
|
} else {
|
|
321
|
-
this.
|
|
321
|
+
this.allowPushOff = false;
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
324
|
|
package/src/irdevice/light.ts
CHANGED
|
@@ -204,9 +204,9 @@ export class Light {
|
|
|
204
204
|
|
|
205
205
|
async allowPushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
206
206
|
if (device.allowPushOff) {
|
|
207
|
-
this.
|
|
207
|
+
this.allowPushOff = true;
|
|
208
208
|
} else {
|
|
209
|
-
this.
|
|
209
|
+
this.allowPushOff = false;
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
|
package/src/irdevice/other.ts
CHANGED
|
@@ -201,9 +201,9 @@ export class Others {
|
|
|
201
201
|
|
|
202
202
|
async allowPushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
203
203
|
if (device.allowPushOff) {
|
|
204
|
-
this.
|
|
204
|
+
this.allowPushOff = true;
|
|
205
205
|
} else {
|
|
206
|
-
this.
|
|
206
|
+
this.allowPushOff = false;
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
|
package/src/irdevice/tv.ts
CHANGED
|
@@ -419,9 +419,9 @@ export class TV {
|
|
|
419
419
|
|
|
420
420
|
async allowPushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
421
421
|
if (device.allowPushOff) {
|
|
422
|
-
this.
|
|
422
|
+
this.allowPushOff = true;
|
|
423
423
|
} else {
|
|
424
|
-
this.
|
|
424
|
+
this.allowPushOff = false;
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
427
|
|
|
@@ -182,9 +182,9 @@ export class VacuumCleaner {
|
|
|
182
182
|
|
|
183
183
|
async allowPushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
184
184
|
if (device.allowPushOff) {
|
|
185
|
-
this.
|
|
185
|
+
this.allowPushOff = true;
|
|
186
186
|
} else {
|
|
187
|
-
this.
|
|
187
|
+
this.allowPushOff = false;
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
|
|
@@ -190,9 +190,9 @@ export class WaterHeater {
|
|
|
190
190
|
|
|
191
191
|
async allowPushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
|
|
192
192
|
if (device.allowPushOff) {
|
|
193
|
-
this.
|
|
193
|
+
this.allowPushOff = true;
|
|
194
194
|
} else {
|
|
195
|
-
this.
|
|
195
|
+
this.allowPushOff = false;
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
|
package/src/platform.ts
CHANGED
|
@@ -289,11 +289,6 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
289
289
|
const devicesAPI = JSON.parse(rawData);
|
|
290
290
|
this.debugLog(`devicesAPI: ${superStringify(devicesAPI.body)}`);
|
|
291
291
|
// SwitchBot Devices
|
|
292
|
-
if (devicesAPI.body.deviceList.length !== 0) {
|
|
293
|
-
this.infoLog(`Total SwitchBot Devices Found: ${devicesAPI.body.deviceList.length}`);
|
|
294
|
-
} else {
|
|
295
|
-
this.debugLog(`Total SwitchBot Devices Found: ${devicesAPI.body.deviceList.length}`);
|
|
296
|
-
}
|
|
297
292
|
const deviceLists = devicesAPI.body.deviceList;
|
|
298
293
|
if (!this.config.options?.devices) {
|
|
299
294
|
this.debugLog(`SwitchBot Device Config Not Set: ${JSON.stringify(this.config.options?.devices)}`);
|
|
@@ -332,13 +327,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
332
327
|
} else {
|
|
333
328
|
this.errorLog('SwitchBot Token Supplied, Issue with Auth.');
|
|
334
329
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
if (devicesAPI.body.infraredRemoteList.length !== 0) {
|
|
338
|
-
this.infoLog(`Total IR Devices Found: ${devicesAPI.body.infraredRemoteList.length}`);
|
|
330
|
+
if (devicesAPI.body.deviceList.length !== 0) {
|
|
331
|
+
this.infoLog(`Total SwitchBot Devices Found: ${devicesAPI.body.deviceList.length}`);
|
|
339
332
|
} else {
|
|
340
|
-
this.debugLog(`Total
|
|
333
|
+
this.debugLog(`Total SwitchBot Devices Found: ${devicesAPI.body.deviceList.length}`);
|
|
341
334
|
}
|
|
335
|
+
|
|
336
|
+
// IR Devices
|
|
342
337
|
const irDeviceLists = devicesAPI.body.infraredRemoteList;
|
|
343
338
|
if (!this.config.options?.irdevices) {
|
|
344
339
|
this.debugLog(`IR Device Config Not Set: ${JSON.stringify(this.config.options?.irdevices)}`);
|
|
@@ -367,6 +362,11 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
367
362
|
this.createIRDevice(device);
|
|
368
363
|
}
|
|
369
364
|
}
|
|
365
|
+
if (devicesAPI.body.infraredRemoteList.length !== 0) {
|
|
366
|
+
this.infoLog(`Total IR Devices Found: ${devicesAPI.body.infraredRemoteList.length}`);
|
|
367
|
+
} else {
|
|
368
|
+
this.debugLog(`Total IR Devices Found: ${devicesAPI.body.infraredRemoteList.length}`);
|
|
369
|
+
}
|
|
370
370
|
} catch (e:any) {
|
|
371
371
|
this.errorLog(`API Request: ${e}, Submit Bugs Here: ` + 'https://tinyurl.com/SwitchBotBug');
|
|
372
372
|
}
|