homebridge-solaxcloud-api 2.3.3 → 2.4.1

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 (55) hide show
  1. package/CHANGELOG.md +150 -131
  2. package/LICENSE +175 -175
  3. package/README.md +1 -0
  4. package/config.sample +15 -15
  5. package/config.schema.json +113 -106
  6. package/dist/batteryAccessory.d.ts +70 -70
  7. package/dist/batteryAccessory.d.ts.map +1 -1
  8. package/dist/batteryAccessory.js +124 -123
  9. package/dist/batteryAccessory.js.map +1 -1
  10. package/dist/index.d.ts +6 -6
  11. package/dist/index.js +6 -6
  12. package/dist/lightSensorAccessory.d.ts +34 -34
  13. package/dist/lightSensorAccessory.js +58 -58
  14. package/dist/motionAccessory.d.ts +53 -53
  15. package/dist/motionAccessory.js +93 -93
  16. package/dist/outletAccessory.d.ts +104 -100
  17. package/dist/outletAccessory.d.ts.map +1 -1
  18. package/dist/outletAccessory.js +196 -187
  19. package/dist/outletAccessory.js.map +1 -1
  20. package/dist/platform.d.ts +67 -56
  21. package/dist/platform.d.ts.map +1 -1
  22. package/dist/platform.js +320 -265
  23. package/dist/platform.js.map +1 -1
  24. package/dist/platformAccessory.d.ts +70 -70
  25. package/dist/platformAccessory.js +102 -102
  26. package/dist/platformInverter.d.ts +180 -176
  27. package/dist/platformInverter.d.ts.map +1 -1
  28. package/dist/platformInverter.js +348 -343
  29. package/dist/platformInverter.js.map +1 -1
  30. package/dist/platformMeters.d.ts +68 -68
  31. package/dist/platformMeters.js +2 -2
  32. package/dist/settings.d.ts +8 -8
  33. package/dist/settings.js +11 -11
  34. package/dist/solaxcloudfetch.d.ts +1 -1
  35. package/dist/solaxcloudfetch.js +21 -21
  36. package/dist/solaxcloudfetch.js.map +1 -1
  37. package/dist/statistics.d.ts +36 -36
  38. package/dist/statistics.js +88 -88
  39. package/dist/util.d.ts +23 -23
  40. package/dist/util.js +42 -42
  41. package/package.json +55 -54
  42. package/test/batteryAccessory.test.ts +16 -0
  43. package/test/helpers.ts +36 -0
  44. package/test/lightSensorAccessory.test.ts +28 -0
  45. package/test/motionAccessory.test.ts +36 -0
  46. package/test/outletAccessory.test.ts +75 -0
  47. package/test/platformAccessory.test.ts +24 -0
  48. package/test/platformConfig.test.ts +188 -0
  49. package/test/platformTotalizer.test.ts +97 -0
  50. package/config.json +0 -16
  51. package/dist/solaxcloudapi.d.ts +0 -163
  52. package/dist/solaxcloudapi.d.ts.map +0 -1
  53. package/dist/solaxcloudapi.js +0 -226
  54. package/dist/solaxcloudapi.js.map +0 -1
  55. package/test/solaxcloudapi.test.ts +0 -164
