@switchbot/homebridge-switchbot 2.2.2-beta.2 → 2.2.2-beta.20

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.
Files changed (91) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/config.schema.json +0 -31
  3. package/dist/device/bot.d.ts +1 -3
  4. package/dist/device/bot.d.ts.map +1 -1
  5. package/dist/device/bot.js +2 -2
  6. package/dist/device/bot.js.map +1 -1
  7. package/dist/device/ceilinglight.d.ts +1 -3
  8. package/dist/device/ceilinglight.d.ts.map +1 -1
  9. package/dist/device/ceilinglight.js +5 -5
  10. package/dist/device/ceilinglight.js.map +1 -1
  11. package/dist/device/colorbulb.d.ts +1 -3
  12. package/dist/device/colorbulb.d.ts.map +1 -1
  13. package/dist/device/colorbulb.js +7 -7
  14. package/dist/device/colorbulb.js.map +1 -1
  15. package/dist/device/contact.d.ts +1 -3
  16. package/dist/device/contact.d.ts.map +1 -1
  17. package/dist/device/contact.js +1 -1
  18. package/dist/device/contact.js.map +1 -1
  19. package/dist/device/curtain.js +1 -1
  20. package/dist/device/curtain.js.map +1 -1
  21. package/dist/device/humidifier.d.ts +7 -9
  22. package/dist/device/humidifier.d.ts.map +1 -1
  23. package/dist/device/humidifier.js +16 -10
  24. package/dist/device/humidifier.js.map +1 -1
  25. package/dist/device/lock.js +1 -1
  26. package/dist/device/lock.js.map +1 -1
  27. package/dist/device/meter.d.ts +1 -3
  28. package/dist/device/meter.d.ts.map +1 -1
  29. package/dist/device/meter.js +1 -1
  30. package/dist/device/meter.js.map +1 -1
  31. package/dist/device/meterplus.d.ts +1 -3
  32. package/dist/device/meterplus.d.ts.map +1 -1
  33. package/dist/device/meterplus.js +1 -1
  34. package/dist/device/meterplus.js.map +1 -1
  35. package/dist/device/motion.d.ts +2 -3
  36. package/dist/device/motion.d.ts.map +1 -1
  37. package/dist/device/motion.js +15 -11
  38. package/dist/device/motion.js.map +1 -1
  39. package/dist/device/plug.d.ts +1 -3
  40. package/dist/device/plug.d.ts.map +1 -1
  41. package/dist/device/plug.js +2 -2
  42. package/dist/device/plug.js.map +1 -1
  43. package/dist/device/striplight.d.ts +8 -3
  44. package/dist/device/striplight.d.ts.map +1 -1
  45. package/dist/device/striplight.js +151 -132
  46. package/dist/device/striplight.js.map +1 -1
  47. package/dist/irdevice/airconditioner.js +2 -2
  48. package/dist/irdevice/airconditioner.js.map +1 -1
  49. package/dist/irdevice/airpurifier.js +2 -2
  50. package/dist/irdevice/airpurifier.js.map +1 -1
  51. package/dist/irdevice/camera.js +2 -2
  52. package/dist/irdevice/camera.js.map +1 -1
  53. package/dist/irdevice/fan.js +2 -2
  54. package/dist/irdevice/fan.js.map +1 -1
  55. package/dist/irdevice/light.js +2 -2
  56. package/dist/irdevice/light.js.map +1 -1
  57. package/dist/irdevice/other.js +2 -2
  58. package/dist/irdevice/other.js.map +1 -1
  59. package/dist/irdevice/tv.d.ts.map +1 -1
  60. package/dist/irdevice/tv.js +18 -15
  61. package/dist/irdevice/tv.js.map +1 -1
  62. package/dist/irdevice/vacuumcleaner.js +2 -2
  63. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  64. package/dist/irdevice/waterheater.js +2 -2
  65. package/dist/irdevice/waterheater.js.map +1 -1
  66. package/dist/settings.d.ts +1 -16
  67. package/dist/settings.d.ts.map +1 -1
  68. package/dist/settings.js.map +1 -1
  69. package/package.json +1 -1
  70. package/src/device/bot.ts +2 -2
  71. package/src/device/ceilinglight.ts +5 -5
  72. package/src/device/colorbulb.ts +7 -7
  73. package/src/device/contact.ts +1 -1
  74. package/src/device/curtain.ts +1 -1
  75. package/src/device/humidifier.ts +14 -10
  76. package/src/device/lock.ts +1 -1
  77. package/src/device/meter.ts +1 -1
  78. package/src/device/meterplus.ts +1 -1
  79. package/src/device/motion.ts +16 -11
  80. package/src/device/plug.ts +2 -2
  81. package/src/device/striplight.ts +148 -127
  82. package/src/irdevice/airconditioner.ts +2 -2
  83. package/src/irdevice/airpurifier.ts +2 -2
  84. package/src/irdevice/camera.ts +2 -2
  85. package/src/irdevice/fan.ts +2 -2
  86. package/src/irdevice/light.ts +2 -2
  87. package/src/irdevice/other.ts +2 -2
  88. package/src/irdevice/tv.ts +14 -12
  89. package/src/irdevice/vacuumcleaner.ts +2 -2
  90. package/src/irdevice/waterheater.ts +2 -2
  91. package/src/settings.ts +1 -23
