@pietrolubini/homebridge-ecoflow 1.6.0-alpha.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/.gitattributes +1 -0
  2. package/README.md +132 -63
  3. package/config.schema.json +46 -1
  4. package/dist/accessories/ecoFlowAccessoryBase.d.ts +4 -1
  5. package/dist/accessories/ecoFlowAccessoryBase.js +27 -2
  6. package/dist/accessories/ecoFlowAccessoryBase.js.map +1 -1
  7. package/dist/accessories/powerocean/interfaces/powerOceanHttpApiContracts.d.ts +7 -0
  8. package/dist/accessories/powerocean/interfaces/powerOceanHttpApiContracts.js +3 -0
  9. package/dist/accessories/powerocean/interfaces/powerOceanHttpApiContracts.js.map +1 -0
  10. package/dist/accessories/powerocean/interfaces/powerOceanMqttApiContracts.d.ts +5 -0
  11. package/dist/accessories/powerocean/interfaces/powerOceanMqttApiContracts.js +3 -0
  12. package/dist/accessories/powerocean/interfaces/powerOceanMqttApiContracts.js.map +1 -0
  13. package/dist/accessories/powerocean/powerOceanAccessory.d.ts +24 -0
  14. package/dist/accessories/powerocean/powerOceanAccessory.js +87 -0
  15. package/dist/accessories/powerocean/powerOceanAccessory.js.map +1 -0
  16. package/dist/accessories/powerocean/simulations/powerOceanSimulator.d.ts +5 -0
  17. package/dist/accessories/powerocean/simulations/powerOceanSimulator.js +23 -0
  18. package/dist/accessories/powerocean/simulations/powerOceanSimulator.js.map +1 -0
  19. package/dist/accessories/powerstream/powerStreamAccessory.js +4 -5
  20. package/dist/accessories/powerstream/powerStreamAccessory.js.map +1 -1
  21. package/dist/apis/containers/mqttDevice.d.ts +2 -0
  22. package/dist/apis/containers/mqttDevice.js +7 -0
  23. package/dist/apis/containers/mqttDevice.js.map +1 -1
  24. package/dist/apis/ecoFlowMqttApiManager.d.ts +2 -0
  25. package/dist/apis/ecoFlowMqttApiManager.js +6 -0
  26. package/dist/apis/ecoFlowMqttApiManager.js.map +1 -1
  27. package/dist/apis/interfaces/mqttApiContracts.d.ts +11 -1
  28. package/dist/apis/interfaces/mqttApiContracts.js +1 -0
  29. package/dist/apis/interfaces/mqttApiContracts.js.map +1 -1
  30. package/dist/apis/simulations/mockMqttClient.d.ts +3 -1
  31. package/dist/apis/simulations/mockMqttClient.js +24 -5
  32. package/dist/apis/simulations/mockMqttClient.js.map +1 -1
  33. package/dist/apis/simulations/simulator.d.ts +2 -1
  34. package/dist/apis/simulations/simulator.js +12 -0
  35. package/dist/apis/simulations/simulator.js.map +1 -1
  36. package/dist/config.d.ts +7 -3
  37. package/dist/config.js +2 -1
  38. package/dist/config.js.map +1 -1
  39. package/dist/homebridge-ui/public/index.html +1 -1
  40. package/dist/homebridge-ui/public/index.js +1 -1
  41. package/dist/platform.js +8 -6
  42. package/dist/platform.js.map +1 -1
  43. package/dist/services/contactSensorService.d.ts +1 -0
  44. package/dist/services/contactSensorService.js +6 -3
  45. package/dist/services/contactSensorService.js.map +1 -1
  46. package/dist/services/fanServiceBase.d.ts +3 -1
  47. package/dist/services/fanServiceBase.js +21 -15
  48. package/dist/services/fanServiceBase.js.map +1 -1
  49. package/dist/services/lightBulbServiceBase.d.ts +3 -1
  50. package/dist/services/lightBulbServiceBase.js +21 -15
  51. package/dist/services/lightBulbServiceBase.js.map +1 -1
  52. package/dist/{accessories/powerstream/services/outletInvService.d.ts → services/outletReadOnlyService.d.ts} +2 -2
  53. package/dist/{accessories/powerstream/services/outletService.js → services/outletReadOnlyService.js} +4 -4
  54. package/dist/services/outletReadOnlyService.js.map +1 -0
  55. package/dist/services/outletServiceBase.d.ts +1 -0
  56. package/dist/services/outletServiceBase.js +8 -5
  57. package/dist/services/outletServiceBase.js.map +1 -1
  58. package/dist/services/serviceBase.d.ts +6 -1
  59. package/dist/services/serviceBase.js +23 -10
  60. package/dist/services/serviceBase.js.map +1 -1
  61. package/dist/services/switchServiceBase.d.ts +1 -0
  62. package/dist/services/switchServiceBase.js +8 -5
  63. package/dist/services/switchServiceBase.js.map +1 -1
  64. package/dist/services/temperatureSensorService.d.ts +1 -1
  65. package/dist/services/temperatureSensorService.js +4 -3
  66. package/dist/services/temperatureSensorService.js.map +1 -1
  67. package/dist/services/thermostatFridgeServiceBase.d.ts +6 -3
  68. package/dist/services/thermostatFridgeServiceBase.js +50 -30
  69. package/dist/services/thermostatFridgeServiceBase.js.map +1 -1
  70. package/junit.xml +1042 -834
  71. package/package.json +1 -1
  72. package/dist/accessories/powerstream/services/outletInvService.js +0 -14
  73. package/dist/accessories/powerstream/services/outletInvService.js.map +0 -1
  74. package/dist/accessories/powerstream/services/outletService.d.ts +0 -9
  75. package/dist/accessories/powerstream/services/outletService.js.map +0 -1
  76. /package/dist/accessories/{powerstream/services/outletInvService.spec.d.ts → powerocean/powerOceanAccessory.spec.d.ts} +0 -0
  77. /package/dist/{accessories/powerstream/services/outletService.spec.d.ts → services/outletReadOnlyService.spec.d.ts} +0 -0