@@ -1,101 +1,105 @@
1
- import { Service, AccessoryPlugin, Logging, CharacteristicGetCallback, API } from 'homebridge';
2
- import { SolaxPlatformAccessory } from './platformAccessory';
3
- /**
4
- * Solax Outlet Accessory.
5
- * Virtual outlet used to monitor and measure both power and total energy consumption from Solax devices.
6
- * Outlet use is inferred from a positive power comsumption.
7
- */
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;
17
- /**
18
- * Outlet service with power meter.
19
- */
20
- private readonly outletService;
21
- /**
22
- * Current power reading in Watt.
23
- */
24
- private powerConsumption;
25
- /**
26
- * Total energy readings in KWh.
27
- */
28
- private totalEnergyConsumption;
29
- /**
30
- * Elgato Eve fake history service for energy and status.
31
- */
32
- private readonly loggingService;
33
- /**
34
- * Power series for smoothing operations.
35
- */
36
- private readonly powerSeries;
37
- /**
38
- * Last Exponential Moving Average.
39
- */
40
- private lastEMA;
41
- /**
42
- * Solax virtual outlet class constructor.
43
- * @param {Logging} log The platform logging for homebridge.
44
- * @param {API} api The API for Solax Cloud platform.
45
- * @param {string} name The accessory name.
46
- * @param {string} serial "Real world" serial number for this accessory.
47
- * @param {string} model Accessory model.
48
- */
49
- constructor(log: Logging, api: API, name: string, serial: string, model: string);
50
- /**
51
- * Adds new power entry to series array of power values.
52
- * @param {number} powerConsumption Power value to add (in Watts).
53
- */
54
- private addPowerEntry;
55
- /**
56
- * Gets array series with power consumption values.
57
- * @returns {number[]} Array with power consumption values.
58
- */
59
- getPowerSeries(): number[];
60
- /**
61
- * Get outlet power from power series by smoothing data using the desired method and window size.
62
- * @param {string} method Method to smooth data ('SMA' or 'EMA').
63
- * @param {number} windowSize Window size for SMA or EMA.
64
- * @returns {number} Power value after smoothing (rounded to nearest integer number).
65
- */
66
- getSmoothPowerConsumption(method: string, windowSize: number): number;
67
- /**
68
- * Gets the current power consumption value for this outlet.
69
- * @returns {number} Outlet power consumption (Watt).
70
- */
71
- getPowerConsumptionValue(): number;
72
- /**
73
- * Gets the current power consumpion.
74
- */
75
- getPowerConsumption(callback: CharacteristicGetCallback): void;
76
- /**
77
- * Sets the current power consumption.
78
- * @param {number} powerConsumption The power consumption to set. */
79
- setPowerConsumption(powerConsumption: number): void;
80
- /**
81
- * Gets the total energy consumption value for this outlet.
82
- * @returns {number} Outlet total energy consumption (Wh).
83
- */
84
- getTotalEnergyConsumptionValue(): number;
85
- /**
86
- * Gets the total energy consumpion.
87
- */
88
- getTotalEnergyConsumption(callback: CharacteristicGetCallback): void;
89
- /**
90
- * Sets the total energy consumption.
91
- * @param {number} totalEnergyConsumption The total energy consumption to set.
92
- */
93
- setTotalEnergyConsumption(totalEnergyConsumption: number): void;
94
- /**
95
- * Gets the outlet state Characteristic based on its consumed power.
96
- * @param {CharacteristicGetCallback} callback The callback.
97
- */
98
- getState(callback: CharacteristicGetCallback): void;
99
- getServices(): Service[];
100
- }
1
+ import { Service, AccessoryPlugin, Logging, CharacteristicGetCallback, API } from 'homebridge';
2
+ import { SolaxPlatformAccessory } from './platformAccessory';
3
+ /**
4
+ * Solax Outlet Accessory.
5
+ * Virtual outlet used to monitor and measure both power and total energy consumption from Solax devices.
6
+ * Outlet use is inferred from a positive power comsumption.
7
+ */
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?;
17
+ /**
18
+ * Outlet service with power meter.
19
+ */
20
+ private readonly outletService;
21
+ /**
22
+ * Current power reading in Watt.
23
+ */
24
+ private powerConsumption;
25
+ /**
26
+ * Total energy readings in KWh.
27
+ */
28
+ private totalEnergyConsumption;
29
+ /**
30
+ * Elgato Eve fake history service for energy and status.
31
+ */
32
+ private readonly loggingService?;
33
+ /**
34
+ * Whether fakegato history is enabled for this outlet.
35
+ */
36
+ private readonly enableHistory;
37
+ /**
38
+ * Power series for smoothing operations.
39
+ */
40
+ private readonly powerSeries;
41
+ /**
42
+ * Last Exponential Moving Average.
43
+ */
44
+ private lastEMA;
45
+ /**
46
+ * Solax virtual outlet class constructor.
47
+ * @param {Logging} log The platform logging for homebridge.
48
+ * @param {API} api The API for Solax Cloud platform.
49
+ * @param {string} name The accessory name.
50
+ * @param {string} serial "Real world" serial number for this accessory.
51
+ * @param {string} model Accessory model.
52
+ */
53
+ constructor(log: Logging, api: API, name: string, serial: string, model: string, enableHistory?: boolean);
54
+ /**
55
+ * Adds new power entry to series array of power values.
56
+ * @param {number} powerConsumption Power value to add (in Watts).
57
+ */
58
+ private addPowerEntry;
59
+ /**
60
+ * Gets array series with power consumption values.
61
+ * @returns {number[]} Array with power consumption values.
62
+ */
63
+ getPowerSeries(): number[];
64
+ /**
65
+ * Get outlet power from power series by smoothing data using the desired method and window size.
66
+ * @param {string} method Method to smooth data ('SMA' or 'EMA').
67
+ * @param {number} windowSize Window size for SMA or EMA.
68
+ * @returns {number} Power value after smoothing (rounded to nearest integer number).
69
+ */
70
+ getSmoothPowerConsumption(method: string, windowSize: number): number;
71
+ /**
72
+ * Gets the current power consumption value for this outlet.
73
+ * @returns {number} Outlet power consumption (Watt).
74
+ */
75
+ getPowerConsumptionValue(): number;
76
+ /**
77
+ * Gets the current power consumpion.
78
+ */
79
+ getPowerConsumption(callback: CharacteristicGetCallback): void;
80
+ /**
81
+ * Sets the current power consumption.
82
+ * @param {number} powerConsumption The power consumption to set. */
83
+ setPowerConsumption(powerConsumption: number): void;
84
+ /**
85
+ * Gets the total energy consumption value for this outlet.
86
+ * @returns {number} Outlet total energy consumption (Wh).
87
+ */
88
+ getTotalEnergyConsumptionValue(): number;
89
+ /**
90
+ * Gets the total energy consumpion.
91
+ */
92
+ getTotalEnergyConsumption(callback: CharacteristicGetCallback): void;
93
+ /**
94
+ * Sets the total energy consumption.
95
+ * @param {number} totalEnergyConsumption The total energy consumption to set.
96
+ */
97
+ setTotalEnergyConsumption(totalEnergyConsumption: number): void;
98
+ /**
99
+ * Gets the outlet state Characteristic based on its consumed power.
100
+ * @param {CharacteristicGetCallback} callback The callback.
101
+ */
102
+ getState(callback: CharacteristicGetCallback): void;
103
+ getServices(): Service[];
104
+ }
101
105
  //# sourceMappingURL=outletAccessory.d.ts.map