@@ -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;
@@ -214,9 +215,9 @@ export class StripLight {
214
215
  async parseStatus(): Promise<void> {
215
216
  if (!this.device.enableCloudService && this.OpenAPI) {
216
217
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} parseStatus enableCloudService: ${this.device.enableCloudService}`);
217
- } else/*if (this.BLE) {
218
+ } else if (this.BLE) {
218
219
  await this.BLEparseStatus();
219
- } else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
220
+ } else if (this.OpenAPI && this.platform.config.credentials?.token) {
220
221
  await this.openAPIparseStatus();
221
222
  } else {
222
223
  await this.offlineOff();
@@ -281,9 +282,9 @@ export class StripLight {
281
282
  async refreshStatus(): Promise<void> {
282
283
  if (!this.device.enableCloudService && this.OpenAPI) {
283
284
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus enableCloudService: ${this.device.enableCloudService}`);
284
- } else/*if (this.BLE) {
285
+ } else if (this.BLE) {
285
286
  await this.BLERefreshStatus();
286
- } else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
287
+ } else if (this.OpenAPI && this.platform.config.credentials?.token) {
287
288
  await this.openAPIRefreshStatus();
288
289
  } else {
289
290
  await this.offlineOff();
@@ -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} openAPIpushChanges`);
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 t = Date.now();
489
- const nonce = 'requestID';
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.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
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 openAPIpushChanges.` + `On: ${this.On}, `
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 openAPIpushChanges with ${this.device.connectionType}`
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} pushHueSaturationChanges`);
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.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
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 pushHueSaturationChanges. Hue: ${this.Hue}, `
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 pushHueSaturationChanges with ${this.device.connectionType}`
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} pushBrightnessChanges`);
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.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
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 pushBrightnessChanges.` + `Brightness: ${this.Brightness}, `
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 pushBrightnessChanges with ${this.device.connectionType}`
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
  */
@@ -809,7 +830,7 @@ export class StripLight {
809
830
  }
810
831
  }
811
832
 
812
- async stopScanning({ switchbot }: { switchbot: any; }): Promise<void> {
833
+ async stopScanning(switchbot: any) {
813
834
  await switchbot.stopScan();
814
835
  if (this.connected) {
815
836
  await this.BLEparseStatus();
@@ -1004,7 +1025,7 @@ export class StripLight {
1004
1025
  } else {
1005
1026
  this.Brightness = this.accessory.context.Brightness;
1006
1027
  }
1007
- if (this.Brightness === undefined) {
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.allowPushOn = true;
562
+ this.allowPushOff = true;
563
563
  } else {
564
- this.allowPushOn = false;
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.allowPushOn = true;
291
+ this.allowPushOff = true;
292
292
  } else {
293
- this.allowPushOn = false;
293
+ this.allowPushOff = false;
294
294
  }
295
295
  }
296
296
 
@@ -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.allowPushOn = true;
188
+ this.allowPushOff = true;
189
189
  } else {
190
- this.allowPushOn = false;
190
+ this.allowPushOff = false;
191
191
  }
192
192
  }
193
193
 
@@ -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.allowPushOn = true;
319
+ this.allowPushOff = true;
320
320
  } else {
321
- this.allowPushOn = false;
321
+ this.allowPushOff = false;
322
322
  }