@@ -5,7 +5,9 @@ const serviceBase_1 = require("@ecoflow/services/serviceBase");
5
5
  class FanServiceBase extends serviceBase_1.ServiceBase {
6
6
  ecoFlowAccessory;
7
7
  maxRotationSpeed;
8
- currentRotationSpeed = 0;
8
+ state = false;
9
+ rotationSpeedPercents = 0;
10
+ rotationSpeed = 0;
9
11
  rotationSpeedCharacteristic = null;
10
12
  constructor(ecoFlowAccessory, maxRotationSpeed, serviceSubType) {
11
13
  super(ecoFlowAccessory.platform.Service.Fan, ecoFlowAccessory, serviceSubType);
@@ -13,26 +15,30 @@ class FanServiceBase extends serviceBase_1.ServiceBase {
13
15
  this.maxRotationSpeed = maxRotationSpeed;
14
16
  }
15
17
  addCharacteristics() {
16
- const onCharacteristic = this.addCharacteristic(this.platform.Characteristic.On);
17
- onCharacteristic.onSet(value => {
18
- const newValue = value;
19
- this.processOnSetOn(newValue, () => this.updateState(!newValue));
20
- });
21
- this.rotationSpeedCharacteristic = this.addCharacteristic(this.platform.Characteristic.RotationSpeed);
22
- this.rotationSpeedCharacteristic.onSet(percents => {
23
- const prevRotationSpeed = this.currentRotationSpeed;
24
- this.currentRotationSpeed = this.covertPercentsToValue(percents, this.maxRotationSpeed);
25
- this.processOnSetRotationSpeed(this.currentRotationSpeed, () => this.updateRotationSpeed(prevRotationSpeed));
26
- });
18
+ const onCharacteristic = this.addCharacteristic(this.platform.Characteristic.On)
19
+ .onGet(() => this.processOnGet(this.state))
20
+ .onSet(value => this.processOnSet(this.platform.Characteristic.On.name, () => {
21
+ this.state = value;
22
+ this.processOnSetOn(this.state, () => this.updateState(!this.state));
23
+ }));
24
+ this.rotationSpeedCharacteristic = this.addCharacteristic(this.platform.Characteristic.RotationSpeed)
25
+ .onGet(() => this.processOnGet(this.rotationSpeedPercents))
26
+ .onSet(percents => this.processOnSet(this.platform.Characteristic.RotationSpeed.name, () => {
27
+ this.rotationSpeedPercents = percents;
28
+ const prevRotationSpeed = this.rotationSpeed;
29
+ this.rotationSpeed = this.covertPercentsToValue(this.rotationSpeedPercents, this.maxRotationSpeed);
30
+ this.processOnSetRotationSpeed(this.rotationSpeed, () => this.updateRotationSpeed(prevRotationSpeed));
31
+ }));
27
32
  return [onCharacteristic, this.rotationSpeedCharacteristic];
28
33
  }
29
34
  updateState(state) {
35
+ this.state = state;
30
36
  this.updateCharacteristic(this.platform.Characteristic.On, 'State', state);
31
37
  }
32
38
  updateRotationSpeed(value) {
33
- const percents = this.covertValueToPercents(value, this.maxRotationSpeed);
34
- this.updateCharacteristic(this.platform.Characteristic.RotationSpeed, 'RotationSpeed', percents);
35
- this.currentRotationSpeed = value;
39
+ this.rotationSpeedPercents = this.covertValueToPercents(value, this.maxRotationSpeed);
40
+ this.updateCharacteristic(this.platform.Characteristic.RotationSpeed, 'RotationSpeed', this.rotationSpeedPercents);
41
+ this.rotationSpeed = value;
36
42
  }
37
43
  setRotationSpeed(value) {
38
44
  this.rotationSpeedCharacteristic?.setValue(value);
@@ -1 +1 @@
1
- {"version":3,"file":"fanServiceBase.js","sourceRoot":"","sources":["../../src/services/fanService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,EAAE,IAAI,CAAC,2BAA2B,CAAC,CAAC;IAC9D,CAAC;IAEM,WAAW,CAAC,KAAc;QAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAC7E,CAAC;IAEM,mBAAmB,CAAC,KAAa;QACtC,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACtF,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,aAAa,EAAE,eAAe,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAC;QACnH,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;IAC7B,CAAC;IAES,gBAAgB,CAAC,KAAa;QACtC,IAAI,CAAC,2BAA2B,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC;CAKF;AAxDD,wCAwDC"}
@@ -4,7 +4,9 @@ import { Characteristic } from 'homebridge';
4
4
  export declare abstract class LightBulbServiceBase extends ServiceBase {
5
5
  protected readonly ecoFlowAccessory: EcoFlowAccessoryBase;
6
6
  private readonly maxBrightness;
7
- private currentBrightness;
7
+ private state;
8
+ private brightnessPercents;
9
+ private brightness;
8
10
  private brightnessCharacteristic;
9
11
  constructor(ecoFlowAccessory: EcoFlowAccessoryBase, maxBrightness: number, serviceSubType: string);
10
12
  protected addCharacteristics(): Characteristic[];
@@ -5,7 +5,9 @@ const serviceBase_1 = require("@ecoflow/services/serviceBase");
5
5
  class LightBulbServiceBase extends serviceBase_1.ServiceBase {
6
6
  ecoFlowAccessory;
7
7
  maxBrightness;
8
- currentBrightness = 0;
8
+ state = false;
9
+ brightnessPercents = 0;
10
+ brightness = 0;
9
11
  brightnessCharacteristic = null;
10
12
  constructor(ecoFlowAccessory, maxBrightness, serviceSubType) {
11
13
  super(ecoFlowAccessory.platform.Service.Lightbulb, ecoFlowAccessory, serviceSubType);
@@ -13,26 +15,30 @@ class LightBulbServiceBase extends serviceBase_1.ServiceBase {
13
15
  this.maxBrightness = maxBrightness;
14
16
  }
15
17
  addCharacteristics() {
16
- const onCharacteristic = this.addCharacteristic(this.platform.Characteristic.On);
17
- onCharacteristic.onSet(value => {
18
- const newValue = value;
19
- this.processOnSetOn(newValue, () => this.updateState(!newValue));
20
- });
21
- this.brightnessCharacteristic = this.addCharacteristic(this.platform.Characteristic.Brightness);
22
- this.brightnessCharacteristic.onSet(percents => {
23
- const prevBrightness = this.currentBrightness;
24
- this.currentBrightness = this.covertPercentsToValue(percents, this.maxBrightness);
25
- this.processOnSetBrightness(this.currentBrightness, () => this.updateBrightness(prevBrightness));
26
- });
18
+ const onCharacteristic = this.addCharacteristic(this.platform.Characteristic.On)
19
+ .onGet(() => this.processOnGet(this.state))
20
+ .onSet(value => this.processOnSet(this.platform.Characteristic.On.name, () => {
21
+ this.state = value;
22
+ this.processOnSetOn(this.state, () => this.updateState(!this.state));
23
+ }));
24
+ this.brightnessCharacteristic = this.addCharacteristic(this.platform.Characteristic.Brightness)
25
+ .onGet(() => this.processOnGet(this.brightnessPercents))
26
+ .onSet(percents => this.processOnSet(this.platform.Characteristic.Brightness.name, () => {
27
+ this.brightnessPercents = percents;
28
+ const prevBrightness = this.brightness;
29
+ this.brightness = this.covertPercentsToValue(this.brightnessPercents, this.maxBrightness);
30
+ this.processOnSetBrightness(this.brightness, () => this.updateBrightness(prevBrightness));
31
+ }));
27
32
  return [onCharacteristic, this.brightnessCharacteristic];
28
33
  }
29
34
  updateState(state) {
35
+ this.state = state;
30
36
  this.updateCharacteristic(this.platform.Characteristic.On, 'State', state);
31
37
  }
32
38
  updateBrightness(value) {
33
- const percents = this.covertValueToPercents(value, this.maxBrightness);
34
- this.updateCharacteristic(this.platform.Characteristic.Brightness, 'Brightness', percents);
35
- this.currentBrightness = value;
39
+ this.brightnessPercents = this.covertValueToPercents(value, this.maxBrightness);
40
+ this.updateCharacteristic(this.platform.Characteristic.Brightness, 'Brightness', this.brightnessPercents);
41
+ this.brightness = value;
36
42
  }
37
43
  setBrightness(value) {
38
44
  this.brightnessCharacteristic?.setValue(value);
@@ -1 +1 @@
1
- {"version":3,"file":"lightBulbServiceBase.js","sourceRoot":"","sources":["../../src/services/lightBulbServiceBase.ts"],"names":[],"mappings":";;;AACA,+DAA4D;AAG5D,MAAsB,oBAAqB,SAAQ,yBAAW;IAKvC;IACF;IALX,iBAAiB,GAAG,CAAC,CAAC;IACtB,wBAAwB,GAA0B,IAAI,CAAC;IAE/D,YACqB,gBAAsC,EACxC,aAAqB,EACtC,cAAsB;QAEtB,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,gBAAgB,EAAE,cAAc,CAAC,CAAC;QAJlE,qBAAgB,GAAhB,gBAAgB,CAAsB;QACxC,kBAAa,GAAb,aAAa,CAAQ;IAIxC,CAAC;IAEkB,kBAAkB;QACnC,MAAM,gBAAgB,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;QACjF,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;YAC7B,MAAM,QAAQ,GAAG,KAAgB,CAAC;YAClC,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QAChG,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE;YAC7C,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAAC;YA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AAC,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;YAC1F,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,CAAC;QAC5F,CAAC,CAAC,CACH,CAAC;QAEJ,OAAO,CAAC,gBAAgB,EAAE,IAAI,CAAC,wBAAwB,CAAC,CAAC;IAC3D,CAAC;IAEM,WAAW,CAAC,KAAc;QAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAC7E,CAAC;IAEM,gBAAgB,CAAC,KAAa;QACnC,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAChF,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,UAAU,EAAE,YAAY,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC1G,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IAC1B,CAAC;IAES,aAAa,CAAC,KAAa;QACnC,IAAI,CAAC,wBAAwB,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;CAKF;AAxDD,oDAwDC"}
@@ -2,7 +2,7 @@ import { EcoFlowAccessoryBase } from '@ecoflow/accessories/ecoFlowAccessoryBase'
2
2
  import { AdditionalBatteryCharacteristicType as CharacteristicType } from '@ecoflow/config';
3
3
  import { BatteryStatusProvider } from '@ecoflow/helpers/batteryStatusProvider';
4
4
  import { OutletBatteryServiceBase } from '@ecoflow/services/outletBatteryServiceBase';
5
- export declare class OutletInvService extends OutletBatteryServiceBase {
6
- constructor(ecoFlowAccessory: EcoFlowAccessoryBase, batteryStatusProvider: BatteryStatusProvider, additionalCharacteristics?: CharacteristicType[]);
5
+ export declare class OutletReadOnlyService extends OutletBatteryServiceBase {
6
+ constructor(ecoFlowAccessory: EcoFlowAccessoryBase, batteryStatusProvider: BatteryStatusProvider, serviceSubType: string, additionalCharacteristics?: CharacteristicType[]);
7
7
  protected processOnSetOn(): Promise<void>;
8
8
  }
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OutletService = void 0;
3
+ exports.OutletReadOnlyService = void 0;
4
4
  const outletBatteryServiceBase_1 = require("@ecoflow/services/outletBatteryServiceBase");
5
- class OutletService extends outletBatteryServiceBase_1.OutletBatteryServiceBase {
5
+ class OutletReadOnlyService extends outletBatteryServiceBase_1.OutletBatteryServiceBase {
6
6
  constructor(ecoFlowAccessory, batteryStatusProvider, serviceSubType, additionalCharacteristics) {
7
7
  super(ecoFlowAccessory, batteryStatusProvider, serviceSubType, additionalCharacteristics);
8
8
  }
@@ -10,5 +10,5 @@ class OutletService extends outletBatteryServiceBase_1.OutletBatteryServiceBase
10
10
  throw new this.platform.api.hap.HapStatusError(-70404 /* this.platform.api.hap.HAPStatus.READ_ONLY_CHARACTERISTIC */);
11
11
  }
12
12
  }
13
- exports.OutletService = OutletService;
14
- //# sourceMappingURL=outletService.js.map
13
+ exports.OutletReadOnlyService = OutletReadOnlyService;
14
+ //# sourceMappingURL=outletReadOnlyService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outletReadOnlyService.js","sourceRoot":"","sources":["../../src/services/outletReadOnlyService.ts"],"names":[],"mappings":";;;AAGA,yFAAsF;AAEtF,MAAa,qBAAsB,SAAQ,mDAAwB;IACjE,YACE,gBAAsC,EACtC,qBAA4C,EAC5C,cAAsB,EACtB,yBAAgD;QAEhD,KAAK,CAAC,gBAAgB,EAAE,qBAAqB,EAAE,cAAc,EAAE,yBAAyB,CAAC,CAAC;IAC5F,CAAC;IAEkB,cAAc;QAC/B,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,uEAA0D,CAAC;IAC3G,CAAC;CACF;AAbD,sDAaC"}
@@ -3,6 +3,7 @@ import { ServiceBase } from '@ecoflow/services/serviceBase';
3
3
  import { Characteristic, CharacteristicValue, WithUUID } from 'homebridge';
4
4
  export declare abstract class OutletServiceBase extends ServiceBase {
5
5
  private readonly additionalCharacteristics?;
6
+ private state;
6
7
  constructor(ecoFlowAccessory: EcoFlowAccessoryBase, additionalCharacteristics?: string[] | undefined, serviceSubType?: string);
7
8
  updateState(state: boolean): void;
8
9
  updateOutputConsumption(watt: number): void;
@@ -5,11 +5,13 @@ const config_1 = require("@ecoflow/config");
5
5
  const serviceBase_1 = require("@ecoflow/services/serviceBase");
6
6
  class OutletServiceBase extends serviceBase_1.ServiceBase {
7
7
  additionalCharacteristics;
8
+ state = false;
8
9
  constructor(ecoFlowAccessory, additionalCharacteristics, serviceSubType) {
9
10
  super(ecoFlowAccessory.platform.Service.Outlet, ecoFlowAccessory, serviceSubType);
10
11
  this.additionalCharacteristics = additionalCharacteristics;
11
12
  }
12
13
  updateState(state) {
14
+ this.state = state;
13
15
  this.updateCharacteristic(this.platform.Characteristic.On, 'State', state);
14
16
  }
15
17
  updateOutputConsumption(watt) {
@@ -23,11 +25,12 @@ class OutletServiceBase extends serviceBase_1.ServiceBase {
23
25
  this.updateCustomCharacteristic(this.platform.Characteristic.PowerConsumption.OutputCurrent, 'Output Current, A', () => ampere, config_1.AdditionalOutletCharacteristicType.OutputCurrent);
24
26
  }
25
27
  addCharacteristics() {
26
- const onCharacteristic = this.addCharacteristic(this.platform.Characteristic.On);
27
- onCharacteristic.onSet((value) => {
28
- const newValue = value;
29
- this.processOnSetOn(newValue, () => this.updateState(!newValue));
30
- });
28
+ const onCharacteristic = this.addCharacteristic(this.platform.Characteristic.On)
29
+ .onGet(() => this.processOnGet(this.state))
30
+ .onSet((value) => this.processOnSet(this.platform.Characteristic.On.name, () => {
31
+ this.state = value;
32
+ this.processOnSetOn(this.state, () => this.updateState(!this.state));
33
+ }));
31
34
  const characteristics = [
32
35
  this.addCharacteristic(this.platform.Characteristic.OutletInUse),
33
36
  onCharacteristic,
@@ -1 +1 @@
1
- {"version":3,"file":"outletServiceBase.js","sourceRoot":"","sources":["../../src/services/outletServiceBase.ts"],"names":[],"mappings":";;;AACA,4CAAiG;AACjG,+DAA4D;AAG5D,MAAsB,iBAAkB,SAAQ,yBAAW;IAGtC;IAFnB,YACE,gBAAsC,EACrB,yBAAoC,EACrD,cAAuB;QAEvB,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,gBAAgB,EAAE,cAAc,CAAC,CAAC;QAHjE,8BAAyB,GAAzB,yBAAyB,CAAW;IAIvD,CAAC;IAEM,WAAW,CAAC,KAAc;QAC/B,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAC7E,CAAC;IAEM,uBAAuB,CAAC,IAAY;QACzC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,WAAW,EAAE,OAAO,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC;QACvF,IAAI,CAAC,0BAA0B,CAC7B,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,gBAAgB,CAAC,sBAAsB,EACpE,uBAAuB,EACvB,GAAG,EAAE,CAAC,IAAI,EACV,2CAAwB,CAAC,wBAAwB,CAClD,CAAC;IACJ,CAAC;IAEM,mBAAmB,CAAC,IAAY;QACrC,IAAI,CAAC,0BAA0B,CAC7B,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,gBAAgB,CAAC,aAAa,EAC3D,mBAAmB,EACnB,GAAG,EAAE,CAAC,IAAI,EACV,2CAAwB,CAAC,aAAa,CACvC,CAAC;IACJ,CAAC;IAEM,mBAAmB,CAAC,MA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GC"}
@@ -9,12 +9,14 @@ export declare abstract class ServiceBase {
9
9
  protected readonly platform: EcoFlowHomebridgePlatform;
10
10
  protected characteristics: Characteristic[];
11
11
  private _service;
12
+ private isReachable;
12
13
  private enabled;
13
14
  constructor(serviceType: WithUUID<typeof Service>, ecoFlowAccessory: EcoFlowAccessoryBase, serviceSubType?: string | undefined);
14
15
  initialize(): void;
15
16
  cleanupCharacteristics(): void;
16
17
  get service(): Service;
17
18
  updateEnabled(enabled: boolean): void;
19
+ updateReachability(value: boolean): void;
18
20
  protected get serviceName(): string;
19
21
  protected createService(): Service;
20
22
  protected abstract addCharacteristics(): Characteristic[];
@@ -29,5 +31,8 @@ export declare abstract class ServiceBase {
29
31
  protected covertPercentsToValue(percents: number, maxValue: number): number;
30
32
  protected covertValueToPercents(value: number, maxValue: number): number;
31
33
  protected onDisabled(): void;
32
- protected addCharacteristicSet(characteristic: Characteristic, name: string, process: (value: CharacteristicValue) => void): void;
34
+ protected processOnGet<TValue>(value: TValue): TValue;
35
+ protected processOnSet(name: string, func: () => void): void;
36
+ private checkIsReachable;
37
+ private checkIsEnabled;
33
38
  }
@@ -9,6 +9,7 @@ class ServiceBase {
9
9
  platform;
10
10
  characteristics = [];
11
11
  _service = null;
12
+ isReachable = true;
12
13
  enabled = true;
13
14
  constructor(serviceType, ecoFlowAccessory, serviceSubType) {
14
15
  this.serviceType = serviceType;
@@ -44,6 +45,9 @@ class ServiceBase {
44
45
  this.onDisabled();
45
46
  }
46
47
  }
48
+ updateReachability(value) {
49
+ this.isReachable = value;
50
+ }
47
51
  get serviceName() {
48
52
  return this.ecoFlowAccessory.config.name + (this.serviceSubType ? ` ${this.serviceSubType}` : '');
49
53
  }
@@ -78,16 +82,25 @@ class ServiceBase {
78
82
  return (value * 100) / maxValue;
79
83
  }
80
84
  onDisabled() { }
81
- addCharacteristicSet(characteristic, name, process) {
82
- characteristic.onSet((value) => {
83
- if (!this.enabled) {
84
- this.log.warn(`[${this.serviceName}] Service is disabled. Setting of "${name}" is disallowed`);
85
- throw new this.platform.api.hap.HapStatusError(-70404 /* this.platform.api.hap.HAPStatus.READ_ONLY_CHARACTERISTIC */);
86
- }
87
- else {
88
- process(value);
89
- }
90
- });
85
+ processOnGet(value) {
86
+ this.checkIsReachable();
87
+ return value;
88
+ }
89
+ processOnSet(name, func) {
90
+ this.checkIsReachable();
91
+ this.checkIsEnabled(name);
92
+ func();
93
+ }
94
+ checkIsReachable() {
95
+ if (!this.isReachable) {
96
+ throw new this.platform.api.hap.HapStatusError(-70402 /* this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
97
+ }
98
+ }
99
+ checkIsEnabled(name) {
100
+ if (!this.enabled) {
101
+ this.log.warn(`[${this.serviceName}] Service is disabled. Setting of "${name}" is disallowed`);
102
+ throw new this.platform.api.hap.HapStatusError(-70404 /* this.platform.api.hap.HAPStatus.READ_ONLY_CHARACTERISTIC */);
103
+ }
91
104
  }
92
105
  }
93
106
  exports.ServiceBase = ServiceBase;
@@ -1 +1 @@
1
- {"version":3,"file":"serviceBase.js","sourceRoot":"","sources":["../../src/services/serviceBase.ts"],"names":[],"mappings":";;;AAIA,MAAsB,WAAW;IAQZ;IACE;IACA;IATF,GAAG,CAAU;IACb,QAAQ,CAA4B;IAC7C,eAAe,GAAqB,EAAE,CAAC;IACzC,QAAQ,GAAmB,IAAI,CAAC;IAChC,OAAO,GAAY,IAAI,CAAC;IAEhC,YACmB,WAAqC,EACnC,gBAAsC,EACtC,cAAuB;QAFzB,gBAAW,GAAX,WAAW,CAA0B;QACnC,qBAAgB,GAAhB,gBAAgB,CAAsB;QACtC,mBAAc,GAAd,cAAc,CAAS;QAE1C,IAAI,CAAC,GAAG,GAAG,gBAAgB,CAAC,GAAG,CAAC;QAChC,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,CAAC;IAC5C,CAAC;IAEM,UAAU;QACf,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;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AAC;IAEO,gBAAgB;QACtB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,4EAA+D,CAAC;QAChH,CAAC;IACH,CAAC;IAEO,cAAc,CAAC,IAAY;QACjC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,WAAW,sCAAsC,IAAI,iBAAiB,CAAC,CAAC;YAC/F,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,uEAA0D,CAAC;QAC3G,CAAC;IACH,CAAC;CACF;AApID,kCAoIC"}
@@ -2,6 +2,7 @@ import { EcoFlowAccessoryBase } from '@ecoflow/accessories/ecoFlowAccessoryBase'
2
2
  import { ServiceBase } from '@ecoflow/services/serviceBase';
3
3
  import { Characteristic } from 'homebridge';
4
4
  export declare abstract class SwitchServiceBase extends ServiceBase {
5
+ private state;
5
6
  constructor(ecoFlowAccessory: EcoFlowAccessoryBase, serviceSubType: string);
6
7
  updateState(state: boolean): void;
7
8
  protected onDisabled(): void;
@@ -3,21 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SwitchServiceBase = void 0;
4
4
  const serviceBase_1 = require("@ecoflow/services/serviceBase");
5
5
  class SwitchServiceBase extends serviceBase_1.ServiceBase {
6
+ state = false;
6
7
  constructor(ecoFlowAccessory, serviceSubType) {
7
8
  super(ecoFlowAccessory.platform.Service.Switch, ecoFlowAccessory, serviceSubType);
8
9
  }
9
10
  updateState(state) {
11
+ this.state = state;
10
12
  this.updateCharacteristic(this.platform.Characteristic.On, 'State', state);
11
13
  }
12
14
  onDisabled() {
13
15
  this.updateState(false);
14
16
  }
15
17
  addCharacteristics() {
16
- const onCharacteristic = this.addCharacteristic(this.platform.Characteristic.On);
17
- this.addCharacteristicSet(onCharacteristic, 'On', (value) => {
18
- const newValue = value;
19
- this.processOnSetOn(newValue, () => this.updateState(!newValue));
20
- });
18
+ const onCharacteristic = this.addCharacteristic(this.platform.Characteristic.On)
19
+ .onGet(() => this.processOnGet(this.state))
20
+ .onSet((value) => this.processOnSet(this.platform.Characteristic.On.name, () => {
21
+ this.state = value;
22
+ this.processOnSetOn(this.state, () => this.updateState(!this.state));
23
+ }));
21
24
  this.service.setCharacteristic(this.platform.Characteristic.Name, this.serviceName);
22
25
  return [onCharacteristic];
23
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"switchServiceBase.js","sourceRoot":"","sources":["../../src/services/switchServiceBase.ts"],"names":[],"mappings":";;;AACA,+DAA4D;AAG5D,MAAsB,iBAAkB,SAAQ,yBAAW;IACzD,YAAY,gBAAsC,EAAE,cAAsB;QACxE,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,gBAAgB,EAAE,cAAc,CAAC,CAAC;IACpF,CAAC;IAEM,WAAW,CAAC,KAAc;QAC/B,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAC7E,CAAC;IAEkB,UAAU;QAC3B,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAEkB,kBAAkB;QACnC,MAAM,gBAAgB,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;QACjF,IAAI,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,IAAI,EAAE,CAAC,KAA0B,EAAE,EAAE;YAC/E,MAAM,QAAQ,GAAG,KAAgB,CAAC;YAClC,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;QACnE,CAAC,CAA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C,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QACvE,CAAC,CAAC,CACH,CAAC;QAEJ,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAEpF,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC5B,CAAC;CAGF;AAhCD,8CAgCC"}
@@ -3,7 +3,7 @@ import { ServiceBase } from '@ecoflow/services/serviceBase';
3
3
  import { Characteristic } from 'homebridge';
4
4
  export declare class TemperatureSensorService extends ServiceBase {
5
5
  protected readonly ecoFlowAccessory: EcoFlowAccessoryBase;
6
- private temperatureCharacteristic;
6
+ private currentTemperature;
7
7
  constructor(ecoFlowAccessory: EcoFlowAccessoryBase, serviceSubType?: string);
8
8
  protected addCharacteristics(): Characteristic[];
9
9
  updateCurrentTemperature(value: number): void;
@@ -4,16 +4,17 @@ exports.TemperatureSensorService = void 0;
4
4
  const serviceBase_1 = require("@ecoflow/services/serviceBase");
5
5
  class TemperatureSensorService extends serviceBase_1.ServiceBase {
6
6
  ecoFlowAccessory;
7
- temperatureCharacteristic = null;
7
+ currentTemperature = 0;
8
8
  constructor(ecoFlowAccessory, serviceSubType) {
9
9
  super(ecoFlowAccessory.platform.Service.TemperatureSensor, ecoFlowAccessory, serviceSubType);
10
10
  this.ecoFlowAccessory = ecoFlowAccessory;
11
11
  }
12
12
  addCharacteristics() {
13
- this.temperatureCharacteristic = this.addCharacteristic(this.platform.Characteristic.CurrentTemperature);
14
- return [this.temperatureCharacteristic];
13
+ const temperatureCharacteristic = this.addCharacteristic(this.platform.Characteristic.CurrentTemperature).onGet(() => this.processOnGet(this.currentTemperature));
14
+ return [temperatureCharacteristic];
15
15
  }
16
16
  updateCurrentTemperature(value) {
17
+ this.currentTemperature = value;
17
18
  this.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, 'Current Temperature', value);
18
19
  }
19
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"temperatureSensorService.js","sourceRoot":"","sources":["../../src/services/temperatureSensorService.ts"],"names":[],"mappings":";;;AACA,+DAA4D;AAG5D,MAAa,wBAAyB,SAAQ,yBAAW;IAIlC;IAHb,yBAAyB,GAA0B,IAAI,CAAC;IAEhE,YACqB,gBAAsC,EACzD,cAAuB;QAEvB,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,iBAAiB,EAAE,gBAAgB,EAAE,cAAc,CAAC,CAAC;QAH1E,qBAAgB,GAAhB,gBAAgB,CAAsB;IAI3D,CAAC;IAEkB,kBAAkB;QACnC,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC;QACzG,OAAO,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IAC1C,CAAC;IAEM,wBAAwB,CAAC,KAAa;QAC3C,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,kBAAkB,EAAE,qBAAqB,EAAE,KAAK,CAAC,CAAC;IAC3G,CAAC;CACF;AAlBD,4DAkBC"}
1
+ {"version":3,"file":"temperatureSensorService.js","sourceRoot":"","sources":["../../src/services/temperatureSensorService.ts"],"names":[],"mappings":";;;AACA,+DAA4D;AAG5D,MAAa,wBAAyB,SAAQ,yBAAW;IAIlC;IAHb,kBAAkB,GAAW,CAAC,CAAC;IAEvC,YACqB,gBAAsC,EACzD,cAAuB;QAEvB,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,iBAAiB,EAAE,gBAAgB,EAAE,cAAc,CAAC,CAAC;QAH1E,qBAAgB,GAAhB,gBAAgB,CAAsB;IAI3D,CAAC;IAEkB,kBAAkB;QACnC,MAAM,yBAAyB,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC,KAAK,CAC7G,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,kBAAkB,CAAC,CACjD,CAAC;QACF,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACrC,CAAC;IAEM,wBAAwB,CAAC,KAAa;QAC3C,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;QAChC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,kBAAkB,EAAE,qBAAqB,EAAE,KAAK,CAAC,CAAC;IAC3G,CAAC;CACF;AArBD,4DAqBC"}
@@ -5,9 +5,12 @@ import { Characteristic } from 'homebridge';
5
5
  export declare abstract class ThermostatFridgeServiceBase extends ServiceBase {
6
6
  private readonly minTemperature;
7
7
  private readonly maxTemperature;
8
- private currentTargetTemperature;
9
- private currentTargetFridgeState;
10
- private currentTemperatureDisplayUnits;
8
+ private currentTemperature;
9
+ private targetTemperature;
10
+ private currentHeatingCoolingStateType;
11
+ private targetHeatingCoolingStateType;
12
+ private targetFridgeState;
13
+ private temperatureDisplayUnits;
11
14
  constructor(ecoFlowAccessory: EcoFlowAccessoryBase, minTemperature: number, maxTemperature: number, serviceSubType: string);
12
15
  updateCurrentTemperature(value: number): void;
13
16
  updateTargetTemperature(value: number): void;
@@ -6,27 +6,37 @@ const serviceBase_1 = require("@ecoflow/services/serviceBase");
6
6
  class ThermostatFridgeServiceBase extends serviceBase_1.ServiceBase {
7
7
  minTemperature;
8
8
  maxTemperature;
9
- currentTargetTemperature = 0;
10
- currentTargetFridgeState = characteristicContracts_1.FridgeStateType.Off;
11
- currentTemperatureDisplayUnits = 0;
9
+ currentTemperature = 0;
10
+ targetTemperature = 0;
11
+ currentHeatingCoolingStateType = characteristicContracts_1.CurrentHeatingCoolingStateType.Off;
12
+ targetHeatingCoolingStateType = characteristicContracts_1.TargetHeatingCoolingStateType.Off;
13
+ targetFridgeState = characteristicContracts_1.FridgeStateType.Off;
14
+ temperatureDisplayUnits = 0;
12
15
  constructor(ecoFlowAccessory, minTemperature, maxTemperature, serviceSubType) {
13
16
  super(ecoFlowAccessory.platform.Service.Thermostat, ecoFlowAccessory, serviceSubType);
14
17
  this.minTemperature = minTemperature;
15
18
  this.maxTemperature = maxTemperature;
16
19
  }
17
20
  updateCurrentTemperature(value) {
21
+ this.currentTemperature = value;
18
22
  this.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, 'Current Temperature', value);
19
23
  }
20
24
  updateTargetTemperature(value) {
25
+ this.targetTemperature = value;
21
26
  this.updateCharacteristic(this.platform.Characteristic.TargetTemperature, 'Target Temperature', value);
22
27
  }
23
28
  updateCurrentState(value) {
24
- this.updateCharacteristic(this.platform.Characteristic.CurrentHeatingCoolingState, 'Current State', value === characteristicContracts_1.FridgeStateType.On ? characteristicContracts_1.CurrentHeatingCoolingStateType.Cool : characteristicContracts_1.CurrentHeatingCoolingStateType.Off);
29
+ this.currentHeatingCoolingStateType =
30
+ value === characteristicContracts_1.FridgeStateType.On ? characteristicContracts_1.CurrentHeatingCoolingStateType.Cool : characteristicContracts_1.CurrentHeatingCoolingStateType.Off;
31
+ this.updateCharacteristic(this.platform.Characteristic.CurrentHeatingCoolingState, 'Current State', this.currentHeatingCoolingStateType);
25
32
  }
26
33
  updateTargetState(value) {
27
- this.updateCharacteristic(this.platform.Characteristic.TargetHeatingCoolingState, 'Target State', value === characteristicContracts_1.FridgeStateType.On ? characteristicContracts_1.TargetHeatingCoolingStateType.Cool : characteristicContracts_1.TargetHeatingCoolingStateType.Off);
34
+ this.targetHeatingCoolingStateType =
35
+ value === characteristicContracts_1.FridgeStateType.On ? characteristicContracts_1.TargetHeatingCoolingStateType.Cool : characteristicContracts_1.TargetHeatingCoolingStateType.Off;
36
+ this.updateCharacteristic(this.platform.Characteristic.TargetHeatingCoolingState, 'Target State', this.targetHeatingCoolingStateType);
28
37
  }
29
38
  updateTemperatureDisplayUnits(value) {
39
+ this.temperatureDisplayUnits = value;
30
40
  this.updateCharacteristic(this.platform.Characteristic.TemperatureDisplayUnits, 'Temperature Display Units', value);
31
41
  }
32
42
  addCharacteristics() {
@@ -41,53 +51,63 @@ class ThermostatFridgeServiceBase extends serviceBase_1.ServiceBase {
41
51
  return characteristics;
42
52
  }
43
53
  addCurrentTemperatureCharacteristic() {
44
- const characteristic = this.addCharacteristic(this.platform.Characteristic.CurrentTemperature).setProps({
54
+ const characteristic = this.addCharacteristic(this.platform.Characteristic.CurrentTemperature)
55
+ .setProps({
45
56
  minValue: this.minTemperature,
46
57
  maxValue: this.maxTemperature,
47
58
  minStep: 0.1,
48
- });
59
+ })
60
+ .onGet(() => this.processOnGet(this.currentTemperature));
49
61
  return characteristic;
50
62
  }
51
63
  addTargetTemperatureCharacteristic() {
52
- const characteristic = this.addCharacteristic(this.platform.Characteristic.TargetTemperature).setProps({
64
+ const characteristic = this.addCharacteristic(this.platform.Characteristic.TargetTemperature)
65
+ .setProps({
53
66
  minValue: this.minTemperature,
54
67
  maxValue: this.maxTemperature,
55
68
  minStep: 0.1,
56
- });
57
- this.addCharacteristicSet(characteristic, 'TargetTemperature', (value) => {
58
- const prevTargetTemperature = this.currentTargetTemperature;
59
- this.currentTargetTemperature = value;
60
- this.processOnSetTargetTemperature(this.currentTargetTemperature, () => this.updateTargetTemperature(prevTargetTemperature));
61
- });
69
+ })
70
+ .onGet(() => this.processOnGet(this.targetTemperature))
71
+ .onSet((value) => this.processOnSet(this.platform.Characteristic.TargetTemperature.name, () => {
72
+ const prevTargetTemperature = this.targetTemperature;
73
+ this.targetTemperature = value;
74
+ this.processOnSetTargetTemperature(this.targetTemperature, () => this.updateTargetTemperature(prevTargetTemperature));
75
+ }));
62
76
  return characteristic;
63
77
  }
64
78
  addCurrentHeatingCoolingStateCharacteristic() {
65
- const characteristic = this.addCharacteristic(this.platform.Characteristic.CurrentHeatingCoolingState).setProps({
79
+ const characteristic = this.addCharacteristic(this.platform.Characteristic.CurrentHeatingCoolingState)
80
+ .setProps({
66
81
  validValues: [characteristicContracts_1.TargetHeatingCoolingStateType.Off, characteristicContracts_1.TargetHeatingCoolingStateType.Cool],
67
- });
82
+ })
83
+ .onGet(() => this.processOnGet(this.currentHeatingCoolingStateType));
68
84
  return characteristic;
69
85
  }
70
86
  addTargetHeatingCoolingStateCharacteristic() {
71
- const characteristic = this.addCharacteristic(this.platform.Characteristic.TargetHeatingCoolingState).setProps({
87
+ const characteristic = this.addCharacteristic(this.platform.Characteristic.TargetHeatingCoolingState)
88
+ .setProps({
72
89
  validValues: [characteristicContracts_1.TargetHeatingCoolingStateType.Off, characteristicContracts_1.TargetHeatingCoolingStateType.Cool],
73
- });
74
- this.addCharacteristicSet(characteristic, 'TargetHeatingCoolingState', (value) => {
75
- const prevTargetFridgeState = this.currentTargetFridgeState;
76
- this.currentTargetFridgeState =
77
- value === characteristicContracts_1.TargetHeatingCoolingStateType.Cool
90
+ })
91
+ .onGet(() => this.processOnGet(this.targetHeatingCoolingStateType))
92
+ .onSet((value) => this.processOnSet(this.platform.Characteristic.TargetHeatingCoolingState.name, () => {
93
+ this.targetHeatingCoolingStateType = value;
94
+ const prevTargetFridgeState = this.targetFridgeState;
95
+ this.targetFridgeState =
96
+ this.targetHeatingCoolingStateType === characteristicContracts_1.TargetHeatingCoolingStateType.Cool
78
97
  ? characteristicContracts_1.FridgeStateType.On
79
98
  : characteristicContracts_1.FridgeStateType.Off;
80
- this.processOnSetTargetState(this.currentTargetFridgeState, () => this.updateTargetState(prevTargetFridgeState));
81
- });
99
+ this.processOnSetTargetState(this.targetFridgeState, () => this.updateTargetState(prevTargetFridgeState));
100
+ }));
82
101
  return characteristic;
83
102
  }
84
103
  addTemperatureDisplayUnitsCharacteristic() {
85
- const characteristic = this.addCharacteristic(this.platform.Characteristic.TemperatureDisplayUnits);
86
- this.addCharacteristicSet(characteristic, 'TemperatureDisplayUnits', (value) => {
87
- const prevTemperatureDisplayUnits = this.currentTemperatureDisplayUnits;
88
- this.currentTemperatureDisplayUnits = value;
89
- this.processOnSetTemperatureDisplayUnits(this.currentTemperatureDisplayUnits, () => this.updateTemperatureDisplayUnits(prevTemperatureDisplayUnits));
90
- });
104
+ const characteristic = this.addCharacteristic(this.platform.Characteristic.TemperatureDisplayUnits)
105
+ .onGet(() => this.processOnGet(this.temperatureDisplayUnits))
106
+ .onSet((value) => this.processOnSet(this.platform.Characteristic.TemperatureDisplayUnits.name, () => {
107
+ const prevTemperatureDisplayUnits = this.temperatureDisplayUnits;
108
+ this.temperatureDisplayUnits = value;
109
+ this.processOnSetTemperatureDisplayUnits(this.temperatureDisplayUnits, () => this.updateTemperatureDisplayUnits(prevTemperatureDisplayUnits));
110
+ }));
91
111
  return characteristic;
92
112
  }
93
113
  }