@@ -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,GAAG,EAAE,MAAM,YAAY,CAAC;AAE/F,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAa7D;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,sBAAuB,YAAW,eAAe;IAEzF;;SAEK;IACL,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAkB;IAEtC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAW;IAEtC;;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,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
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SolaxOutletAccessory = void 0;
7
- const platformAccessory_1 = require("./platformAccessory");
8
- const statistics_1 = require("./statistics");
9
- const homebridge_lib_1 = require("homebridge-lib");
10
- const fakegato_history_1 = __importDefault(require("fakegato-history"));
11
- /**
12
- * Maximum size for the outlet power series.
13
- */
14
- const MAX_POWER_SERIES_SIZE = 1024;
15
- /**
16
- * Solax Outlet Accessory.
17
- * Virtual outlet used to monitor and measure both power and total energy consumption from Solax devices.
18
- * Outlet use is inferred from a positive power comsumption.
19
- */
20
- class SolaxOutletAccessory extends platformAccessory_1.SolaxPlatformAccessory {
21
- /**
22
- * Solax virtual outlet class constructor.
23
- * @param {Logging} log The platform logging for homebridge.
24
- * @param {API} api The API for Solax Cloud platform.
25
- * @param {string} name The accessory name.
26
- * @param {string} serial "Real world" serial number for this accessory.
27
- * @param {string} model Accessory model.
28
- */
29
- constructor(log, api, name, serial, model) {
30
- super(log, api, name, serial, model);
31
- /**
32
- * Current power reading in Watt.
33
- */
34
- this.powerConsumption = 0;
35
- /**
36
- * Total energy readings in KWh.
37
- */
38
- this.totalEnergyConsumption = 0.0;
39
- /**
40
- * Power series for smoothing operations.
41
- */
42
- this.powerSeries = [];
43
- /**
44
- * Last Exponential Moving Average.
45
- */
46
- this.lastEMA = 0;
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);
51
- // create power meter service
52
- this.outletService = new this.eve.Services.Outlet(this.name);
53
- // outlet on/off state
54
- this.outletService.getCharacteristic(this.api.hap.Characteristic.On)
55
- .on("get" /* GET */, this.getState.bind(this));
56
- // in use
57
- //this.outletService.getCharacteristic(hap.Characteristic.OutletInUse).on(hap.CharacteristicEventTypes.GET, this.getState.bind(this));
58
- // current consumption
59
- this.outletService.getCharacteristic(this.eve.Characteristics.CurrentConsumption)
60
- .on("get" /* GET */, this.getPowerConsumption.bind(this));
61
- // total consumption
62
- this.outletService.getCharacteristic(this.eve.Characteristics.TotalConsumption)
63
- .on("get" /* GET */, this.getTotalEnergyConsumption.bind(this));
64
- // history logging services
65
- this.loggingService = new this.eveService('energy', this, { storage: 'fs', log: this.log, disableRepeatLastData: true });
66
- log.info(`Outlet "${name}" created!`);
67
- }
68
- /**
69
- * Adds new power entry to series array of power values.
70
- * @param {number} powerConsumption Power value to add (in Watts).
71
- */
72
- addPowerEntry(powerConsumption) {
73
- // check if we reached the limit
74
- if (this.powerSeries.length === MAX_POWER_SERIES_SIZE) {
75
- // remove first element
76
- this.powerSeries.shift();
77
- }
78
- // add new element
79
- this.powerSeries.push(powerConsumption);
80
- }
81
- /**
82
- * Gets array series with power consumption values.
83
- * @returns {number[]} Array with power consumption values.
84
- */
85
- getPowerSeries() {
86
- return this.powerSeries;
87
- }
88
- /**
89
- * Get outlet power from power series by smoothing data using the desired method and window size.
90
- * @param {string} method Method to smooth data ('SMA' or 'EMA').
91
- * @param {number} windowSize Window size for SMA or EMA.
92
- * @returns {number} Power value after smoothing (rounded to nearest integer number).
93
- */
94
- getSmoothPowerConsumption(method, windowSize) {
95
- this.log.debug(`${this.name}: GET Power Smooth (method=${method}, window=${windowSize})`);
96
- let result = 0;
97
- // get power series for window size
98
- const series = this.getPowerSeries().slice(-windowSize);
99
- // calculate simple moving average from given window size
100
- const [sma] = statistics_1.Statistics.simpleMovingAverage(series, Math.min(windowSize, series.length));
101
- // check if we have enough data for averaging
102
- switch (method) {
103
- case 'sma':
104
- result = sma;
105
- this.log.debug(`${this.name}: simple moving average (window data=[${series}], power=${result}W)`);
106
- break;
107
- case 'ema':
108
- if (series.length < windowSize) {
109
- result = sma;
110
- this.log.debug(`${this.name}: exponential moving average (window data=[${series}], last EMA=none, power=${result}W)`);
111
- }
112
- else {
113
- const lastPowerValue = series[series.length - 1];
114
- const weight = 2 / (windowSize + 1);
115
- result = (lastPowerValue - this.lastEMA) * weight + this.lastEMA;
116
- this.log.debug(`${this.name}: exponential moving average (window data=[${series}], last EMA=${this.lastEMA}, power=${result}W)`);
117
- }
118
- this.lastEMA = result;
119
- }
120
- return result;
121
- }
122
- /**
123
- * Gets the current power consumption value for this outlet.
124
- * @returns {number} Outlet power consumption (Watt).
125
- */
126
- getPowerConsumptionValue() {
127
- return this.powerConsumption;
128
- }
129
- /**
130
- * Gets the current power consumpion.
131
- */
132
- getPowerConsumption(callback) {
133
- this.log.debug(`${this.name}: GET Power (power=${this.powerConsumption}W)`);
134
- callback(null, this.powerConsumption);
135
- }
136
- /**
137
- * Sets the current power consumption.
138
- * @param {number} powerConsumption The power consumption to set. */
139
- setPowerConsumption(powerConsumption) {
140
- this.log.debug(`${this.name}: SET Power (power=${powerConsumption}W)`);
141
- this.powerConsumption = powerConsumption >= 0 ? powerConsumption : 0;
142
- this.outletService.getCharacteristic(this.eve.Characteristics.CurrentConsumption).updateValue(this.powerConsumption);
143
- // add entries to history
144
- this.loggingService.addEntry({ time: Math.round(new Date().valueOf() / 1000), power: this.powerConsumption });
145
- // add new value to power series
146
- this.addPowerEntry(this.powerConsumption);
147
- }
148
- /**
149
- * Gets the total energy consumption value for this outlet.
150
- * @returns {number} Outlet total energy consumption (Wh).
151
- */
152
- getTotalEnergyConsumptionValue() {
153
- return this.totalEnergyConsumption;
154
- }
155
- /**
156
- * Gets the total energy consumpion.
157
- */
158
- getTotalEnergyConsumption(callback) {
159
- this.log.debug(`${this.name}: GET Total Energy (energy=${this.totalEnergyConsumption}kWh)`);
160
- callback(null, this.totalEnergyConsumption);
161
- }
162
- /**
163
- * Sets the total energy consumption.
164
- * @param {number} totalEnergyConsumption The total energy consumption to set.
165
- */
166
- setTotalEnergyConsumption(totalEnergyConsumption) {
167
- this.log.debug(`${this.name}: SET Total Energy (energy=${totalEnergyConsumption}kWh)`);
168
- this.totalEnergyConsumption = totalEnergyConsumption;
169
- this.outletService.getCharacteristic(this.eve.Characteristics.TotalConsumption).updateValue(this.totalEnergyConsumption);
170
- }
171
- /**
172
- * Gets the outlet state Characteristic based on its consumed power.
173
- * @param {CharacteristicGetCallback} callback The callback.
174
- */
175
- getState(callback) {
176
- this.log.debug(`${this.name}: GET State (power=${this.powerConsumption}W)`);
177
- callback(null, this.powerConsumption > 0);
178
- }
179
- /*
180
- * This method is called directly after creation of this instance.
181
- * It should return all services which should be added to the accessory.
182
- */
183
- getServices() {
184
- return [this.informationService, this.outletService, this.loggingService];
185
- }
186
- }
187
- exports.SolaxOutletAccessory = SolaxOutletAccessory;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SolaxOutletAccessory = void 0;
7
+ const platformAccessory_1 = require("./platformAccessory");
8
+ const statistics_1 = require("./statistics");
9
+ const homebridge_lib_1 = require("homebridge-lib");
10
+ const fakegato_history_1 = __importDefault(require("fakegato-history"));
11
+ /**
12
+ * Maximum size for the outlet power series.
13
+ */
14
+ const MAX_POWER_SERIES_SIZE = 1024;
15
+ /**
16
+ * Solax Outlet Accessory.
17
+ * Virtual outlet used to monitor and measure both power and total energy consumption from Solax devices.
18
+ * Outlet use is inferred from a positive power comsumption.
19
+ */
20
+ class SolaxOutletAccessory extends platformAccessory_1.SolaxPlatformAccessory {
21
+ /**
22
+ * Solax virtual outlet class constructor.
23
+ * @param {Logging} log The platform logging for homebridge.
24
+ * @param {API} api The API for Solax Cloud platform.
25
+ * @param {string} name The accessory name.
26
+ * @param {string} serial "Real world" serial number for this accessory.
27
+ * @param {string} model Accessory model.
28
+ */
29
+ constructor(log, api, name, serial, model, enableHistory = true) {
30
+ super(log, api, name, serial, model);
31
+ /**
32
+ * Current power reading in Watt.
33
+ */
34
+ this.powerConsumption = 0;
35
+ /**
36
+ * Total energy readings in KWh.
37
+ */
38
+ this.totalEnergyConsumption = 0.0;
39
+ /**
40
+ * Power series for smoothing operations.
41
+ */
42
+ this.powerSeries = [];
43
+ /**
44
+ * Last Exponential Moving Average.
45
+ */
46
+ this.lastEMA = 0;
47
+ this.log.debug(`Creating outlet "${this.name}"`);
48
+ this.enableHistory = enableHistory;
49
+ // init fakegato objects
50
+ this.eve = new homebridge_lib_1.EveHomeKitTypes(this.api);
51
+ // create power meter service
52
+ this.outletService = new this.eve.Services.Outlet(this.name);
53
+ // outlet on/off state
54
+ this.outletService.getCharacteristic(this.api.hap.Characteristic.On)
55
+ .on("get" /* GET */, this.getState.bind(this));
56
+ // in use
57
+ //this.outletService.getCharacteristic(hap.Characteristic.OutletInUse).on(hap.CharacteristicEventTypes.GET, this.getState.bind(this));
58
+ // current consumption
59
+ this.outletService.getCharacteristic(this.eve.Characteristics.CurrentConsumption)
60
+ .on("get" /* GET */, this.getPowerConsumption.bind(this));
61
+ // total consumption
62
+ this.outletService.getCharacteristic(this.eve.Characteristics.TotalConsumption)
63
+ .on("get" /* GET */, this.getTotalEnergyConsumption.bind(this));
64
+ if (this.enableHistory) {
65
+ // history logging services
66
+ this.eveService = (0, fakegato_history_1.default)(this.api);
67
+ this.loggingService = new this.eveService('energy', this, { storage: 'fs', log: this.log, disableRepeatLastData: true });
68
+ }
69
+ log.info(`Outlet "${name}" created!`);
70
+ }
71
+ /**
72
+ * Adds new power entry to series array of power values.
73
+ * @param {number} powerConsumption Power value to add (in Watts).
74
+ */
75
+ addPowerEntry(powerConsumption) {
76
+ // check if we reached the limit
77
+ if (this.powerSeries.length === MAX_POWER_SERIES_SIZE) {
78
+ // remove first element
79
+ this.powerSeries.shift();
80
+ }
81
+ // add new element
82
+ this.powerSeries.push(powerConsumption);
83
+ }
84
+ /**
85
+ * Gets array series with power consumption values.
86
+ * @returns {number[]} Array with power consumption values.
87
+ */
88
+ getPowerSeries() {
89
+ return this.powerSeries;
90
+ }
91
+ /**
92
+ * Get outlet power from power series by smoothing data using the desired method and window size.
93
+ * @param {string} method Method to smooth data ('SMA' or 'EMA').
94
+ * @param {number} windowSize Window size for SMA or EMA.
95
+ * @returns {number} Power value after smoothing (rounded to nearest integer number).
96
+ */
97
+ getSmoothPowerConsumption(method, windowSize) {
98
+ this.log.debug(`${this.name}: GET Power Smooth (method=${method}, window=${windowSize})`);
99
+ let result = 0;
100
+ // get power series for window size
101
+ const series = this.getPowerSeries().slice(-windowSize);
102
+ // calculate simple moving average from given window size
103
+ const [sma] = statistics_1.Statistics.simpleMovingAverage(series, Math.min(windowSize, series.length));
104
+ // check if we have enough data for averaging
105
+ switch (method) {
106
+ case 'sma':
107
+ result = sma;
108
+ this.log.debug(`${this.name}: simple moving average (window data=[${series}], power=${result}W)`);
109
+ break;
110
+ case 'ema':
111
+ if (series.length < windowSize) {
112
+ result = sma;
113
+ this.log.debug(`${this.name}: exponential moving average (window data=[${series}], last EMA=none, power=${result}W)`);
114
+ }
115
+ else {
116
+ const lastPowerValue = series[series.length - 1];
117
+ const weight = 2 / (windowSize + 1);
118
+ result = (lastPowerValue - this.lastEMA) * weight + this.lastEMA;
119
+ this.log.debug(`${this.name}: exponential moving average (window data=[${series}], last EMA=${this.lastEMA}, power=${result}W)`);
120
+ }
121
+ this.lastEMA = result;
122
+ }
123
+ return result;
124
+ }
125
+ /**
126
+ * Gets the current power consumption value for this outlet.
127
+ * @returns {number} Outlet power consumption (Watt).
128
+ */
129
+ getPowerConsumptionValue() {
130
+ return this.powerConsumption;
131
+ }
132
+ /**
133
+ * Gets the current power consumpion.
134
+ */
135
+ getPowerConsumption(callback) {
136
+ this.log.debug(`${this.name}: GET Power (power=${this.powerConsumption}W)`);
137
+ callback(null, this.powerConsumption);
138
+ }
139
+ /**
140
+ * Sets the current power consumption.
141
+ * @param {number} powerConsumption The power consumption to set. */
142
+ setPowerConsumption(powerConsumption) {
143
+ this.log.debug(`${this.name}: SET Power (power=${powerConsumption}W)`);
144
+ this.powerConsumption = powerConsumption >= 0 ? powerConsumption : 0;
145
+ this.outletService.getCharacteristic(this.eve.Characteristics.CurrentConsumption).updateValue(this.powerConsumption);
146
+ if (this.loggingService) {
147
+ // add entries to history
148
+ this.loggingService.addEntry({ time: Math.round(new Date().valueOf() / 1000), power: this.powerConsumption });
149
+ }
150
+ // add new value to power series
151
+ this.addPowerEntry(this.powerConsumption);
152
+ }
153
+ /**
154
+ * Gets the total energy consumption value for this outlet.
155
+ * @returns {number} Outlet total energy consumption (Wh).
156
+ */
157
+ getTotalEnergyConsumptionValue() {
158
+ return this.totalEnergyConsumption;
159
+ }
160
+ /**
161
+ * Gets the total energy consumpion.
162
+ */
163
+ getTotalEnergyConsumption(callback) {
164
+ this.log.debug(`${this.name}: GET Total Energy (energy=${this.totalEnergyConsumption}kWh)`);
165
+ callback(null, this.totalEnergyConsumption);
166
+ }
167
+ /**
168
+ * Sets the total energy consumption.
169
+ * @param {number} totalEnergyConsumption The total energy consumption to set.
170
+ */
171
+ setTotalEnergyConsumption(totalEnergyConsumption) {
172
+ this.log.debug(`${this.name}: SET Total Energy (energy=${totalEnergyConsumption}kWh)`);
173
+ this.totalEnergyConsumption = totalEnergyConsumption;
174
+ this.outletService.getCharacteristic(this.eve.Characteristics.TotalConsumption).updateValue(this.totalEnergyConsumption);
175
+ }
176
+ /**
177
+ * Gets the outlet state Characteristic based on its consumed power.
178
+ * @param {CharacteristicGetCallback} callback The callback.
179
+ */
180
+ getState(callback) {
181
+ this.log.debug(`${this.name}: GET State (power=${this.powerConsumption}W)`);
182
+ callback(null, this.powerConsumption > 0);
183
+ }
184
+ /*
185
+ * This method is called directly after creation of this instance.
186
+ * It should return all services which should be added to the accessory.
187
+ */
188
+ getServices() {
189
+ const services = [this.informationService, this.outletService];
190
+ if (this.loggingService) {
191
+ services.push(this.loggingService);
192
+ }
193
+ return services;
194
+ }
195
+ }
196
+ exports.SolaxOutletAccessory = SolaxOutletAccessory;
188
197
  //# sourceMappingURL=outletAccessory.js.map
@@ -1 +1 @@
1
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