323
323
  }
324
324
 
@@ -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.allowPushOn = true;
207
+ this.allowPushOff = true;
208
208
  } else {
209
- this.allowPushOn = false;
209
+ this.allowPushOff = false;
210
210
  }
211
211
  }
212
212
 
@@ -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.allowPushOn = true;
204
+ this.allowPushOff = true;
205
205
  } else {
206
- this.allowPushOn = false;
206
+ this.allowPushOff = false;
207
207
  }
208
208
  }
209
209
 
@@ -197,23 +197,20 @@ export class TV {
197
197
  async ActiveIdentifierSet(value: CharacteristicValue): Promise<void> {
198
198
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ActiveIdentifier: ${value}`);
199
199
  this.ActiveIdentifier = value;
200
- this.accessory.context.ActiveIdentifier = this.ActiveIdentifier;
201
200
  }
202
201
 
203
202
  async ActiveSet(value: CharacteristicValue): Promise<void> {
204
203
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${value}`);
205
- if (!this.device.irtv?.disable_power) {
206
- if (value === this.platform.Characteristic.Active.INACTIVE) {
207
- await this.pushTvOffChanges();
208
- } else {
209
- await this.pushTvOnChanges();
210
- }
211
- /**
204
+ if (value === this.platform.Characteristic.Active.ACTIVE) {
205
+ await this.pushTvOnChanges();
206
+ } else {
207
+ await this.pushTvOffChanges();
208
+ }
209
+ /**
212
210
  * pushTvOnChanges and pushTvOffChanges above assume they are measuring the state of the accessory BEFORE
213
211
  * they are updated, so we are only updating the accessory state after calling the above.
214
212
  */
215
- this.Active = value;
216
- }
213
+ this.Active = value;
217
214
  }
218
215
 
219
216
  /**
@@ -419,9 +416,9 @@ export class TV {
419
416
 
420
417
  async allowPushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
421
418
  if (device.allowPushOff) {
422
- this.allowPushOn = true;
419
+ this.allowPushOff = true;
423
420
  } else {
424
- this.allowPushOn = false;
421
+ this.allowPushOff = false;
425
422
  }
426
423
  }
427
424
 
@@ -514,6 +511,11 @@ export class TV {
514
511
  } else {
515
512
  this.Active = this.accessory.context.Active;
516
513
  }
514
+ if (this.ActiveIdentifier === undefined) {
515
+ this.ActiveIdentifier = 1;
516
+ } else {
517
+ this.ActiveIdentifier = this.accessory.context.ActiveIdentifier;
518
+ }
517
519
  }
518
520
 
519
521
  async config(device: irdevice & irDevicesConfig): Promise<void> {
@@ -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.allowPushOn = true;
185
+ this.allowPushOff = true;
186
186
  } else {
187
- this.allowPushOn = false;
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.allowPushOn = true;
193
+ this.allowPushOff = true;
194
194
  } else {
195
- this.allowPushOn = false;
195
+ this.allowPushOff = false;
196
196
  }
197
197
  }
198
198
 
package/src/settings.ts CHANGED
@@ -149,7 +149,7 @@ export interface irDevicesConfig extends irdevice {
149
149
  irlight?: Record<any, any>;
150
150
  irvc?: Record<any, any>;
151
151
  irwh?: Record<any, any>;
152
- irtv?: irtv;
152
+ irtv?: Record<any, any>;
153
153
  other?: other;
154
154
  }
155
155
 
@@ -161,32 +161,10 @@ export type irfan = {
161
161
  set_min?: number; //set_min
162
162
  };
163
163
 
164
- //For Potential Future Use
165
- export type set_minStep = {
166
- set_minStep_device?: boolean;
167
- set_minStep?: number;
168
- };
169
-
170
- //For Potential Future Use
171
- export type set_max = {
172
- set_max_device?: boolean;
173
- set_max?: number;
174
- };
175
-
176
- //For Potential Future Use
177
- export type set_min = {
178
- set_min_device?: boolean;
179
- set_min?: number;
180
- };
181
-
182
164
  export type irair = {
183
165
  hide_automode?: boolean;
184
166
  };
185
167
 
186
- export type irtv = {
187
- disable_power?: boolean;
188
- };
189
-
190
168
  export type other = {
191
169
  deviceType?: string;
192
170
  };