homebridge-enphase-envoy 10.3.0-beta.2 → 10.3.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -2
- package/index.js +3 -3
- package/package.json +1 -1
- package/src/envoydevice.js +226 -233
package/CHANGELOG.md
CHANGED
|
@@ -13,9 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
13
13
|
|
|
14
14
|
## Changes
|
|
15
15
|
|
|
16
|
-
-
|
|
16
|
+
- extend Eve Energy Meter to support (Production, Consumption Net, Consumption Total)
|
|
17
|
+
- fix [#218](https://github.com/grzegorz914/homebridge-enphase-envoy/issues/218)
|
|
17
18
|
- stability and performance improvements
|
|
18
|
-
- config
|
|
19
|
+
- config schema updated
|
|
19
20
|
- readme updated
|
|
20
21
|
- cleanup
|
|
21
22
|
|
package/index.js
CHANGED
|
@@ -103,9 +103,9 @@ class EnvoyPlatform {
|
|
|
103
103
|
.on('warn', (msg) => logLevel.warn && log.warn(`Device: ${host} ${deviceName}, ${msg}`))
|
|
104
104
|
.on('error', (msg) => logLevel.error && log.error(`Device: ${host} ${deviceName}, ${msg}`));
|
|
105
105
|
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
108
|
-
api.publishExternalAccessories(PluginName,
|
|
106
|
+
const accessories = await envoyDevice.start();
|
|
107
|
+
if (accessories) {
|
|
108
|
+
api.publishExternalAccessories(PluginName, accessories);
|
|
109
109
|
if (logLevel.success) log.success(`Device: ${host} ${deviceName}, Published as external accessory.`);
|
|
110
110
|
|
|
111
111
|
await impulseGenerator.state(false);
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"private": false,
|
|
3
3
|
"displayName": "Enphase Envoy",
|
|
4
4
|
"name": "homebridge-enphase-envoy",
|
|
5
|
-
"version": "10.3.0-beta.
|
|
5
|
+
"version": "10.3.0-beta.4",
|
|
6
6
|
"description": "Homebridge p7ugin for Photovoltaic Energy System manufactured by Enphase.",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"author": "grzegorz914",
|
package/src/envoydevice.js
CHANGED
|
@@ -55,8 +55,8 @@ class EnvoyDevice extends EventEmitter {
|
|
|
55
55
|
|
|
56
56
|
//ac battery
|
|
57
57
|
this.acBatterieName = device.acBatterieName || 'AC Batterie';
|
|
58
|
-
this.
|
|
59
|
-
this.
|
|
58
|
+
this.acBatterieBackupLevelSummaryControl = device.acBatterieBackupLevelSummaryAccessory || {};
|
|
59
|
+
this.acBatterieBackupLevelControl = device.acBatterieBackupLevelAccessory || {};
|
|
60
60
|
|
|
61
61
|
//enpower
|
|
62
62
|
this.enpowerDryContactsControl = device.envoyFirmware7xxTokenGenerationMode > 0 ? (device.enpowerDryContactsControl || false) : false;
|
|
@@ -67,9 +67,9 @@ class EnvoyDevice extends EventEmitter {
|
|
|
67
67
|
|
|
68
68
|
//encharge
|
|
69
69
|
this.enchargeName = device.enchargeName || 'Encharge';
|
|
70
|
-
this.
|
|
70
|
+
this.enchargeBackupLevelSummaryControl = device.envoyFirmware7xxTokenGenerationMode > 0 ? (device.enchargeBackupLevelSummaryAccessory || {}) : {};
|
|
71
71
|
this.enchargeBackupLevelSummarySensors = device.envoyFirmware7xxTokenGenerationMode > 0 ? (device.enchargeBackupLevelSummarySensors || []).filter(sensor => (sensor.displayType ?? 0) > 0) : [];
|
|
72
|
-
this.
|
|
72
|
+
this.enchargeBackupLevelControl = device.envoyFirmware7xxTokenGenerationMode > 0 ? (device.enchargeBackupLevelAccessory || {}) : {};
|
|
73
73
|
this.enchargeStateSensor = device.envoyFirmware7xxTokenGenerationMode > 0 ? (device.enchargeStateSensor || {}) : {};
|
|
74
74
|
this.enchargeProfileControls = device.envoyFirmware7xxTokenGenerationMode > 0 ? (device.enchargeProfileControls || []).filter(control => (control.displayType ?? 0) > 0) : [];
|
|
75
75
|
this.enchargeProfileSensors = device.envoyFirmware7xxTokenGenerationMode > 0 ? (device.enchargeProfileSensors || []).filter(sensor => (sensor.displayType ?? 0) > 0) : [];
|
|
@@ -123,18 +123,18 @@ class EnvoyDevice extends EventEmitter {
|
|
|
123
123
|
|
|
124
124
|
//plc level check control
|
|
125
125
|
if (this.plcLevelCheckControl.displayType > 0) {
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
126
|
+
const control = this.plcLevelCheckControl;
|
|
127
|
+
control.serviceType = [null, Service.Switch, Service.Outlet, Service.Lightbulb][control.displayType];
|
|
128
|
+
control.characteristicType = [null, Characteristic.On, Characteristic.On, Characteristic.On][control.displayType];
|
|
129
|
+
control.state = false;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
//data sampling control
|
|
133
133
|
if (this.dataSamplingControl.displayType > 0) {
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
134
|
+
const control = this.dataSamplingControl;
|
|
135
|
+
control.serviceType = [null, Service.Switch, Service.Outlet, Service.Lightbulb][control.displayType];
|
|
136
|
+
control.characteristicType = [null, Characteristic.On, Characteristic.On, Characteristic.On][control.displayType];
|
|
137
|
+
control.state = false;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
//data sampling sensor
|
|
@@ -215,32 +215,32 @@ class EnvoyDevice extends EventEmitter {
|
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
//ac battery
|
|
218
|
-
if (this.
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
218
|
+
if (this.acBatterieBackupLevelSummaryControl.displayType > 0) {
|
|
219
|
+
const control = this.acBatterieBackupLevelSummaryControl;
|
|
220
|
+
control.serviceType = [null, Service.Lightbulb, Service.Fan, Service.HumiditySensor, Service.CarbonMonoxideSensor, Service.Battery][control.displayType];
|
|
221
|
+
control.characteristicType = [null, Characteristic.On, Characteristic.On, Characteristic.StatusActive, Characteristic.CarbonMonoxideDetected, Characteristic.StatusLowBattery][control.displayType];
|
|
222
|
+
control.characteristicType1 = [null, Characteristic.Brightness, Characteristic.RotationSpeed, Characteristic.CurrentRelativeHumidity, Characteristic.CarbonMonoxideLevel, Characteristic.BatteryLevel][control.displayType];
|
|
223
|
+
control.state = false;
|
|
224
|
+
control.backupLevel = 0;
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
if (this.
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
227
|
+
if (this.acBatterieBackupLevelControl.displayType > 0) {
|
|
228
|
+
const control = this.acBatterieBackupLevelControl;
|
|
229
|
+
control.serviceType = [null, Service.Battery][control.displayType];
|
|
230
|
+
control.characteristicType = [null, Characteristic.StatusLowBattery][control.displayType];
|
|
231
|
+
control.characteristicType1 = [null, Characteristic.BatteryLevel][control.displayType];
|
|
232
|
+
control.characteristicType2 = [null, Characteristic.ChargingState][control.displayType];
|
|
233
|
+
control.state = false;
|
|
234
|
+
control.backupLevel = 0;
|
|
235
|
+
control.chargeState = 0;
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
//enpower
|
|
239
239
|
if (this.enpowerGridStateControl.displayType > 0) {
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
240
|
+
const control = this.enpowerGridStateControl;
|
|
241
|
+
control.serviceType = [null, Service.Switch, Service.Outlet, Service.Lightbulb][control.displaqyType];
|
|
242
|
+
control.characteristicType = [null, Characteristic.On, Characteristic.On, Characteristic.On][control.displaqyType];
|
|
243
|
+
control.state = false;
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
if (this.enpowerGridStateSensor.displayType > 0) {
|
|
@@ -257,13 +257,13 @@ class EnvoyDevice extends EventEmitter {
|
|
|
257
257
|
}
|
|
258
258
|
|
|
259
259
|
//encharge
|
|
260
|
-
if (this.
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
260
|
+
if (this.enchargeBackupLevelSummaryControl.displayType > 0) {
|
|
261
|
+
const control = this.enchargeBackupLevelSummaryControl;
|
|
262
|
+
control.serviceType = [null, Service.Lightbulb, Service.Fan, Service.HumiditySensor, Service.CarbonMonoxideSensor, Service.Battery][control.displayType];
|
|
263
|
+
control.characteristicType = [null, Characteristic.On, Characteristic.On, Characteristic.StatusActive, Characteristic.CarbonMonoxideDetected, Characteristic.StatusLowBattery][control.displayType];
|
|
264
|
+
control.characteristicType1 = [null, Characteristic.Brightness, Characteristic.RotationSpeed, Characteristic.CurrentRelativeHumidity, Characteristic.CarbonMonoxideLevel, Characteristic.BatteryLevel][control.displayType];
|
|
265
|
+
control.state = false;
|
|
266
|
+
control.backupLevel = 0;
|
|
267
267
|
}
|
|
268
268
|
|
|
269
269
|
for (const sensor of this.enchargeBackupLevelSummarySensors) {
|
|
@@ -272,15 +272,15 @@ class EnvoyDevice extends EventEmitter {
|
|
|
272
272
|
sensor.state = false;
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
-
if (this.
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
275
|
+
if (this.enchargeBackupLevelControl.displayType > 0) {
|
|
276
|
+
const control = this.enchargeBackupLevelControl;
|
|
277
|
+
control.serviceType = [null, Service.Battery][control.displayType];
|
|
278
|
+
control.characteristicType1 = [null, Characteristic.StatusLowBattery][control.displayType];
|
|
279
|
+
control.characteristicType = [null, Characteristic.BatteryLevel][control.displayType];
|
|
280
|
+
control.characteristicType2 = [null, Characteristic.ChargingState][control.displayType];
|
|
281
|
+
control.state = false;
|
|
282
|
+
control.backupLevel = 0;
|
|
283
|
+
control.chargeState = 0;
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
if (this.enchargeStateSensor.displayType > 0) {
|
|
@@ -290,12 +290,12 @@ class EnvoyDevice extends EventEmitter {
|
|
|
290
290
|
sensor.state = false;
|
|
291
291
|
}
|
|
292
292
|
|
|
293
|
-
for (const
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
293
|
+
for (const control of this.enchargeProfileControls) {
|
|
294
|
+
control.serviceType = [null, Service.Lightbulb][control.displayType];
|
|
295
|
+
control.characteristicType = [null, Characteristic.On][control.displayType];
|
|
296
|
+
control.state = false;
|
|
297
|
+
control.reservedSoc = 0;
|
|
298
|
+
control.previousState = null;
|
|
299
299
|
}
|
|
300
300
|
|
|
301
301
|
for (const sensor of this.enchargeProfileSensors) {
|
|
@@ -333,10 +333,10 @@ class EnvoyDevice extends EventEmitter {
|
|
|
333
333
|
|
|
334
334
|
//generator
|
|
335
335
|
if (this.generatorStateControl.displayType > 0) {
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
336
|
+
const control = this.generatorStateControl;
|
|
337
|
+
control.serviceType = [null, Service.Switch, Service.Outlet, Service.Lightbulb][control.displaqyType];
|
|
338
|
+
control.characteristicType = [null, Characteristic.On, Characteristic.On, Characteristic.On][control.displaqyType];
|
|
339
|
+
control.state = false;
|
|
340
340
|
}
|
|
341
341
|
|
|
342
342
|
if (this.generatorStateSensor.displayType > 0) {
|
|
@@ -346,11 +346,11 @@ class EnvoyDevice extends EventEmitter {
|
|
|
346
346
|
sensor.state = false;
|
|
347
347
|
}
|
|
348
348
|
|
|
349
|
-
for (const
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
349
|
+
for (const control of this.generatorModeContols) {
|
|
350
|
+
control.serviceType = [null, Service.Switch, Service.Outlet, Service.Lightbulb][control.displayType];
|
|
351
|
+
control.characteristicType = [null, Characteristic.On, Characteristic.On, Characteristic.On][control.displayType];
|
|
352
|
+
control.state = false;
|
|
353
|
+
control.previousState = null;
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
for (const sensor of this.generatorModeSensors) {
|
|
@@ -786,7 +786,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
786
786
|
const devices = this.energyMeter ? 2 : 1;
|
|
787
787
|
for (let i = 0; i < devices; i++) {
|
|
788
788
|
switch (i) {
|
|
789
|
-
case 0
|
|
789
|
+
case 0: //PV System
|
|
790
790
|
const envoySerialNumber = this.pv.info.serialNumber;
|
|
791
791
|
const accessoryName = this.name;
|
|
792
792
|
|
|
@@ -1501,10 +1501,10 @@ class EnvoyDevice extends EventEmitter {
|
|
|
1501
1501
|
if (acbsSupported) {
|
|
1502
1502
|
|
|
1503
1503
|
// --- AC Battery Backup Level and State Summary Service ---
|
|
1504
|
-
if (this.
|
|
1504
|
+
if (this.acBatterieBackupLevelSummaryControl.displayType > 0) {
|
|
1505
1505
|
if (this.logDebug) this.emit('debug', `Prepare ${acBatterieName} Backup Level Summary Service`);
|
|
1506
1506
|
|
|
1507
|
-
const control = this.
|
|
1507
|
+
const control = this.acBatterieBackupLevelSummaryControl;
|
|
1508
1508
|
const { namePrefix, serviceType, characteristicType, characteristicType1 } = control;
|
|
1509
1509
|
const serviceName = namePrefix ? `${accessoryName} ${acBatterieName}` : acBatterieName;
|
|
1510
1510
|
|
|
@@ -1571,10 +1571,10 @@ class EnvoyDevice extends EventEmitter {
|
|
|
1571
1571
|
const serialNumber = storage.serialNumber;
|
|
1572
1572
|
|
|
1573
1573
|
// Backup Level and State individual service
|
|
1574
|
-
if (this.
|
|
1574
|
+
if (this.acBatterieBackupLevelControl.displayType > 0) {
|
|
1575
1575
|
if (this.logDebug) this.emit('debug', `Prepare ${acBatterieName} Backup Level Summary Service`);
|
|
1576
1576
|
|
|
1577
|
-
const control = this.
|
|
1577
|
+
const control = this.acBatterieBackupLevelControl;
|
|
1578
1578
|
const { namePrefix, serviceType, characteristicType, characteristicType1, characteristicType2 } = control;
|
|
1579
1579
|
const serviceName = namePrefix ? `${accessoryName} ${acBatterieName}` : acBatterieName;
|
|
1580
1580
|
|
|
@@ -1731,6 +1731,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
1731
1731
|
//power level sensors
|
|
1732
1732
|
if (this.powerProductionLevelSensors.length > 0) {
|
|
1733
1733
|
if (this.logDebug) this.emit('debug', `Prepare Production Power Level Sensor Services`);
|
|
1734
|
+
|
|
1734
1735
|
this.powerProductionLevelSensorServices = [];
|
|
1735
1736
|
for (let i = 0; i < this.powerProductionLevelSensors.length; i++) {
|
|
1736
1737
|
const sensor = this.powerProductionLevelSensors[i];
|
|
@@ -1752,6 +1753,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
1752
1753
|
//energy level sensors
|
|
1753
1754
|
if (this.energyProductionLevelSensors.length > 0) {
|
|
1754
1755
|
if (this.logDebug) this.emit('debug', `Prepare Production Energy Level Sensor Services`);
|
|
1756
|
+
|
|
1755
1757
|
this.energyProductionLevelSensorServices = [];
|
|
1756
1758
|
for (let i = 0; i < this.energyProductionLevelSensors.length; i++) {
|
|
1757
1759
|
const sensor = this.energyProductionLevelSensors[i];
|
|
@@ -1773,6 +1775,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
1773
1775
|
//grid quality sensors
|
|
1774
1776
|
if (this.gridProductionQualitySensors.length > 0 && source.gridQualityState) {
|
|
1775
1777
|
if (this.logDebug) this.emit('debug', `Prepare Grid Quality Sensor Services`);
|
|
1778
|
+
|
|
1776
1779
|
this.gridProductionQualityActiveSensorServices = [];
|
|
1777
1780
|
for (let i = 0; i < this.gridProductionQualitySensors.length; i++) {
|
|
1778
1781
|
const sensor = this.gridProductionQualitySensors[i];
|
|
@@ -1795,6 +1798,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
1795
1798
|
//power level sensors
|
|
1796
1799
|
if (this.powerConsumptionNetLevelSensors.length > 0) {
|
|
1797
1800
|
if (this.logDebug) this.emit('debug', `Prepare ${measurementType} Power Level Sensor Services`);
|
|
1801
|
+
|
|
1798
1802
|
this.powerConsumptionNetLevelSensorServices = [];
|
|
1799
1803
|
for (let i = 0; i < this.powerConsumptionNetLevelSensors.length; i++) {
|
|
1800
1804
|
const sensor = this.powerConsumptionNetLevelSensors[i];
|
|
@@ -1816,6 +1820,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
1816
1820
|
//energy level sensors
|
|
1817
1821
|
if (this.energyConsumptionNetLevelSensors.length > 0) {
|
|
1818
1822
|
if (this.logDebug) this.emit('debug', `Prepare ${measurementType} Energy Level Sensor Services`);
|
|
1823
|
+
|
|
1819
1824
|
this.energyConsumptionNetLevelSensorServices = [];
|
|
1820
1825
|
for (let i = 0; i < this.energyConsumptionNetLevelSensors.length; i++) {
|
|
1821
1826
|
const sensor = this.energyConsumptionNetLevelSensors[i];
|
|
@@ -1837,6 +1842,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
1837
1842
|
//grid quality sensors
|
|
1838
1843
|
if (this.gridConsumptionNetQualitySensors.length > 0) {
|
|
1839
1844
|
if (this.logDebug) this.emit('debug', `Prepare Grid Quality Sensor Services`);
|
|
1845
|
+
|
|
1840
1846
|
this.gridConsumptionNetQualityActiveSensorServices = [];
|
|
1841
1847
|
for (let i = 0; i < this.gridConsumptionNetQualitySensors.length; i++) {
|
|
1842
1848
|
const sensor = this.gridConsumptionNetQualitySensors[i];
|
|
@@ -1859,6 +1865,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
1859
1865
|
//power level sensors
|
|
1860
1866
|
if (this.powerConsumptionTotalLevelSensors.length > 0) {
|
|
1861
1867
|
if (this.logDebug) this.emit('debug', `Prepare ${measurementType} Power Level Sensor Services`);
|
|
1868
|
+
|
|
1862
1869
|
this.powerConsumptionTotalLevelSensorServices = [];
|
|
1863
1870
|
for (let i = 0; i < this.powerConsumptionTotalLevelSensors.length; i++) {
|
|
1864
1871
|
const sensor = this.powerConsumptionTotalLevelSensors[i];
|
|
@@ -1880,6 +1887,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
1880
1887
|
//energy level sensors
|
|
1881
1888
|
if (this.energyConsumptionTotalLevelSensors.length > 0) {
|
|
1882
1889
|
if (this.logDebug) this.emit('debug', `Prepare ${measurementType} Energy Level Sensor Services`);
|
|
1890
|
+
|
|
1883
1891
|
this.energyConsumptionTotalLevelSensorServices = [];
|
|
1884
1892
|
for (let i = 0; i < this.energyConsumptionTotalLevelSensors.length; i++) {
|
|
1885
1893
|
const sensor = this.energyConsumptionTotalLevelSensors[i];
|
|
@@ -1901,6 +1909,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
1901
1909
|
//grid quality sensors
|
|
1902
1910
|
if (this.gridConsumptionTotalQualitySensors.length > 0) {
|
|
1903
1911
|
if (this.logDebug) this.emit('debug', `Prepare Grid Quality Sensor Services`);
|
|
1912
|
+
|
|
1904
1913
|
this.gridConsumptionTotalQualityActiveSensorServices = [];
|
|
1905
1914
|
for (let i = 0; i < this.gridConsumptionTotalQualitySensors.length; i++) {
|
|
1906
1915
|
const sensor = this.gridConsumptionTotalQualitySensors[i];
|
|
@@ -2093,14 +2102,14 @@ class EnvoyDevice extends EventEmitter {
|
|
|
2093
2102
|
if (enchargesInstalled) {
|
|
2094
2103
|
|
|
2095
2104
|
//backup level and state summary control
|
|
2096
|
-
if (this.
|
|
2105
|
+
if (this.enchargeBackupLevelSummaryControl.displayType > 0) {
|
|
2097
2106
|
if (this.logDebug) this.emit('debug', `Prepare ${enchargeName} Backup Level Summary Service`);
|
|
2098
2107
|
|
|
2099
|
-
const control = this.
|
|
2108
|
+
const control = this.enchargeBackupLevelSummaryControl;
|
|
2100
2109
|
const { namePrefix, serviceType, characteristicType, characteristicType1 } = control;
|
|
2101
2110
|
const serviceName = namePrefix ? `${accessoryName} ${enchargeName}` : enchargeName;
|
|
2102
2111
|
|
|
2103
|
-
const controlService = accessory.addService(serviceType, serviceName, `
|
|
2112
|
+
const controlService = accessory.addService(serviceType, serviceName, `enchargeBackupLevelSummaryControlService`);
|
|
2104
2113
|
controlService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
2105
2114
|
controlService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
2106
2115
|
controlService.getCharacteristic(characteristicType)
|
|
@@ -2142,14 +2151,14 @@ class EnvoyDevice extends EventEmitter {
|
|
|
2142
2151
|
}
|
|
2143
2152
|
});
|
|
2144
2153
|
|
|
2145
|
-
this.
|
|
2154
|
+
this.enchargeBackupLevelSummaryControlService = controlService;
|
|
2146
2155
|
}
|
|
2147
2156
|
|
|
2148
2157
|
//backup level summary sensors
|
|
2149
2158
|
if (this.enchargeBackupLevelSummarySensors.length > 0) {
|
|
2150
2159
|
if (this.logDebug) this.emit('debug', `Prepare ${enchargeName} Backup Level Sensor Services`);
|
|
2151
2160
|
|
|
2152
|
-
this.
|
|
2161
|
+
this.enchargeBackupLevelSummarySensorsServices = [];
|
|
2153
2162
|
for (let i = 0; i < this.enchargeBackupLevelSummarySensors.length; i++) {
|
|
2154
2163
|
const sensor = this.enchargeBackupLevelSummarySensors[i];
|
|
2155
2164
|
const { namePrefix, name, serviceType, characteristicType } = sensor;
|
|
@@ -2165,22 +2174,22 @@ class EnvoyDevice extends EventEmitter {
|
|
|
2165
2174
|
return currentState;
|
|
2166
2175
|
});
|
|
2167
2176
|
|
|
2168
|
-
this.
|
|
2177
|
+
this.enchargeBackupLevelSummarySensorsServices.push(sensorService);
|
|
2169
2178
|
}
|
|
2170
2179
|
}
|
|
2171
2180
|
|
|
2172
2181
|
//devices
|
|
2173
2182
|
this.enchargeServices = [];
|
|
2174
|
-
this.
|
|
2183
|
+
this.enchargeBackupLevelControlServices = [];
|
|
2175
2184
|
|
|
2176
2185
|
for (const encharge of this.pv.inventoryData.esubs.encharges.devices) {
|
|
2177
2186
|
const serialNumber = encharge.serialNumber;
|
|
2178
2187
|
|
|
2179
2188
|
// Backup level and state (individual)
|
|
2180
|
-
if (this.
|
|
2189
|
+
if (this.enchargeBackupLevelControl.displayType > 0) {
|
|
2181
2190
|
if (this.logDebug) this.emit('debug', `Prepare ${enchargeName} ${serialNumber} Backup Level Service`);
|
|
2182
2191
|
|
|
2183
|
-
const control = this.
|
|
2192
|
+
const control = this.enchargeBackupLevelControl;
|
|
2184
2193
|
const { namePrefix, serviceType, characteristicType, characteristicType1, characteristicType2 } = control;
|
|
2185
2194
|
const serviceName = namePrefix ? `${accessoryName} ${enchargeName}` : enchargeName;
|
|
2186
2195
|
|
|
@@ -2222,7 +2231,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
2222
2231
|
return currentChargeState;
|
|
2223
2232
|
});
|
|
2224
2233
|
|
|
2225
|
-
this.
|
|
2234
|
+
this.enchargeBackupLevelControlServices.push(controlService);
|
|
2226
2235
|
}
|
|
2227
2236
|
|
|
2228
2237
|
if (this.logDebug) this.emit('debug', `Prepare ${enchargeName} ${serialNumber} Service`);
|
|
@@ -2438,8 +2447,8 @@ class EnvoyDevice extends EventEmitter {
|
|
|
2438
2447
|
//encharge grid mode sensor services
|
|
2439
2448
|
if (this.enchargeGridModeSensors.length > 0) {
|
|
2440
2449
|
if (this.logDebug) this.emit('debug', `Prepare ${enchargeName} Grid Mode Sensor Services`);
|
|
2441
|
-
this.enchargeGridModeSensorServices = [];
|
|
2442
2450
|
|
|
2451
|
+
this.enchargeGridModeSensorServices = [];
|
|
2443
2452
|
for (let i = 0; i < this.enchargeGridModeSensors.length; i++) {
|
|
2444
2453
|
const sensor = this.enchargeGridModeSensors[i];
|
|
2445
2454
|
const { namePrefix, name, serviceType, characteristicType, state } = sensor;
|
|
@@ -2644,8 +2653,8 @@ class EnvoyDevice extends EventEmitter {
|
|
|
2644
2653
|
// Grid mode sensors
|
|
2645
2654
|
if (this.enpowerGridModeSensors.length > 0) {
|
|
2646
2655
|
if (this.logDebug) this.emit('debug', `Prepare Enpower ${serialNumber} Grid Mode Sensor Services`);
|
|
2647
|
-
const enpowerGridModeSensorServices = [];
|
|
2648
2656
|
|
|
2657
|
+
const enpowerGridModeSensorServices = [];
|
|
2649
2658
|
for (let i = 0; i < this.enpowerGridModeSensors.length; i++) {
|
|
2650
2659
|
const sensor = this.enpowerGridModeSensors[i];
|
|
2651
2660
|
const { namePrefix, name, serviceType, characteristicType, state } = sensor;
|
|
@@ -2883,7 +2892,6 @@ class EnvoyDevice extends EventEmitter {
|
|
|
2883
2892
|
if (this.logDebug) this.emit('debug', `Prepare Generator ${type} Mode Control Services`);
|
|
2884
2893
|
|
|
2885
2894
|
this.generatorModeControlServices = [];
|
|
2886
|
-
|
|
2887
2895
|
for (let i = 0; i < this.generatorModeContols.length; i++) {
|
|
2888
2896
|
const control = this.generatorModeContols[i];
|
|
2889
2897
|
const { namePrefix, name, serviceType, characteristicType } = control;
|
|
@@ -2930,7 +2938,6 @@ class EnvoyDevice extends EventEmitter {
|
|
|
2930
2938
|
if (this.logDebug) this.emit('debug', `Prepare Generator ${type} Mode Sensor Services`);
|
|
2931
2939
|
|
|
2932
2940
|
this.generatorModeSensorServices = [];
|
|
2933
|
-
|
|
2934
2941
|
for (let i = 0; i < this.generatorModeSensors.length; i++) {
|
|
2935
2942
|
const sensor = this.generatorModeSensors[i];
|
|
2936
2943
|
const { namePrefix, name, serviceType, characteristicType } = sensor;
|
|
@@ -2995,7 +3002,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
2995
3002
|
|
|
2996
3003
|
accessories.push(accessory);
|
|
2997
3004
|
break;
|
|
2998
|
-
case 1: //Energy Meter
|
|
3005
|
+
case 1: //EVE Energy Meter
|
|
2999
3006
|
this.fakegatoHistoryServices = [];
|
|
3000
3007
|
this.energyMeterServices = [];
|
|
3001
3008
|
for (const source of this.pv.powerAndEnergyData.data) {
|
|
@@ -3761,10 +3768,10 @@ class EnvoyDevice extends EventEmitter {
|
|
|
3761
3768
|
plcLevel: acb.plcLevel
|
|
3762
3769
|
};
|
|
3763
3770
|
|
|
3764
|
-
// Update storage backup
|
|
3765
|
-
if (this.
|
|
3766
|
-
const
|
|
3767
|
-
const { minSoc, characteristicType, characteristicType1, characteristicType2 } =
|
|
3771
|
+
// Update storage backup control level and state
|
|
3772
|
+
if (this.acBatterieBackupLevelControl.displayType > 0) {
|
|
3773
|
+
const control = this.acBatterieBackupLevelControl;
|
|
3774
|
+
const { minSoc, characteristicType, characteristicType1, characteristicType2 } = control;
|
|
3768
3775
|
|
|
3769
3776
|
// Create characteristics
|
|
3770
3777
|
const characteristics = [
|
|
@@ -3776,7 +3783,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
3776
3783
|
// Update acbs services
|
|
3777
3784
|
for (const { type, value, valueKey } of characteristics) {
|
|
3778
3785
|
if (!this.functions.isValidValue(value)) continue;
|
|
3779
|
-
|
|
3786
|
+
control[valueKey] = value;
|
|
3780
3787
|
this.acbLevelAndStateServices?.[index]?.updateCharacteristic(type, value);
|
|
3781
3788
|
}
|
|
3782
3789
|
}
|
|
@@ -3847,16 +3854,16 @@ class EnvoyDevice extends EventEmitter {
|
|
|
3847
3854
|
this.acbSummaryService?.updateCharacteristic(type, value);
|
|
3848
3855
|
}
|
|
3849
3856
|
|
|
3850
|
-
// Updatestorage backup summary
|
|
3851
|
-
if (this.
|
|
3857
|
+
// Updatestorage backup summary control level and state
|
|
3858
|
+
if (this.acBatterieBackupLevelSummaryControl.displayType > 0 && (!this.feature.liveData.supported || !this.feature.meters.storage.enabled)) {
|
|
3852
3859
|
|
|
3853
3860
|
if (this.logInfo) {
|
|
3854
3861
|
this.emit('info', `Acb Data, ${this.acBatterieName}, backup energy: ${acbData.energySumKw} kW`);
|
|
3855
3862
|
this.emit('info', `Acb Data, ${this.acBatterieName}, backup level: ${percentFullSum} %`);
|
|
3856
3863
|
}
|
|
3857
3864
|
|
|
3858
|
-
const
|
|
3859
|
-
const { minSoc, displayType, characteristicType, characteristicType1 } =
|
|
3865
|
+
const control = this.acBatterieBackupLevelSummaryControl;
|
|
3866
|
+
const { minSoc, displayType, characteristicType, characteristicType1 } = control;
|
|
3860
3867
|
const isServiceBattery = displayType === 5;
|
|
3861
3868
|
const isAboveMinSoc = percentFullSum > minSoc;
|
|
3862
3869
|
const backupLevel = isAboveMinSoc ? percentFullSum : 0;
|
|
@@ -3871,7 +3878,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
3871
3878
|
// Update storage summary services
|
|
3872
3879
|
for (const { type, value, valueKey } of characteristics) {
|
|
3873
3880
|
if (!this.functions.isValidValue(value)) continue;
|
|
3874
|
-
|
|
3881
|
+
control[valueKey] = value;
|
|
3875
3882
|
this.acbSummaryLevelAndStateService?.updateCharacteristic(type, value);
|
|
3876
3883
|
}
|
|
3877
3884
|
}
|
|
@@ -3990,7 +3997,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
3990
3997
|
this.emit('info', `Power And Energy, ${measurementType}, energy lifetime: ${obj.energyLifetimeKw} kWh`);
|
|
3991
3998
|
}
|
|
3992
3999
|
|
|
3993
|
-
// Update system
|
|
4000
|
+
// Update system control service
|
|
3994
4001
|
if (key === 'production' && (!this.feature.liveData.supported || !meterEnabled)) {
|
|
3995
4002
|
const powerLevel = this.functions.scaleValue(obj.power, 0, this.powerProductionSummary, 0, 100);
|
|
3996
4003
|
const powerState = powerLevel > 0;
|
|
@@ -4000,8 +4007,8 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4000
4007
|
this.emit('info', `Power And Energy, ${measurementType}, power state: ${powerState ? 'On' : 'Off'}`);
|
|
4001
4008
|
}
|
|
4002
4009
|
|
|
4003
|
-
const
|
|
4004
|
-
const { characteristicType, characteristicType1 } =
|
|
4010
|
+
const control = this.systemAccessory;
|
|
4011
|
+
const { characteristicType, characteristicType1 } = control;
|
|
4005
4012
|
|
|
4006
4013
|
const characteristics1 = [
|
|
4007
4014
|
{ type: characteristicType, value: powerState, valueKey: 'state' },
|
|
@@ -4012,7 +4019,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4012
4019
|
for (const { type, value, valueKey } of characteristics1) {
|
|
4013
4020
|
if (!this.functions.isValidValue(value)) continue;
|
|
4014
4021
|
this.emit('debug', `Power And Energy, ${measurementType}, power ${valueKey}: ${value}`);
|
|
4015
|
-
|
|
4022
|
+
control[valueKey] = value;
|
|
4016
4023
|
this.systemService?.updateCharacteristic(type, value);
|
|
4017
4024
|
};
|
|
4018
4025
|
}
|
|
@@ -4318,35 +4325,6 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4318
4325
|
phaseC
|
|
4319
4326
|
};
|
|
4320
4327
|
|
|
4321
|
-
if (phaseA) {
|
|
4322
|
-
Object.assign(secctrl, {
|
|
4323
|
-
freqBiasHz: secctrlData.freq_bias_hz,
|
|
4324
|
-
voltageBiasV: secctrlData.voltage_bias_v,
|
|
4325
|
-
freqBiasHzQ8: secctrlData.freq_bias_hz_q8,
|
|
4326
|
-
voltageBiasVQ5: secctrlData.voltage_bias_v_q5,
|
|
4327
|
-
});
|
|
4328
|
-
}
|
|
4329
|
-
|
|
4330
|
-
if (phaseB) {
|
|
4331
|
-
Object.assign(secctrl, {
|
|
4332
|
-
freqBiasHzPhaseB: secctrlData.freq_bias_hz_phaseb,
|
|
4333
|
-
voltageBiasVPhaseB: secctrlData.voltage_bias_v_phaseb,
|
|
4334
|
-
freqBiasHzQ8PhaseB: secctrlData.freq_bias_hz_q8_phaseb,
|
|
4335
|
-
voltageBiasVQ5PhaseB: secctrlData.voltage_bias_v_q5_phaseb
|
|
4336
|
-
});
|
|
4337
|
-
}
|
|
4338
|
-
|
|
4339
|
-
if (phaseC) {
|
|
4340
|
-
Object.assign(secctrl, {
|
|
4341
|
-
freqBiasHzPhaseC: secctrlData.freq_bias_hz_phasec,
|
|
4342
|
-
voltageBiasVPhaseC: secctrlData.voltage_bias_v_phasec,
|
|
4343
|
-
freqBiasHzQ8PhaseC: secctrlData.freq_bias_hz_q8_phasec,
|
|
4344
|
-
voltageBiasVQ5PhaseC: secctrlData.voltage_bias_v_q5_phasec
|
|
4345
|
-
});
|
|
4346
|
-
}
|
|
4347
|
-
|
|
4348
|
-
this.pv.inventoryData.esubs.secctrl = secctrl;
|
|
4349
|
-
|
|
4350
4328
|
// Add to ensemble summary characteristics
|
|
4351
4329
|
ensembleSummaryCharacteristics.push(
|
|
4352
4330
|
{ type: Characteristic.EncAggAvailEnergy, value: secctrl.encAggAvailEnergy },
|
|
@@ -4364,6 +4342,13 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4364
4342
|
}
|
|
4365
4343
|
|
|
4366
4344
|
if (phaseA) {
|
|
4345
|
+
Object.assign(secctrl, {
|
|
4346
|
+
freqBiasHz: secctrlData.freq_bias_hz,
|
|
4347
|
+
voltageBiasV: secctrlData.voltage_bias_v,
|
|
4348
|
+
freqBiasHzQ8: secctrlData.freq_bias_hz_q8,
|
|
4349
|
+
voltageBiasVQ5: secctrlData.voltage_bias_v_q5,
|
|
4350
|
+
});
|
|
4351
|
+
|
|
4367
4352
|
ensembleSummaryCharacteristics.push(
|
|
4368
4353
|
{ type: Characteristic.FrequencyBiasHz, value: secctrl.freqBiasHz },
|
|
4369
4354
|
{ type: Characteristic.VoltageBiasV, value: secctrl.voltageBiasV },
|
|
@@ -4373,6 +4358,13 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4373
4358
|
}
|
|
4374
4359
|
|
|
4375
4360
|
if (phaseB) {
|
|
4361
|
+
Object.assign(secctrl, {
|
|
4362
|
+
freqBiasHzPhaseB: secctrlData.freq_bias_hz_phaseb,
|
|
4363
|
+
voltageBiasVPhaseB: secctrlData.voltage_bias_v_phaseb,
|
|
4364
|
+
freqBiasHzQ8PhaseB: secctrlData.freq_bias_hz_q8_phaseb,
|
|
4365
|
+
voltageBiasVQ5PhaseB: secctrlData.voltage_bias_v_q5_phaseb
|
|
4366
|
+
});
|
|
4367
|
+
|
|
4376
4368
|
ensembleSummaryCharacteristics.push(
|
|
4377
4369
|
{ type: Characteristic.FrequencyBiasHzPhaseB, value: secctrl.freqBiasHzPhaseB },
|
|
4378
4370
|
{ type: Characteristic.VoltageBiasVPhaseB, value: secctrl.voltageBiasVPhaseB },
|
|
@@ -4382,6 +4374,13 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4382
4374
|
}
|
|
4383
4375
|
|
|
4384
4376
|
if (phaseC) {
|
|
4377
|
+
Object.assign(secctrl, {
|
|
4378
|
+
freqBiasHzPhaseC: secctrlData.freq_bias_hz_phasec,
|
|
4379
|
+
voltageBiasVPhaseC: secctrlData.voltage_bias_v_phasec,
|
|
4380
|
+
freqBiasHzQ8PhaseC: secctrlData.freq_bias_hz_q8_phasec,
|
|
4381
|
+
voltageBiasVQ5PhaseC: secctrlData.voltage_bias_v_q5_phasec
|
|
4382
|
+
});
|
|
4383
|
+
|
|
4385
4384
|
ensembleSummaryCharacteristics.push(
|
|
4386
4385
|
{ type: Characteristic.FrequencyBiasHzPhaseC, value: secctrl.freqBiasHzPhaseC },
|
|
4387
4386
|
{ type: Characteristic.VoltageBiasVPhaseC, value: secctrl.voltageBiasVPhaseC },
|
|
@@ -4390,7 +4389,9 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4390
4389
|
);
|
|
4391
4390
|
}
|
|
4392
4391
|
|
|
4393
|
-
|
|
4392
|
+
this.pv.inventoryData.esubs.secctrl = secctrl;
|
|
4393
|
+
|
|
4394
|
+
// Update encharge summary control
|
|
4394
4395
|
if (enchargesInstalled && (!this.feature.liveData.supported || !this.feature.meters.storage.enabled)) {
|
|
4395
4396
|
|
|
4396
4397
|
if (this.logInfo) {
|
|
@@ -4398,10 +4399,10 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4398
4399
|
this.emit('info', `Ensemble Data, ${this.enchargeName}, backup level: ${secctrl.encAggSoc} %`);
|
|
4399
4400
|
}
|
|
4400
4401
|
|
|
4401
|
-
// Update encharges summary
|
|
4402
|
-
if (this.
|
|
4403
|
-
const
|
|
4404
|
-
const { minSoc, displayType, characteristicType, characteristicType1 } =
|
|
4402
|
+
// Update encharges summary control
|
|
4403
|
+
if (this.enchargeBackupLevelSummaryControl.displayType > 0) {
|
|
4404
|
+
const control = this.enchargeBackupLevelSummaryControl;
|
|
4405
|
+
const { minSoc, displayType, characteristicType, characteristicType1 } = control;
|
|
4405
4406
|
const serviceBattery = displayType === 5;
|
|
4406
4407
|
const backupLevel = secctrl.encAggSoc > minSoc ? secctrl.encAggSoc : 0;
|
|
4407
4408
|
const state = serviceBattery ? backupLevel < minSoc : backupLevel > minSoc;
|
|
@@ -4415,29 +4416,27 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4415
4416
|
// Update storage summary services
|
|
4416
4417
|
for (const { type, value, valueKey } of characteristics) {
|
|
4417
4418
|
if (!this.functions.isValidValue(value)) continue;
|
|
4418
|
-
|
|
4419
|
-
this.
|
|
4419
|
+
control[valueKey] = value;
|
|
4420
|
+
this.enchargeBackupLevelSummaryControlService?.updateCharacteristic(type, value);
|
|
4420
4421
|
}
|
|
4421
4422
|
}
|
|
4422
4423
|
|
|
4423
4424
|
// Update encharge summary backup level sensors
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
const state = this.functions.evaluateCompareMode(secctrl.encAggSoc, backupLevel, compareMode);
|
|
4425
|
+
for (let i = 0; i < this.enchargeBackupLevelSummarySensors.length; i++) {
|
|
4426
|
+
const sensor = this.enchargeBackupLevelSummarySensors[i];
|
|
4427
|
+
const { backupLevel, compareMode, characteristicType } = sensor;
|
|
4428
|
+
const state = this.functions.evaluateCompareMode(secctrl.encAggSoc, backupLevel, compareMode);
|
|
4429
4429
|
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4430
|
+
const characteristics = [
|
|
4431
|
+
{ type: characteristicType, value: state, valueKey: 'state' }
|
|
4432
|
+
];
|
|
4433
4433
|
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
}
|
|
4434
|
+
// Update system services
|
|
4435
|
+
for (const { type, value, valueKey } of characteristics) {
|
|
4436
|
+
if (!this.functions.isValidValue(value)) continue;
|
|
4437
|
+
sensor[valueKey] = value;
|
|
4438
|
+
this.enchargeBackupLevelSummarySensorsServices?.[i]?.updateCharacteristic(type, value);
|
|
4439
|
+
};
|
|
4441
4440
|
}
|
|
4442
4441
|
}
|
|
4443
4442
|
}
|
|
@@ -4587,23 +4586,21 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4587
4586
|
}
|
|
4588
4587
|
|
|
4589
4588
|
// encharge grid mode sensors
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
const state = sensor.gridMode === relay.enchgGridMode;
|
|
4589
|
+
for (let i = 0; i < this.enchargeGridModeSensors.length; i++) {
|
|
4590
|
+
const sensor = this.enchargeGridModeSensors[i];
|
|
4591
|
+
const { characteristicType, gridMode } = sensor;
|
|
4592
|
+
const state = gridMode === relay.enchgGridMode;
|
|
4595
4593
|
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4594
|
+
// Create characteristics
|
|
4595
|
+
const characteristics = [
|
|
4596
|
+
{ type: characteristicType, value: state, valueKey: 'state' },
|
|
4597
|
+
];
|
|
4600
4598
|
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
}
|
|
4599
|
+
// Update characteristics
|
|
4600
|
+
for (const { type, value, valueKey } of characteristics) {
|
|
4601
|
+
if (!this.functions.isValidValue(value)) continue;
|
|
4602
|
+
sensor[valueKey] = value;
|
|
4603
|
+
this.enchargeGridModeSensorServices?.[i]?.updateCharacteristic(type, value);
|
|
4607
4604
|
}
|
|
4608
4605
|
}
|
|
4609
4606
|
|
|
@@ -4627,23 +4624,21 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4627
4624
|
}
|
|
4628
4625
|
|
|
4629
4626
|
// solar grid mode sensors
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
const state = sensor.gridMode === relay.solarGridMode;
|
|
4627
|
+
for (let i = 0; i < this.solarGridModeSensors.length; i++) {
|
|
4628
|
+
const sensor = this.solarGridModeSensors[i];
|
|
4629
|
+
const { characteristicType, gridMode } = sensor;
|
|
4630
|
+
const state = gridMode === relay.solarGridMode;
|
|
4635
4631
|
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4632
|
+
// Create characteristics
|
|
4633
|
+
const characteristics = [
|
|
4634
|
+
{ type: characteristicType, value: state, valueKey: 'state' },
|
|
4635
|
+
];
|
|
4640
4636
|
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
}
|
|
4637
|
+
// Update characteristics
|
|
4638
|
+
for (const { type, value, valueKey } of characteristics) {
|
|
4639
|
+
if (!this.functions.isValidValue(value)) continue;
|
|
4640
|
+
sensor[valueKey] = value;
|
|
4641
|
+
this.solarGridModeSensorServices?.[i]?.updateCharacteristic(type, value);
|
|
4647
4642
|
}
|
|
4648
4643
|
}
|
|
4649
4644
|
}
|
|
@@ -4772,10 +4767,10 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4772
4767
|
this.enchargeServices?.[index]?.updateCharacteristic(type, value);
|
|
4773
4768
|
};
|
|
4774
4769
|
|
|
4775
|
-
// Update encharge backup level
|
|
4776
|
-
if (this.
|
|
4777
|
-
const
|
|
4778
|
-
const { minSoc, characteristicType, characteristicType1, characteristicType2 } =
|
|
4770
|
+
// Update encharge backup level control
|
|
4771
|
+
if (this.enchargeBackupLevelControl.displayType > 0) {
|
|
4772
|
+
const control = this.enchargeBackupLevelControl;
|
|
4773
|
+
const { minSoc, characteristicType, characteristicType1, characteristicType2 } = control;
|
|
4779
4774
|
const state = enchargeData.percentFull < minSoc;
|
|
4780
4775
|
|
|
4781
4776
|
// Create characteristics
|
|
@@ -4788,8 +4783,8 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4788
4783
|
// Update acbs services
|
|
4789
4784
|
for (const { type, value, valueKey } of characteristics1) {
|
|
4790
4785
|
if (!this.functions.isValidValue(value)) continue;
|
|
4791
|
-
|
|
4792
|
-
this.
|
|
4786
|
+
control[valueKey] = value;
|
|
4787
|
+
this.enchargeBackupLevelControlServices?.[index]?.updateCharacteristic(type, value);
|
|
4793
4788
|
}
|
|
4794
4789
|
}
|
|
4795
4790
|
|
|
@@ -4916,8 +4911,8 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4916
4911
|
|
|
4917
4912
|
// Encharge profile control updates
|
|
4918
4913
|
for (let i = 0; i < this.enchargeProfileControls.length; i++) {
|
|
4919
|
-
const
|
|
4920
|
-
const { characteristicType, profile, chargeFromGrid } =
|
|
4914
|
+
const control = this.enchargeProfileControls[i];
|
|
4915
|
+
const { characteristicType, profile, chargeFromGrid } = control;
|
|
4921
4916
|
const profileState = profile === tariff.storageSettings.mode;
|
|
4922
4917
|
const chargeFromGridState = chargeFromGrid === tariff.storageSettings.chargeFromGrid;
|
|
4923
4918
|
const state = profileState && chargeFromGridState;
|
|
@@ -4934,7 +4929,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4934
4929
|
// Update storage summary services
|
|
4935
4930
|
for (const { type, value, valueKey } of characteristics) {
|
|
4936
4931
|
if (!this.functions.isValidValue(value)) continue;
|
|
4937
|
-
|
|
4932
|
+
control[valueKey] = value;
|
|
4938
4933
|
this.enchargeProfileControlsServices?.[i]?.updateCharacteristic(type, value);
|
|
4939
4934
|
}
|
|
4940
4935
|
}
|
|
@@ -5134,8 +5129,8 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5134
5129
|
|
|
5135
5130
|
// Update enpower grid control
|
|
5136
5131
|
if (this.enpowerGridStateControl.displayType > 0) {
|
|
5137
|
-
const
|
|
5138
|
-
const { characteristicType } =
|
|
5132
|
+
const control = this.enpowerGridStateControl;
|
|
5133
|
+
const { characteristicType } = control;
|
|
5139
5134
|
const state = enpowerData.mainsAdminStateBool;
|
|
5140
5135
|
|
|
5141
5136
|
// Create characteristics
|
|
@@ -5146,7 +5141,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5146
5141
|
// Update characteristics
|
|
5147
5142
|
for (const { type, value, valueKey } of characteristics) {
|
|
5148
5143
|
if (!this.functions.isValidValue(value)) continue;
|
|
5149
|
-
|
|
5144
|
+
control[valueKey] = value;
|
|
5150
5145
|
this.enpowerGridStateControlServices?.[index]?.updateCharacteristic(type, value);
|
|
5151
5146
|
}
|
|
5152
5147
|
}
|
|
@@ -5173,8 +5168,8 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5173
5168
|
// Update enpower grid mode sensors
|
|
5174
5169
|
for (let i = 0; i < (this.enpowerGridModeSensors?.length ?? 0); i++) {
|
|
5175
5170
|
const sensor = this.enpowerGridModeSensors[i];
|
|
5176
|
-
const { characteristicType } = sensor;
|
|
5177
|
-
const state =
|
|
5171
|
+
const { characteristicType, gridMode } = sensor;
|
|
5172
|
+
const state = gridMode === enpowerData.enpwrGridMode;
|
|
5178
5173
|
|
|
5179
5174
|
// Create characteristics
|
|
5180
5175
|
const characteristics = [
|
|
@@ -5411,8 +5406,8 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5411
5406
|
|
|
5412
5407
|
// Update generator admin mode ON/OFF control
|
|
5413
5408
|
if (this.generatorStateControl.displayType > 0) {
|
|
5414
|
-
const
|
|
5415
|
-
const { characteristicType } =
|
|
5409
|
+
const control = this.generatorStateControl;
|
|
5410
|
+
const { characteristicType } = control;
|
|
5416
5411
|
const state = generatorData.adminModeBool;
|
|
5417
5412
|
|
|
5418
5413
|
// Create characteristics
|
|
@@ -5423,7 +5418,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5423
5418
|
// Update characteristics
|
|
5424
5419
|
for (const { type, value, valueKey } of characteristics2) {
|
|
5425
5420
|
if (!this.functions.isValidValue(value)) continue;
|
|
5426
|
-
|
|
5421
|
+
control[valueKey] = value;
|
|
5427
5422
|
this.generatorStateControlService?.updateCharacteristic(type, value);
|
|
5428
5423
|
}
|
|
5429
5424
|
}
|
|
@@ -5449,8 +5444,8 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5449
5444
|
|
|
5450
5445
|
// Update generator mode toggle controls
|
|
5451
5446
|
for (let i = 0; i < (this.generatorModeContols?.length ?? 0); i++) {
|
|
5452
|
-
const
|
|
5453
|
-
const { mode, characteristicType } =
|
|
5447
|
+
const control = this.generatorModeContols[i];
|
|
5448
|
+
const { mode, characteristicType } = control;
|
|
5454
5449
|
const state = mode === generatorData.adminMode;
|
|
5455
5450
|
|
|
5456
5451
|
// Create characteristics
|
|
@@ -5461,7 +5456,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5461
5456
|
// Update characteristics
|
|
5462
5457
|
for (const { type, value, valueKey } of characteristics2) {
|
|
5463
5458
|
if (!this.functions.isValidValue(value)) continue;
|
|
5464
|
-
|
|
5459
|
+
control[valueKey] = value;
|
|
5465
5460
|
this.generatorModeControlServices?.[i]?.updateCharacteristic(type, value);
|
|
5466
5461
|
}
|
|
5467
5462
|
}
|
|
@@ -5561,7 +5556,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5561
5556
|
|
|
5562
5557
|
if (this.logDebug) this.emit('debug', `Updated device: ${type}`, deviceData);
|
|
5563
5558
|
|
|
5564
|
-
// Update system
|
|
5559
|
+
// Update system control
|
|
5565
5560
|
if (type === 'Production' && deviceData.power) {
|
|
5566
5561
|
const powerLevel = this.functions.scaleValue(deviceData.power, 0, this.powerProductionSummary, 0, 100);
|
|
5567
5562
|
const powerState = powerLevel > 0;
|
|
@@ -5572,9 +5567,9 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5572
5567
|
this.emit('info', `Live Data, ${type}, power state: ${powerState ? 'On' : 'Off'}`);
|
|
5573
5568
|
}
|
|
5574
5569
|
|
|
5575
|
-
// Update system
|
|
5576
|
-
const
|
|
5577
|
-
const { characteristicType, characteristicType1 } =
|
|
5570
|
+
// Update system control
|
|
5571
|
+
const control = this.systemAccessory;
|
|
5572
|
+
const { characteristicType, characteristicType1 } = control;
|
|
5578
5573
|
|
|
5579
5574
|
// Create characteristics
|
|
5580
5575
|
const characteristics = [
|
|
@@ -5585,7 +5580,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5585
5580
|
// Update system services
|
|
5586
5581
|
for (const { type, value, valueKey } of characteristics) {
|
|
5587
5582
|
if (!this.functions.isValidValue(value)) continue;
|
|
5588
|
-
|
|
5583
|
+
control[valueKey] = value;
|
|
5589
5584
|
this.systemService?.updateCharacteristic(type, value);
|
|
5590
5585
|
};
|
|
5591
5586
|
}
|
|
@@ -5633,10 +5628,10 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5633
5628
|
}
|
|
5634
5629
|
}
|
|
5635
5630
|
|
|
5636
|
-
// Update acbs summary
|
|
5637
|
-
if (this.
|
|
5638
|
-
const
|
|
5639
|
-
const { minSoc, displayType, characteristicType, characteristicType1 } =
|
|
5631
|
+
// Update acbs summary control
|
|
5632
|
+
if (this.acBatterieBackupLevelSummaryControl.displayType > 0) {
|
|
5633
|
+
const control = this.acBatterieBackupLevelSummaryControl;
|
|
5634
|
+
const { minSoc, displayType, characteristicType, characteristicType1 } = control;
|
|
5640
5635
|
const isServiceBattery = displayType === 5;
|
|
5641
5636
|
const isAboveMinSoc = percentFullSumAcb > minSoc;
|
|
5642
5637
|
const backupLevel = isAboveMinSoc ? percentFullSumAcb : 0;
|
|
@@ -5651,7 +5646,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5651
5646
|
// Update storage summary services
|
|
5652
5647
|
for (const { type, value, valueKey } of characteristics) {
|
|
5653
5648
|
if (!this.functions.isValidValue(value)) continue;
|
|
5654
|
-
|
|
5649
|
+
control[valueKey] = value;
|
|
5655
5650
|
this.acbSummaryLevelAndStateService?.updateCharacteristic(type, value);
|
|
5656
5651
|
}
|
|
5657
5652
|
}
|
|
@@ -5680,10 +5675,10 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5680
5675
|
}
|
|
5681
5676
|
}
|
|
5682
5677
|
|
|
5683
|
-
// Update encharges summary
|
|
5684
|
-
if (this.
|
|
5685
|
-
const
|
|
5686
|
-
const { minSoc, displayType, characteristicType, characteristicType1 } =
|
|
5678
|
+
// Update encharges summary control
|
|
5679
|
+
if (this.enchargeBackupLevelSummaryControl.displayType > 0) {
|
|
5680
|
+
const control = this.enchargeBackupLevelSummaryControl;
|
|
5681
|
+
const { minSoc, displayType, characteristicType, characteristicType1 } = control;
|
|
5687
5682
|
const serviceBattery = displayType === 5;
|
|
5688
5683
|
const backupLevel = percentFullSumEnc > minSoc ? percentFullSumEnc : 0;
|
|
5689
5684
|
const state = serviceBattery ? backupLevel < minSoc : backupLevel > minSoc;
|
|
@@ -5697,29 +5692,27 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5697
5692
|
// Update storage summary services
|
|
5698
5693
|
for (const { type, value, valueKey } of characteristics) {
|
|
5699
5694
|
if (!this.functions.isValidValue(value)) continue;
|
|
5700
|
-
|
|
5701
|
-
this.
|
|
5695
|
+
control[valueKey] = value;
|
|
5696
|
+
this.enchargeBackupLevelSummaryControlService?.updateCharacteristic(type, value);
|
|
5702
5697
|
}
|
|
5703
5698
|
}
|
|
5704
5699
|
|
|
5705
5700
|
// Update encharges summary backup level sensors
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
};
|
|
5722
|
-
}
|
|
5701
|
+
for (let i = 0; i < this.enchargeBackupLevelSummarySensors.length; i++) {
|
|
5702
|
+
const sensor = this.enchargeBackupLevelSummarySensors[i];
|
|
5703
|
+
const { backupLevel, compareMode, characteristicType } = sensor;
|
|
5704
|
+
const state = this.functions.evaluateCompareMode(percentFullSumEnc, backupLevel, compareMode);
|
|
5705
|
+
|
|
5706
|
+
const characteristics = [
|
|
5707
|
+
{ type: characteristicType, value: state, valueKey: 'state' }
|
|
5708
|
+
];
|
|
5709
|
+
|
|
5710
|
+
// Update system services
|
|
5711
|
+
for (const { type, value, valueKey } of characteristics) {
|
|
5712
|
+
if (!this.functions.isValidValue(value)) continue;
|
|
5713
|
+
sensor[valueKey] = value;
|
|
5714
|
+
this.enchargeBackupLevelSummarySensorsServices?.[i]?.updateCharacteristic(type, value);
|
|
5715
|
+
};
|
|
5723
5716
|
}
|
|
5724
5717
|
}
|
|
5725
5718
|
}
|
|
@@ -5792,8 +5785,8 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5792
5785
|
if (this.restFul.enable || this.mqtt.enable) await this.externalIntegrations();
|
|
5793
5786
|
|
|
5794
5787
|
// Prepare HomeKit accessory
|
|
5795
|
-
const
|
|
5796
|
-
return
|
|
5788
|
+
const accessories = await this.prepareAccessory();
|
|
5789
|
+
return accessories;
|
|
5797
5790
|
} catch (error) {
|
|
5798
5791
|
throw new Error(`Start error: ${error}`);
|
|
5799
5792
|
}
|