homebridge-solaxcloud-api 2.0.3 → 2.1.2

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.
@@ -18,14 +18,14 @@ const MOTION_TIMEOUT = 5;
18
18
  class SolaxMotionAccessory extends platformAccessory_1.SolaxPlatformAccessory {
19
19
  /**
20
20
  * Solax virtual motion sensor class constructor.
21
- * @param {SolaxCloudApiPlatform} platform The API Platform for Solax Cloud.
22
21
  * @param {Logging} log The platform logging for homebridge.
22
+ * @param {API} api The API for Solax Cloud platform.
23
23
  * @param {string} name The accessory name.
24
24
  * @param {string} serial "Real-world" serial number for this accessory.
25
25
  * @param {string} model Accessory model.
26
26
  */
27
- constructor(platform, log, name, serial, model) {
28
- super(platform, log, name, serial, model);
27
+ constructor(log, api, name, serial, model) {
28
+ super(log, api, name, serial, model);
29
29
  /**
30
30
  * Whether motion is detected (Solax Cloud data updated).
31
31
  */
@@ -35,11 +35,10 @@ class SolaxMotionAccessory extends platformAccessory_1.SolaxPlatformAccessory {
35
35
  */
36
36
  this.motionTimeout = MOTION_TIMEOUT;
37
37
  this.sleep = util_1.default.promisify(setTimeout);
38
- const hap = this.platform.api.hap;
39
38
  this.log.debug(`Creating motion sensor "${this.name}"`);
40
- this.motionService = new hap.Service.MotionSensor(this.name);
39
+ this.motionService = new this.api.hap.Service.MotionSensor(this.name);
41
40
  this.motionService
42
- .getCharacteristic(hap.Characteristic.MotionDetected)
41
+ .getCharacteristic(this.api.hap.Characteristic.MotionDetected)
43
42
  .on("get" /* GET */, this.getState.bind(this));
44
43
  log.info(`Motion sensor "${name}" created!`);
45
44
  }
@@ -58,7 +57,7 @@ class SolaxMotionAccessory extends platformAccessory_1.SolaxPlatformAccessory {
58
57
  setState(motion) {
59
58
  this.log.debug(`${this.name}: SET State (motion=${motion})`);
60
59
  this.motionService
61
- .getCharacteristic(this.platform.api.hap.Characteristic.MotionDetected)
60
+ .getCharacteristic(this.api.hap.Characteristic.MotionDetected)
62
61
  .updateValue(motion);
63
62
  this.motion = motion;
64
63
  if (this.motion) {
@@ -1 +1 @@
1
- {"version":3,"file":"motionAccessory.js","sourceRoot":"","sources":["../src/motionAccessory.ts"],"names":[],"mappings":";;;;;;AAEA,gDAAwB;AAGxB,2DAA6D;AAE7D;;GAEG;AACH,MAAM,cAAc,GAAG,CAAC,CAAC;AAEzB;;;;GAIG;AACH,MAAa,oBAAqB,SAAQ,0CAAsB;IAiB9D;;;;;;;OAOG;IACH,YAAY,QAA+B,EAAE,GAAY,EAAE,IAAY,EAAE,MAAc,EAAE,KAAa;QACpG,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QAnB5C;;WAEG;QACK,WAAM,GAAG,KAAK,CAAC;QAEvB;;WAEG;QACK,kBAAa,GAAW,cAAc,CAAC;QAyB/C,UAAK,GAAG,cAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QAZjC,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC;QAElC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,2BAA2B,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QAExD,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7D,IAAI,CAAC,aAAa;aACf,iBAAiB,CAAC,GAAG,CAAC,cAAc,CAAC,cAAc,CAAC;aACpD,EAAE,kBAAmC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAElE,GAAG,CAAC,IAAI,CAAC,kBAAkB,IAAI,YAAY,CAAC,CAAC;IAC/C,CAAC;IAID;;;OAGG;IACI,QAAQ,CAAC,QAAmC;QACjD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,uBAAuB,IAAI,CAAC,M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AC;QAEvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,4BAA4B;YAC5B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;SACxE;IACH,CAAC;IAED;;;OAGG;IACH,gBAAgB,CAAC,OAAe;QAC9B,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACH,gBAAgB;QACd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,OAAO;YACL,IAAI,CAAC,kBAAkB;YACvB,IAAI,CAAC,aAAa;SACnB,CAAC;IACJ,CAAC;CAEF;AAhGD,oDAgGC"}
@@ -1,5 +1,4 @@
1
- import { Service, AccessoryPlugin, Logging, CharacteristicGetCallback } from 'homebridge';
2
- import { SolaxCloudAPIPlatform } from './platform';
1
+ import { Service, AccessoryPlugin, Logging, CharacteristicGetCallback, API } from 'homebridge';
3
2
  import { SolaxPlatformAccessory } from './platformAccessory';
4
3
  /**
5
4
  * Solax Outlet Accessory.
@@ -7,6 +6,14 @@ import { SolaxPlatformAccessory } from './platformAccessory';
7
6
  * Outlet use is inferred from a positive power comsumption.
8
7
  */
9
8
  export declare class SolaxOutletAccessory extends SolaxPlatformAccessory implements AccessoryPlugin {
9
+ /**
10
+ * Eve Homekit types helper
11
+ * */
12
+ private readonly eve;
13
+ /**
14
+ * Eve Service for fakegato.
15
+ */
16
+ private readonly eveService;
10
17
  /**
11
18
  * Outlet service with power meter.
12
19
  */
@@ -33,13 +40,13 @@ export declare class SolaxOutletAccessory extends SolaxPlatformAccessory impleme
33
40
  private lastEMA;
34
41
  /**
35
42
  * Solax virtual outlet class constructor.
36
- * @param {SolaxCloudApiPlatform} platform The API Platform for Solax Cloud.
37
43
  * @param {Logging} log The platform logging for homebridge.
44
+ * @param {API} api The API for Solax Cloud platform.
38
45
  * @param {string} name The accessory name.
39
46
  * @param {string} serial "Real world" serial number for this accessory.
40
47
  * @param {string} model Accessory model.
41
48
  */
42
- constructor(platform: SolaxCloudAPIPlatform, log: Logging, name: string, serial: string, model: string);
49
+ constructor(log: Logging, api: API, name: string, serial: string, model: string);
43
50
  /**
44
51
  * Adds new power entry to series array of power values.
45
52
  * @param {number} powerConsumption Power value to add (in Watts).
@@ -1 +1 @@
1
- {"version":3,"file":"outletAccessory.d.ts","sourceRoot":"","sources":["../src/outletAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAE1F,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAW7D;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,sBAAuB,YAAW,eAAe;IAEzF;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAU;IAExC;;OAEG;IACH,OAAO,CAAC,gBAAgB,CAAK;IAE7B;;OAEG;IACH,OAAO,CAAC,sBAAsB,CAAO;IAErC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAyB;IAExD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAgB;IAE5C;;OAEG;IACH,OAAO,CAAC,OAAO,CAAK;IAEpB;;;;;;;OAOG;gBACS,QAAQ,EAAE,qBAAqB,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IA8BtG;;;OAGG;IACH,OAAO,CAAC,aAAa;IAWrB;;;OAGG;IACI,cAAc,IAAI,MAAM,EAAE;IAIjC;;;;;OAKG;IACI,yBAAyB,CAAC,M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AE,MAAM,EAAE,KAAK,EAAE,MAAM;IAiC/E;;;OAGG;IACH,OAAO,CAAC,aAAa;IAWrB;;;OAGG;IACI,cAAc,IAAI,MAAM,EAAE;IAIjC;;;;;OAKG;IACI,yBAAyB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;IAwC5E;;OAEG;IACI,mBAAmB,CAAC,QAAQ,EAAE,yBAAyB,GAAG,IAAI;IAMrE;;wEAEoE;IAC7D,mBAAmB,CAAC,gBAAgB,EAAE,MAAM;IAcnD;;OAEG;IACI,yBAAyB,CAAC,QAAQ,EAAE,yBAAyB,GAAG,IAAI;IAM3E;;;OAGG;IACI,yBAAyB,CAAC,sBAAsB,EAAE,MAAM;IAQ/D;;;OAGG;IACI,QAAQ,CAAC,QAAQ,EAAE,yBAAyB,GAAG,IAAI;IAU1D,WAAW,IAAI,OAAO,EAAE;CAIzB"}
@@ -1,8 +1,13 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.SolaxOutletAccessory = void 0;
4
7
  const platformAccessory_1 = require("./platformAccessory");
5
8
  const statistics_1 = require("./statistics");
9
+ const homebridge_lib_1 = require("homebridge-lib");
10
+ const fakegato_history_1 = __importDefault(require("fakegato-history"));
6
11
  /**
7
12
  * Maximum size for the outlet power series.
8
13
  */
@@ -15,14 +20,14 @@ const MAX_POWER_SERIES_SIZE = 1024;
15
20
  class SolaxOutletAccessory extends platformAccessory_1.SolaxPlatformAccessory {
16
21
  /**
17
22
  * Solax virtual outlet class constructor.
18
- * @param {SolaxCloudApiPlatform} platform The API Platform for Solax Cloud.
19
23
  * @param {Logging} log The platform logging for homebridge.
24
+ * @param {API} api The API for Solax Cloud platform.
20
25
  * @param {string} name The accessory name.
21
26
  * @param {string} serial "Real world" serial number for this accessory.
22
27
  * @param {string} model Accessory model.
23
28
  */
24
- constructor(platform, log, name, serial, model) {
25
- super(platform, log, name, serial, model);
29
+ constructor(log, api, name, serial, model) {
30
+ super(log, api, name, serial, model);
26
31
  /**
27
32
  * Current power reading in Watt.
28
33
  */
@@ -39,22 +44,25 @@ class SolaxOutletAccessory extends platformAccessory_1.SolaxPlatformAccessory {
39
44
  * Last Exponential Moving Average.
40
45
  */
41
46
  this.lastEMA = 0;
42
- const hap = this.platform.api.hap;
43
47
  this.log.debug(`Creating outlet "${this.name}"`);
48
+ // init fakegato objects
49
+ this.eve = new homebridge_lib_1.EveHomeKitTypes(this.api);
50
+ this.eveService = (0, fakegato_history_1.default)(this.api);
44
51
  // create power meter service
45
- this.outletService = new this.platform.eve.Services.Outlet(this.name);
52
+ this.outletService = new this.eve.Services.Outlet(this.name);
46
53
  // outlet on/off state
47
- this.outletService.getCharacteristic(hap.Characteristic.On).on("get" /* GET */, this.getState.bind(this));
54
+ this.outletService.getCharacteristic(this.api.hap.Characteristic.On)
55
+ .on("get" /* GET */, this.getState.bind(this));
48
56
  // in use
49
57
  //this.outletService.getCharacteristic(hap.Characteristic.OutletInUse).on(hap.CharacteristicEventTypes.GET, this.getState.bind(this));
50
58
  // current consumption
51
- this.outletService.getCharacteristic(this.platform.eve.Characteristics.CurrentConsumption)
59
+ this.outletService.getCharacteristic(this.eve.Characteristics.CurrentConsumption)
52
60
  .on("get" /* GET */, this.getPowerConsumption.bind(this));
53
61
  // total consumption
54
- this.outletService.getCharacteristic(this.platform.eve.Characteristics.TotalConsumption)
62
+ this.outletService.getCharacteristic(this.eve.Characteristics.TotalConsumption)
55
63
  .on("get" /* GET */, this.getTotalEnergyConsumption.bind(this));
56
64
  // history logging services
57
- this.loggingService = new this.platform.eveService('energy', this, { storage: 'fs', log: this.log, disableRepeatLastData: true });
65
+ this.loggingService = new this.eveService('energy', this, { storage: 'fs', log: this.log, disableRepeatLastData: true });
58
66
  log.info(`Outlet "${name}" created!`);
59
67
  }
60
68
  /**
@@ -124,7 +132,7 @@ class SolaxOutletAccessory extends platformAccessory_1.SolaxPlatformAccessory {
124
132
  setPowerConsumption(powerConsumption) {
125
133
  this.log.debug(`${this.name}: SET Power (power=${powerConsumption}W)`);
126
134
  this.powerConsumption = powerConsumption >= 0 ? powerConsumption : 0;
127
- this.outletService.getCharacteristic(this.platform.eve.Characteristics.CurrentConsumption).updateValue(this.powerConsumption);
135
+ this.outletService.getCharacteristic(this.eve.Characteristics.CurrentConsumption).updateValue(this.powerConsumption);
128
136
  // add entries to history
129
137
  this.loggingService.addEntry({ time: Math.round(new Date().valueOf() / 1000), power: this.powerConsumption });
130
138
  // add new value to power series
@@ -144,7 +152,7 @@ class SolaxOutletAccessory extends platformAccessory_1.SolaxPlatformAccessory {
144
152
  setTotalEnergyConsumption(totalEnergyConsumption) {
145
153
  this.log.debug(`${this.name}: SET Total Energy (energy=${totalEnergyConsumption}kWh)`);
146
154
  this.totalEnergyConsumption = totalEnergyConsumption;
147
- this.outletService.getCharacteristic(this.platform.eve.Characteristics.TotalConsumption).updateValue(this.totalEnergyConsumption);
155
+ this.outletService.getCharacteristic(this.eve.Characteristics.TotalConsumption).updateValue(this.totalEnergyConsumption);
148
156
  }
149
157
  /**
150
158
  * Gets the outlet state Characteristic based on its consumed power.
@@ -1 +1 @@
1
- {"version":3,"file":"outletAccessory.js","sourceRoot":"","sources":["../src/outletAccessory.ts"],"names":[],"mappings":";;;AAGA,2DAA6D;AAE7D,6CAA0C;AAI1C;;GAEG;AACH,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAEnC;;;;GAIG;AACH,MAAa,oBAAqB,SAAQ,0CAAsB;IAgC9D;;;;;;;OAOG;IACH,YAAY,QAA+B,EAAE,GAAY,EAAE,IAAY,EAAE,MAAc,EAAE,KAAa;QACpG,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QAlC5C;;WAEG;QACK,qBAAgB,GAAG,CAAC,CAAC;QAE7B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,sBAA8B;QAC7D,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,8BAA8B,sBAAsB,MAAM,CAAC,CAAC;QAEvF,IAAI,CAAC,sBAAsB,GAAG,sBAAsB,CAAC;QAErD,IAAI,CAAC,aAAa,CAAC,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IAC3H,CAAC;IAED;;;OAGG;IACI,QAAQ,CAAC,QAAmC;QACjD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,sBAAsB,IAAI,CAAC,gBAAgB,IAAI,CAAC,CAAC;QAE5E,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,OAAO,CAAE,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,cAAc,CAAE,CAAC;IAC9E,CAAC;CAEF;AAzND,oDAyNC"}
@@ -1,7 +1,5 @@
1
1
  /// <reference types="node" />
2
2
  import { AccessoryPlugin, API, StaticPlatformPlugin, Logging, PlatformConfig } from 'homebridge';
3
- import { EveHomeKitTypes } from 'homebridge-lib';
4
- import fakegato from 'fakegato-history';
5
3
  /**
6
4
  * SolaxCloudAPIPlatform.
7
5
  * This class is the main constructor for your plugin, this is where you should
@@ -10,40 +8,15 @@ import fakegato from 'fakegato-history';
10
8
  export declare class SolaxCloudAPIPlatform implements StaticPlatformPlugin {
11
9
  private readonly log;
12
10
  private readonly config;
13
- readonly api: API;
14
- readonly eve: EveHomeKitTypes;
15
- eveService: fakegato;
16
- private readonly solaxCloudAPI;
11
+ private readonly api;
17
12
  /**
18
- * Numeber of periods to use for data smoothing.
13
+ * Number of periods to use for data smoothing.
19
14
  */
20
15
  private smoothingWindow;
21
16
  /**
22
- * Outlets with raw data gather.
17
+ * Array of inverters.
23
18
  */
24
- private rawOutlets;
25
- /**
26
- * Smooth data outlets.
27
- * These outlets present smoothed values based on the raw data figures to
28
- * prevent events like the temporary passage of a cloud to directly affect values.
29
- */
30
- private smoothOutlets;
31
- /**
32
- * Virtual motion sensor triggered by data updates from Solax Cloud.
33
- */
34
- private motionUpdate;
35
- /**
36
- * Ambient light sensors for Power Consumption (pure Home App config)
37
- */
38
- private rawLightSensors;
39
- /**
40
- * Ambient light sensors for smooth power consumption lights.
41
- * These lights present smoothed values based on the raw data figures to
42
- * prevent events like the temporary passage of a cloud to directly affect values.
43
- */
44
- private smoothLightSensors;
45
- /** Array with all accessories */
46
- private solaxAccessories;
19
+ private inverters;
47
20
  /**
48
21
  * Platform constructor.
49
22
  * @param log
@@ -54,32 +27,15 @@ export declare class SolaxCloudAPIPlatform implements StaticPlatformPlugin {
54
27
  constructor(log: Logging, config: PlatformConfig, api: API);
55
28
  sleep: typeof import("timers/promises").setTimeout;
56
29
  /**
57
- * Periodically retrieves inverter data from Solax Cloud API using configured tokenID and SN.
30
+ * Check whether object implements interface InverterConfig.
31
+ * @param obj Any object.
32
+ * @returns Whether object implements interface InverterConfig.
58
33
  */
59
- private fetchDataPeriodically;
34
+ private static isInverterConfig;
60
35
  /**
61
- * Update all platform accessory status based on the values read from the API.
62
- * @param {SolaxCloudAPIResponse} apiData API data from Solax Cloud.
63
- */
64
- private updateAccessories;
65
- /**
66
- * Updates smooth ambient light sensors data from raw outlet data by applying configured smoothing function.
67
- */
68
- private updateSmoothLightSensors;
69
- /**
70
- * Update raw ambient light sensors with power consumption data from Solax Cloud API.
71
- * @param {SolaxCloudAPIResponse} apiData API data retrieved from Solax Cloud.
72
- */
73
- private updateRawLightSensors;
74
- /**
75
- * Updates smooth outlet data from raw outlet data by applying configured smoothing function.
36
+ * Periodically retrieves inverter data from Solax Cloud API using configured tokenID and SN.
76
37
  */
77
- private updateSmoothOutlets;
78
- /**
79
- * Update raw outlet data from API data read from Solax Cloud.
80
- * @param {SolaxCloudAPIResponse} apiData Solax Cloud API data.
81
- * */
82
- private updateRawOutlets;
38
+ private fetchDataPeriodically;
83
39
  /**
84
40
  * Checks platform config validity and sets defaults whenever needed.
85
41
  * @returns {boolean} Whether the config is valid.
@@ -1 +1 @@
1
- {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,oBAAoB,EAAE,OAAO,EAAE,cAAc,EAAY,MAAM,YAAY,CAAC;AAE3G,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,QAAQ,MAAM,kBAAkB,CAAC;AAmDxC;;;;GAIG;AACH,qBAAa,qBAAsB,YAAW,oBAAoB;IAChE,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAU;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,SAAgB,GAAG,EAAE,GAAG,CAAC;IAEzB,SAAgB,GAAG,EAAE,eAAe,CAAC;IAC9B,UAAU,EAAE,QAAQ,CAAC;IAE5B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiB;IAE/C;;OAEG;IACH,OAAO,CAAC,eAAe,CAAK;IAE5B;;OAEG;IACH,OAAO,CAAC,UAAU,CAAwB;IAE1C;;;;OAIG;IACH,OAAO,CAAC,aAAa,CAAwB;IAE7C;;OAEG;IACH,OAAO,CAAC,YAAY,CAAwB;IAE5C;;OAEG;IACH,OAAO,CAAC,eAAe,CAA6B;IAEpD;;;;OAIG;IACH,OAAO,CAAC,kBAAkB,CAA6B;IAEvD,iCAAiC;IACjC,OAAO,CAAC,gBAAgB,CAAyB;IAEjD;;;;;;OAMG;gBACU,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,GAAG;IA4J3D,KAAK,8CAA8B;IAEnC;;OAEG;YACW,qBAAqB;IAuBnC;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAuBzB;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAkBhC;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAQ7B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAkB3B;;;SAGK;IACL,OAAO,CAAC,gBAAgB;IASxB;;;OAGG;IACH,OAAO,CAAC,WAAW;IAgFnB,WAAW,CAAC,QAAQ,EAAE,CAAC,gBAAgB,EAAE,eAAe,EAAE,KAAK,IAAI,GAAG,IAAI;CAG3E"}
1
+ {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,oBAAoB,EAAE,OAAO,EAAE,cAAc,EAAY,MAAM,YAAY,CAAC;AA6C3G;;;;GAIG;AACH,qBAAa,qBAAsB,YAAW,oBAAoB;IAChE,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAU;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAM;IAE1B;;OAEG;IACH,OAAO,CAAC,eAAe,CAAK;IAE5B;;OAEG;IACH,OAAO,CAAC,SAAS,CAAuC;IAExD;;;;;;OAMG;gBACU,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,GAAG;IA6C3D,KAAK,8CAA8B;IAEnC;;;;OAIG;IAEH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAI/B;;OAEG;YACW,qBAAqB;IASnC;;;OAGG;IACH,OAAO,CAAC,WAAW;IAqInB,WAAW,CAAC,QAAQ,EAAE,CAAC,gBAAgB,EAAE,eAAe,EAAE,KAAK,IAAI,GAAG,IAAI;CAQ3E"}
package/dist/platform.js CHANGED
@@ -4,13 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.SolaxCloudAPIPlatform = void 0;
7
- const homebridge_lib_1 = require("homebridge-lib");
8
- const fakegato_history_1 = __importDefault(require("fakegato-history"));
9
- const util_1 = __importDefault(require("util"));
10
- const solaxcloudapi_1 = require("./solaxcloudapi");
11
- const outletAccessory_1 = require("./outletAccessory");
12
- const motionAccessory_1 = require("./motionAccessory");
13
- const lightSensorAccessory_1 = require("./lightSensorAccessory");
7
+ const util_1 = require("./util");
8
+ const platformInverter_1 = require("./platformInverter");
9
+ const util_2 = __importDefault(require("util"));
14
10
  /**
15
11
  * Valid smoothing methods (Simple Moving Average, Exponential Moving Average).
16
12
  */
@@ -35,16 +31,6 @@ const MAX_POLLS_DAY = 10000;
35
31
  * Maximum polling frequency (in seconds).
36
32
  */
37
33
  const MAX_POLLING_FREQUENCY = Math.max(60 / MAX_POLLS_MIN, (24 * 60 * 60) / MAX_POLLS_DAY);
38
- /**
39
- * Accessory names.
40
- */
41
- const ACCESSORY_NAMES = {
42
- pv: 'PV',
43
- inverterAC: 'AC',
44
- inverterToGrid: 'To Grid',
45
- inverterToHouse: 'To House',
46
- gridToHouse: 'From Grid',
47
- };
48
34
  /**
49
35
  * SolaxCloudAPIPlatform.
50
36
  * This class is the main constructor for your plugin, this is where you should
@@ -60,12 +46,14 @@ class SolaxCloudAPIPlatform {
60
46
  */
61
47
  constructor(log, config, api) {
62
48
  /**
63
- * Numeber of periods to use for data smoothing.
49
+ * Number of periods to use for data smoothing.
64
50
  */
65
51
  this.smoothingWindow = 1;
66
- /** Array with all accessories */
67
- this.solaxAccessories = [];
68
- this.sleep = util_1.default.promisify(setTimeout);
52
+ /**
53
+ * Array of inverters.
54
+ */
55
+ this.inverters = [];
56
+ this.sleep = util_2.default.promisify(setTimeout);
69
57
  // store values in properties
70
58
  this.log = log;
71
59
  this.config = config;
@@ -82,74 +70,13 @@ class SolaxCloudAPIPlatform {
82
70
  this.smoothingWindow = Math.floor(15 * 60 / this.config.pollingFrequency);
83
71
  this.log.info(`Window for smoothing series is ${this.smoothingWindow} periods.`);
84
72
  try {
85
- this.eve = new homebridge_lib_1.EveHomeKitTypes(this.api);
86
- this.eveService = (0, fakegato_history_1.default)(this.api);
87
- // init new Solax Cloud API object with give tokenID and sn
88
- this.solaxCloudAPI = new solaxcloudapi_1.SolaxCloudAPI(this.config.tokenId, this.config.sn);
89
- // initial data set
90
- const apiData = this.solaxCloudAPI.getAPIData();
91
- this.log.debug(`apiData = ${JSON.stringify(apiData)}`);
92
- let inverterSN;
93
- let inverterModel;
94
- if (apiData.success) {
95
- inverterSN = apiData.result.inverterSN.toLowerCase();
96
- inverterModel = solaxcloudapi_1.SolaxCloudAPI.getInverterType(apiData.result.inverterType);
97
- }
98
- else {
99
- this.log.info('Could not retrieve initial values from Solax Cloud, accessory Serial Number and Model properties deferred...');
100
- inverterSN = String(this.config.name);
101
- inverterModel = 'Unknown';
102
- }
103
- // setup raw outlet accessories
104
- this.rawOutlets = {
105
- pv: new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} ${ACCESSORY_NAMES.pv}`, `pv-${inverterSN}`, inverterModel),
106
- inverterAC: new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} ${ACCESSORY_NAMES.inverterAC}`, `inv-ac-${inverterSN}`, inverterModel),
107
- inverterToGrid: new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} ${ACCESSORY_NAMES.inverterToGrid}`, `inv-grid-${inverterSN}`, inverterModel),
108
- inverterToHouse: new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} ${ACCESSORY_NAMES.inverterToHouse}`, `inv-house-${inverterSN}`, inverterModel),
109
- gridToHouse: new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} ${ACCESSORY_NAMES.gridToHouse}`, `grid-house-${inverterSN}`, inverterModel),
110
- };
111
- // setup update motion sensor
112
- this.motionUpdate = new motionAccessory_1.SolaxMotionAccessory(this, this.log, `${this.config.name} Update`, `update-${inverterSN}`, inverterModel);
113
- // create array with all base accessories
114
- this.solaxAccessories =
115
- [this.rawOutlets.pv, this.rawOutlets.inverterAC, this.rawOutlets.inverterToGrid,
116
- this.rawOutlets.inverterToHouse, this.rawOutlets.gridToHouse, this.motionUpdate];
117
- // check if "pure" Home App accessories are needed
118
- if (this.config.pureHomeApp) {
119
- // add raw light sensors
120
- this.rawLightSensors = {
121
- pv: new lightSensorAccessory_1.SolaxLightSensorAccessory(this, this.log, `${this.config.name} ${ACCESSORY_NAMES.pv} sensor`, `pv-light-${inverterSN}`, inverterModel),
122
- inverterAC: new lightSensorAccessory_1.SolaxLightSensorAccessory(this, this.log, `${this.config.name} ${ACCESSORY_NAMES.inverterAC} sensor`, `inv-ac-light-${inverterSN}`, inverterModel),
123
- inverterToGrid: new lightSensorAccessory_1.SolaxLightSensorAccessory(this, this.log, `${this.config.name} ${ACCESSORY_NAMES.inverterToGrid} sensor`, `inv-grid-light-${inverterSN}`, inverterModel),
124
- inverterToHouse: new lightSensorAccessory_1.SolaxLightSensorAccessory(this, this.log, `${this.config.name} ${ACCESSORY_NAMES.inverterToHouse} sensor`, `inv-house-light-${inverterSN}`, inverterModel),
125
- gridToHouse: new lightSensorAccessory_1.SolaxLightSensorAccessory(this, this.log, `${this.config.name} ${ACCESSORY_NAMES.gridToHouse} sensor`, `grid-house-light-${inverterSN}`, inverterModel),
126
- };
127
- this.solaxAccessories.push(this.rawLightSensors.pv, this.rawLightSensors.inverterAC, this.rawLightSensors.inverterToGrid, this.rawLightSensors.inverterToHouse, this.rawLightSensors.gridToHouse);
128
- if (this.config.smoothMeters) {
129
- // add smooth light sensors
130
- this.smoothLightSensors = {
131
- pv: new lightSensorAccessory_1.SolaxLightSensorAccessory(this, this.log, `${this.config.name} ${ACCESSORY_NAMES.pv} sensor (smooth)`, `pv-light-${inverterSN}`, inverterModel),
132
- inverterAC: new lightSensorAccessory_1.SolaxLightSensorAccessory(this, this.log, `${this.config.name} ${ACCESSORY_NAMES.inverterAC} sensor (smooth)`, `inv-ac-light-smooth-${inverterSN}`, inverterModel),
133
- inverterToGrid: new lightSensorAccessory_1.SolaxLightSensorAccessory(this, this.log, `${this.config.name} ${ACCESSORY_NAMES.inverterToGrid} sensor (smooth)`, `inv-grid-light-smooth-${inverterSN}`, inverterModel),
134
- inverterToHouse: new lightSensorAccessory_1.SolaxLightSensorAccessory(this, this.log, `${this.config.name} ${ACCESSORY_NAMES.inverterToHouse} sensor (smooth)`, `inv-house-light-smooth-${inverterSN}`, inverterModel),
135
- gridToHouse: new lightSensorAccessory_1.SolaxLightSensorAccessory(this, this.log, `${this.config.name} ${ACCESSORY_NAMES.gridToHouse} sensor (smooth)`, `grid-house-light-smooth-${inverterSN}`, inverterModel),
136
- };
137
- this.solaxAccessories.push(this.smoothLightSensors.pv, this.smoothLightSensors.inverterAC, this.smoothLightSensors.inverterToGrid, this.smoothLightSensors.inverterToHouse, this.smoothLightSensors.gridToHouse);
138
- }
139
- }
140
- else {
141
- if (this.config.smoothMeters) {
142
- // setup smooth outlet accessories
143
- this.smoothOutlets = {
144
- pv: new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} ${ACCESSORY_NAMES.pv} (smooth)`, `pv-smooth-${inverterSN}`, inverterModel),
145
- inverterAC: new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} ${ACCESSORY_NAMES.inverterAC} (smooth)`, `inv-ac-smooth-${inverterSN}`, inverterModel),
146
- inverterToGrid: new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} ${ACCESSORY_NAMES.inverterToGrid} (smooth)`, `inv-grid-smooth-${inverterSN}`, inverterModel),
147
- inverterToHouse: new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} ${ACCESSORY_NAMES.inverterToHouse} (smooth)`, `inv-house-smooth-${inverterSN}`, inverterModel),
148
- gridToHouse: new outletAccessory_1.SolaxOutletAccessory(this, this.log, `${this.config.name} ${ACCESSORY_NAMES.gridToHouse} (smooth)`, `grid-house-smooth-${inverterSN}`, inverterModel),
149
- };
150
- this.solaxAccessories.push(this.smoothOutlets.pv, this.smoothOutlets.inverterAC, this.smoothOutlets.inverterToGrid, this.smoothOutlets.inverterToHouse, this.smoothOutlets.gridToHouse);
151
- }
152
- }
73
+ // loop over configured inverters
74
+ this.config.inverters.forEach(inverter => {
75
+ // setup new inverter
76
+ const platformInverter = new platformInverter_1.SolaxCloudAPIPlatformInverter(log, config, api, this.config.tokenId, inverter.sn, inverter.name, this.smoothingWindow);
77
+ // add new inverter to list
78
+ this.inverters.push(platformInverter);
79
+ });
153
80
  // start data fetching
154
81
  this.fetchDataPeriodically();
155
82
  this.log.debug('Finished initializing platform.');
@@ -163,95 +90,22 @@ class SolaxCloudAPIPlatform {
163
90
  });
164
91
  }
165
92
  /**
166
- * Periodically retrieves inverter data from Solax Cloud API using configured tokenID and SN.
93
+ * Check whether object implements interface InverterConfig.
94
+ * @param obj Any object.
95
+ * @returns Whether object implements interface InverterConfig.
167
96
  */
168
- async fetchDataPeriodically() {
169
- try {
170
- this.log.debug('Retrieving data from Solax Cloud API.');
171
- const apiData = this.solaxCloudAPI.getAPIData();
172
- if (apiData.success) {
173
- this.log.debug(`Retrieved inverter status: ${JSON.stringify(apiData.result)}`);
174
- this.updateAccessories(apiData);
175
- }
176
- else {
177
- throw new Error(apiData.exception);
178
- }
179
- }
180
- catch (error) {
181
- this.log.error(`Failed to read from Solax Cloud API. Error: ${error}`);
182
- }
183
- finally {
184
- this.log.info(`Updated data from Solax Cloud API, sleeping for ${this.config.pollingFrequency} seconds.`);
185
- this.sleep(this.config.pollingFrequency * 1000)
186
- .then(async () => await this.fetchDataPeriodically());
187
- }
97
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
98
+ static isInverterConfig(obj) {
99
+ return 'name' in obj && 'sn' in obj;
188
100
  }
189
101
  /**
190
- * Update all platform accessory status based on the values read from the API.
191
- * @param {SolaxCloudAPIResponse} apiData API data from Solax Cloud.
192
- */
193
- updateAccessories(apiData) {
194
- // update raw outlets on/off, power & energy settings
195
- this.updateRawOutlets(apiData);
196
- if (this.config.pureHomeApp) {
197
- // update raw light sensors with power consumption
198
- this.updateRawLightSensors(apiData);
199
- if (this.config.smoothMeters) {
200
- // update smooth light sensors from raw outlets by applying smoothing function to power consumption
201
- this.updateSmoothLightSensors();
202
- }
203
- }
204
- else {
205
- if (this.config.smoothMeters) {
206
- // update smooth outlets data from raw outlets by applying smoothing function to power consumption
207
- this.updateSmoothOutlets();
208
- }
209
- }
210
- // update motion sensor
211
- this.motionUpdate.setState(true);
212
- }
213
- /**
214
- * Updates smooth ambient light sensors data from raw outlet data by applying configured smoothing function.
215
- */
216
- updateSmoothLightSensors() {
217
- this.smoothLightSensors.pv.setAmbientLightLevel(this.rawOutlets.pv.getSmoothPowerConsumption(this.config.smoothingMethod, this.smoothingWindow));
218
- this.smoothLightSensors.inverterAC.setAmbientLightLevel(this.rawOutlets.inverterAC.getSmoothPowerConsumption(this.config.smoothingMethod, this.smoothingWindow));
219
- this.smoothLightSensors.inverterToGrid.setAmbientLightLevel(this.rawOutlets.inverterToGrid.getSmoothPowerConsumption(this.config.smoothingMethod, this.smoothingWindow));
220
- this.smoothLightSensors.inverterToHouse.setAmbientLightLevel(this.rawOutlets.inverterToHouse.getSmoothPowerConsumption(this.config.smoothingMethod, this.smoothingWindow));
221
- this.smoothLightSensors.gridToHouse.setAmbientLightLevel(this.rawOutlets.gridToHouse.getSmoothPowerConsumption(this.config.smoothingMethod, this.smoothingWindow));
222
- }
223
- /**
224
- * Update raw ambient light sensors with power consumption data from Solax Cloud API.
225
- * @param {SolaxCloudAPIResponse} apiData API data retrieved from Solax Cloud.
226
- */
227
- updateRawLightSensors(apiData) {
228
- this.rawLightSensors.pv.setAmbientLightLevel(solaxcloudapi_1.SolaxCloudAPI.getPVPower(apiData.result));
229
- this.rawLightSensors.inverterAC.setAmbientLightLevel(solaxcloudapi_1.SolaxCloudAPI.getInverterACPower(apiData.result));
230
- this.rawLightSensors.inverterToGrid.setAmbientLightLevel(solaxcloudapi_1.SolaxCloudAPI.getInverterPowerToGrid(apiData.result));
231
- this.rawLightSensors.inverterToHouse.setAmbientLightLevel(solaxcloudapi_1.SolaxCloudAPI.getInverterPowerToHouse(apiData.result));
232
- this.rawLightSensors.gridToHouse.setAmbientLightLevel(solaxcloudapi_1.SolaxCloudAPI.getGridPowerToHouse(apiData.result));
233
- }
234
- /**
235
- * Updates smooth outlet data from raw outlet data by applying configured smoothing function.
102
+ * Periodically retrieves inverter data from Solax Cloud API using configured tokenID and SN.
236
103
  */
237
- updateSmoothOutlets() {
238
- this.smoothOutlets.pv.setPowerConsumption(this.rawOutlets.pv.getSmoothPowerConsumption(this.config.smoothingMethod, this.smoothingWindow));
239
- this.smoothOutlets.inverterAC.setPowerConsumption(this.rawOutlets.inverterAC.getSmoothPowerConsumption(this.config.smoothingMethod, this.smoothingWindow));
240
- this.smoothOutlets.inverterToGrid.setPowerConsumption(this.rawOutlets.inverterToGrid.getSmoothPowerConsumption(this.config.smoothingMethod, this.smoothingWindow));
241
- this.smoothOutlets.inverterToHouse.setPowerConsumption(this.rawOutlets.inverterToHouse.getSmoothPowerConsumption(this.config.smoothingMethod, this.smoothingWindow));
242
- this.smoothOutlets.gridToHouse.setPowerConsumption(this.rawOutlets.gridToHouse.getSmoothPowerConsumption(this.config.smoothingMethod, this.smoothingWindow));
243
- }
244
- /**
245
- * Update raw outlet data from API data read from Solax Cloud.
246
- * @param {SolaxCloudAPIResponse} apiData Solax Cloud API data.
247
- * */
248
- updateRawOutlets(apiData) {
249
- this.rawOutlets.pv.setPowerConsumption(solaxcloudapi_1.SolaxCloudAPI.getPVPower(apiData.result));
250
- this.rawOutlets.inverterAC.setPowerConsumption(solaxcloudapi_1.SolaxCloudAPI.getInverterACPower(apiData.result));
251
- this.rawOutlets.inverterAC.setTotalEnergyConsumption(solaxcloudapi_1.SolaxCloudAPI.getYieldTotal(apiData.result));
252
- this.rawOutlets.inverterToGrid.setPowerConsumption(solaxcloudapi_1.SolaxCloudAPI.getInverterPowerToGrid(apiData.result));
253
- this.rawOutlets.inverterToHouse.setPowerConsumption(solaxcloudapi_1.SolaxCloudAPI.getInverterPowerToHouse(apiData.result));
254
- this.rawOutlets.gridToHouse.setPowerConsumption(solaxcloudapi_1.SolaxCloudAPI.getGridPowerToHouse(apiData.result));
104
+ async fetchDataPeriodically() {
105
+ // loop over inverters and update its data
106
+ this.inverters.forEach(inverter => inverter.updateInverterData());
107
+ this.log.info(`Updated data from Solax Cloud API, sleeping for ${this.config.pollingFrequency} seconds.`);
108
+ this.sleep(this.config.pollingFrequency * 1000).then(async () => await this.fetchDataPeriodically());
255
109
  }
256
110
  /**
257
111
  * Checks platform config validity and sets defaults whenever needed.
@@ -260,18 +114,60 @@ class SolaxCloudAPIPlatform {
260
114
  checkConfig(config) {
261
115
  let result = true;
262
116
  this.log.debug(`Config read: ${JSON.stringify(config)}`);
117
+ // check for configuration conversion to new format if needed
118
+ if (!config.inverters) {
119
+ // check for "old" configuration settings
120
+ if (config.name && config.sn) {
121
+ this.log.info('Converting config file to new format (with multiple inverters support)...');
122
+ // setup new configuration settings (supporting multiple inverters) with single entry
123
+ config.inverters = [
124
+ {
125
+ name: config.name,
126
+ sn: config.sn,
127
+ },
128
+ ];
129
+ // delete old configuration settings
130
+ delete config.name;
131
+ delete config.sn;
132
+ }
133
+ }
263
134
  // check for mandatory parameters
264
- if (!config.name) {
265
- this.log.error('Config check: Can\'t find mandatory parameter "name" parameter in config file, aborting!');
135
+ if (!config.tokenId) {
136
+ this.log.error('Config check: Can\'t find mandatory parameter "tokenId" parameter in config file, aborting!');
266
137
  result = false;
138
+ return result;
267
139
  }
268
- else if (!config.tokenId) {
269
- this.log.error('Config check: Can\'t find mandatory parameter "tokenId" parameter in config file, aborting!');
140
+ if (!config.inverters) {
141
+ this.log.error('Config check: Can\'t find mandatory parameter "inverters" parameter in config file, aborting!');
142
+ result = false;
143
+ return result;
144
+ }
145
+ // check for inverters type
146
+ if (Array.isArray(config.inverters)) {
147
+ // loop over inverters and check config type
148
+ config.inverters.forEach(inverter => {
149
+ if (!SolaxCloudAPIPlatform.isInverterConfig(inverter)) {
150
+ this.log.error('Config check: Invalid type for inverter under "inverters" in config file, aborting!');
151
+ result = false;
152
+ return result;
153
+ }
154
+ });
155
+ }
156
+ else {
157
+ this.log.error('Config check: Incorrect type for mandatory parameter "inverters" in config file, aborting!');
158
+ result = false;
159
+ return result;
160
+ }
161
+ // check for duplicates
162
+ if (util_1.Util.arrayHasDuplicates(config.inverters.map(inverter => inverter.name))) {
163
+ this.log.error('Config check: Duplicate inverter names in config file, aborting!');
270
164
  result = false;
165
+ return result;
271
166
  }
272
- else if (!config.sn) {
273
- this.log.error('Config check: Can\'t find mandatory parameter "sn" parameter in config file, aborting!');
167
+ else if (util_1.Util.arrayHasDuplicates(config.inverters.map(inverter => inverter.sn))) {
168
+ this.log.error('Config check: Duplicate inverter SNs in config file, aborting!');
274
169
  result = false;
170
+ return result;
275
171
  }
276
172
  // check for polling frequency
277
173
  if (config.pollingFrequency === undefined) {
@@ -335,7 +231,10 @@ class SolaxCloudAPIPlatform {
335
231
  * The Platform must respond in a timely manner as otherwise the startup of the bridge would be unnecessarily delayed.
336
232
  */
337
233
  accessories(callback) {
338
- callback(this.solaxAccessories);
234
+ const accessories = [];
235
+ // loop over inverters and add accessories
236
+ this.inverters.forEach(inverter => accessories.push(...inverter.getAccessories()));
237
+ callback(accessories);
339
238
  }
340
239
  }
341
240
  exports.SolaxCloudAPIPlatform = SolaxCloudAPIPlatform;