homebridge-enphase-envoy 10.3.0-beta.1 → 10.3.0-beta.3
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/package.json +1 -1
- package/src/envoydevice.js +256 -260
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.3",
|
|
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) {
|
|
@@ -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,7 +2151,7 @@ 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
|
|
@@ -2171,16 +2180,16 @@ class EnvoyDevice extends EventEmitter {
|
|
|
2171
2180
|
|
|
2172
2181
|
//devices
|
|
2173
2182
|
this.enchargeServices = [];
|
|
2174
|
-
this.
|
|
2183
|
+
this.enchargeBackupLevelServices = [];
|
|
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.enchargeBackupLevelServices.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;
|
|
@@ -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.enchargeBackupLevelSummarySensorServices?.[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
|
}
|
|
@@ -4694,6 +4689,24 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4694
4689
|
gridProfile: encharge.gridProfile
|
|
4695
4690
|
};
|
|
4696
4691
|
|
|
4692
|
+
// Create characteristics
|
|
4693
|
+
const characteristics = [
|
|
4694
|
+
{ type: Characteristic.ChargeState, value: enchargeData.chargeState },
|
|
4695
|
+
{ type: Characteristic.AdminState, value: enchargeData.adminStateStr },
|
|
4696
|
+
{ type: Characteristic.Communicating, value: enchargeData.communicating },
|
|
4697
|
+
{ type: Characteristic.CommLevelSubGhz, value: enchargeData.commLevelSubGhz },
|
|
4698
|
+
{ type: Characteristic.CommLevel24Ghz, value: enchargeData.commLevel24Ghz },
|
|
4699
|
+
{ type: Characteristic.SleepEnabled, value: enchargeData.sleepEnabled },
|
|
4700
|
+
{ type: Characteristic.PercentFull, value: enchargeData.percentFull },
|
|
4701
|
+
{ type: Characteristic.Temperature, value: enchargeData.temperature },
|
|
4702
|
+
{ type: Characteristic.MaxCellTemp, value: enchargeData.maxCellTemp },
|
|
4703
|
+
{ type: Characteristic.LedStatus, value: enchargeData.ledStatus },
|
|
4704
|
+
{ type: Characteristic.Capacity, value: enchargeData.capacity },
|
|
4705
|
+
{ type: Characteristic.DcSwitchOff, value: enchargeData.dcSwitchOff },
|
|
4706
|
+
{ type: Characteristic.Revision, value: enchargeData.rev },
|
|
4707
|
+
{ type: Characteristic.ReadingTime, value: enchargeData.readingTime }
|
|
4708
|
+
];
|
|
4709
|
+
|
|
4697
4710
|
// Add status field
|
|
4698
4711
|
if (enchargesStatusSupported && encharge.status) {
|
|
4699
4712
|
if (this.logDebug) this.emit('debug', `Requesting encharge ${enchargeData.serialNumber} status data`);
|
|
@@ -4725,6 +4738,8 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4725
4738
|
submodulesCount: status.submodulesCount,
|
|
4726
4739
|
submodules: status.submodules
|
|
4727
4740
|
};
|
|
4741
|
+
|
|
4742
|
+
characteristics.push({ type: Characteristic.CommInterface, value: enchargeData.status.commInterfaceStr }, { type: Characteristic.RatedPower, value: enchargeData.status.ratedPowerKw })
|
|
4728
4743
|
}
|
|
4729
4744
|
|
|
4730
4745
|
// Add power field
|
|
@@ -4740,56 +4755,39 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4740
4755
|
apparentPowerKw: power.apparentPower / 1000000,
|
|
4741
4756
|
soc: power.soc,
|
|
4742
4757
|
};
|
|
4758
|
+
|
|
4759
|
+
characteristics.push({ type: Characteristic.RealPower, value: enchargeData.power.realPowerKw });
|
|
4743
4760
|
}
|
|
4744
4761
|
|
|
4745
|
-
//
|
|
4746
|
-
if (this.
|
|
4747
|
-
|
|
4748
|
-
|
|
4762
|
+
// Add grid profile characteristic
|
|
4763
|
+
if (this.feature.gridProfile.supported) characteristics.push({ type: Characteristic.GridProfile, value: enchargeData.gridProfile });
|
|
4764
|
+
|
|
4765
|
+
for (const { type, value } of characteristics) {
|
|
4766
|
+
if (!this.functions.isValidValue(value)) continue;
|
|
4767
|
+
this.enchargeServices?.[index]?.updateCharacteristic(type, value);
|
|
4768
|
+
};
|
|
4769
|
+
|
|
4770
|
+
// Update encharge backup level control
|
|
4771
|
+
if (this.enchargeBackupLevelControl.displayType > 0) {
|
|
4772
|
+
const control = this.enchargeBackupLevelControl;
|
|
4773
|
+
const { minSoc, characteristicType, characteristicType1, characteristicType2 } = control;
|
|
4749
4774
|
const state = enchargeData.percentFull < minSoc;
|
|
4750
4775
|
|
|
4751
4776
|
// Create characteristics
|
|
4752
|
-
const
|
|
4777
|
+
const characteristics1 = [
|
|
4753
4778
|
{ type: characteristicType, value: state, valueKey: 'state' },
|
|
4754
4779
|
{ type: characteristicType1, value: enchargeData.percentFull, valueKey: 'backupLevel' },
|
|
4755
4780
|
{ type: characteristicType2, value: enchargeData.chargeStateNum, valueKey: 'chargeState' },
|
|
4756
4781
|
];
|
|
4757
4782
|
|
|
4758
4783
|
// Update acbs services
|
|
4759
|
-
for (const { type, value, valueKey } of
|
|
4784
|
+
for (const { type, value, valueKey } of characteristics1) {
|
|
4760
4785
|
if (!this.functions.isValidValue(value)) continue;
|
|
4761
|
-
|
|
4762
|
-
this.
|
|
4786
|
+
control[valueKey] = value;
|
|
4787
|
+
this.enchargeBackupLevelServices?.[index]?.updateCharacteristic(type, value);
|
|
4763
4788
|
}
|
|
4764
4789
|
}
|
|
4765
4790
|
|
|
4766
|
-
// Create characteristics
|
|
4767
|
-
const characteristics = [
|
|
4768
|
-
{ type: Characteristic.ChargeState, value: enchargeData.chargeState },
|
|
4769
|
-
{ type: Characteristic.AdminState, value: enchargeData.adminStateStr },
|
|
4770
|
-
{ type: Characteristic.Communicating, value: enchargeData.communicating },
|
|
4771
|
-
{ type: Characteristic.CommLevelSubGhz, value: enchargeData.commLevelSubGhz },
|
|
4772
|
-
{ type: Characteristic.CommLevel24Ghz, value: enchargeData.commLevel24Ghz },
|
|
4773
|
-
{ type: Characteristic.SleepEnabled, value: enchargeData.sleepEnabled },
|
|
4774
|
-
{ type: Characteristic.PercentFull, value: enchargeData.percentFull },
|
|
4775
|
-
{ type: Characteristic.Temperature, value: enchargeData.temperature },
|
|
4776
|
-
{ type: Characteristic.MaxCellTemp, value: enchargeData.maxCellTemp },
|
|
4777
|
-
{ type: Characteristic.LedStatus, value: enchargeData.ledStatus },
|
|
4778
|
-
{ type: Characteristic.Capacity, value: enchargeData.capacity },
|
|
4779
|
-
{ type: Characteristic.DcSwitchOff, value: enchargeData.dcSwitchOff },
|
|
4780
|
-
{ type: Characteristic.Revision, value: enchargeData.rev },
|
|
4781
|
-
{ type: Characteristic.ReadingTime, value: enchargeData.readingTime }
|
|
4782
|
-
];
|
|
4783
|
-
|
|
4784
|
-
if (enchargesStatusSupported && enchargeData.status) characteristics.push({ type: Characteristic.CommInterface, value: enchargeData.status.commInterfaceStr }, { type: Characteristic.RatedPower, value: enchargeData.status.ratedPowerKw });
|
|
4785
|
-
if (enchargesPowerSupported && enchargeData.power) characteristics.push({ type: Characteristic.RealPower, value: enchargeData.power.realPowerKw });
|
|
4786
|
-
if (this.feature.gridProfile.supported) characteristics.push({ type: Characteristic.GridProfile, value: enchargeData.gridProfile });
|
|
4787
|
-
|
|
4788
|
-
for (const { type, value } of characteristics) {
|
|
4789
|
-
if (!this.functions.isValidValue(value)) continue;
|
|
4790
|
-
this.enchargeServices?.[index]?.updateCharacteristic(type, value);
|
|
4791
|
-
};
|
|
4792
|
-
|
|
4793
4791
|
return enchargeData;
|
|
4794
4792
|
}));
|
|
4795
4793
|
|
|
@@ -4913,25 +4911,25 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4913
4911
|
|
|
4914
4912
|
// Encharge profile control updates
|
|
4915
4913
|
for (let i = 0; i < this.enchargeProfileControls.length; i++) {
|
|
4916
|
-
const
|
|
4917
|
-
const { characteristicType } =
|
|
4918
|
-
const
|
|
4919
|
-
const
|
|
4920
|
-
const state =
|
|
4914
|
+
const control = this.enchargeProfileControls[i];
|
|
4915
|
+
const { characteristicType, profile, chargeFromGrid } = control;
|
|
4916
|
+
const profileState = profile === tariff.storageSettings.mode;
|
|
4917
|
+
const chargeFromGridState = chargeFromGrid === tariff.storageSettings.chargeFromGrid;
|
|
4918
|
+
const state = profileState && chargeFromGridState;
|
|
4921
4919
|
|
|
4922
4920
|
// Create characteristics
|
|
4923
4921
|
const characteristics = [
|
|
4924
4922
|
{ type: characteristicType, value: state, valueKey: 'state' },
|
|
4925
4923
|
];
|
|
4926
4924
|
|
|
4927
|
-
if (
|
|
4925
|
+
if (profile !== 'backup') {
|
|
4928
4926
|
characteristics.push({ type: Characteristic.Brightness, value: tariff.storageSettings.reservedSoc, valueKey: 'reservedSoc' });
|
|
4929
4927
|
}
|
|
4930
4928
|
|
|
4931
4929
|
// Update storage summary services
|
|
4932
4930
|
for (const { type, value, valueKey } of characteristics) {
|
|
4933
4931
|
if (!this.functions.isValidValue(value)) continue;
|
|
4934
|
-
|
|
4932
|
+
control[valueKey] = value;
|
|
4935
4933
|
this.enchargeProfileControlsServices?.[i]?.updateCharacteristic(type, value);
|
|
4936
4934
|
}
|
|
4937
4935
|
}
|
|
@@ -4939,8 +4937,8 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4939
4937
|
// Encharge profile sensors update
|
|
4940
4938
|
for (let i = 0; i < this.enchargeProfileSensors.length; i++) {
|
|
4941
4939
|
const sensor = this.enchargeProfileSensors[i];
|
|
4942
|
-
const { characteristicType } = sensor;
|
|
4943
|
-
const state = tariff.storageSettings.mode
|
|
4940
|
+
const { characteristicType, profile } = sensor;
|
|
4941
|
+
const state = profile === tariff.storageSettings.mode;
|
|
4944
4942
|
|
|
4945
4943
|
// Create characteristics
|
|
4946
4944
|
const characteristics = [
|
|
@@ -5131,8 +5129,8 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5131
5129
|
|
|
5132
5130
|
// Update enpower grid control
|
|
5133
5131
|
if (this.enpowerGridStateControl.displayType > 0) {
|
|
5134
|
-
const
|
|
5135
|
-
const { characteristicType } =
|
|
5132
|
+
const control = this.enpowerGridStateControl;
|
|
5133
|
+
const { characteristicType } = control;
|
|
5136
5134
|
const state = enpowerData.mainsAdminStateBool;
|
|
5137
5135
|
|
|
5138
5136
|
// Create characteristics
|
|
@@ -5143,7 +5141,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5143
5141
|
// Update characteristics
|
|
5144
5142
|
for (const { type, value, valueKey } of characteristics) {
|
|
5145
5143
|
if (!this.functions.isValidValue(value)) continue;
|
|
5146
|
-
|
|
5144
|
+
control[valueKey] = value;
|
|
5147
5145
|
this.enpowerGridStateControlServices?.[index]?.updateCharacteristic(type, value);
|
|
5148
5146
|
}
|
|
5149
5147
|
}
|
|
@@ -5408,8 +5406,8 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5408
5406
|
|
|
5409
5407
|
// Update generator admin mode ON/OFF control
|
|
5410
5408
|
if (this.generatorStateControl.displayType > 0) {
|
|
5411
|
-
const
|
|
5412
|
-
const { characteristicType } =
|
|
5409
|
+
const control = this.generatorStateControl;
|
|
5410
|
+
const { characteristicType } = control;
|
|
5413
5411
|
const state = generatorData.adminModeBool;
|
|
5414
5412
|
|
|
5415
5413
|
// Create characteristics
|
|
@@ -5420,7 +5418,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5420
5418
|
// Update characteristics
|
|
5421
5419
|
for (const { type, value, valueKey } of characteristics2) {
|
|
5422
5420
|
if (!this.functions.isValidValue(value)) continue;
|
|
5423
|
-
|
|
5421
|
+
control[valueKey] = value;
|
|
5424
5422
|
this.generatorStateControlService?.updateCharacteristic(type, value);
|
|
5425
5423
|
}
|
|
5426
5424
|
}
|
|
@@ -5446,8 +5444,8 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5446
5444
|
|
|
5447
5445
|
// Update generator mode toggle controls
|
|
5448
5446
|
for (let i = 0; i < (this.generatorModeContols?.length ?? 0); i++) {
|
|
5449
|
-
const
|
|
5450
|
-
const { mode, characteristicType } =
|
|
5447
|
+
const control = this.generatorModeContols[i];
|
|
5448
|
+
const { mode, characteristicType } = control;
|
|
5451
5449
|
const state = mode === generatorData.adminMode;
|
|
5452
5450
|
|
|
5453
5451
|
// Create characteristics
|
|
@@ -5458,7 +5456,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5458
5456
|
// Update characteristics
|
|
5459
5457
|
for (const { type, value, valueKey } of characteristics2) {
|
|
5460
5458
|
if (!this.functions.isValidValue(value)) continue;
|
|
5461
|
-
|
|
5459
|
+
control[valueKey] = value;
|
|
5462
5460
|
this.generatorModeControlServices?.[i]?.updateCharacteristic(type, value);
|
|
5463
5461
|
}
|
|
5464
5462
|
}
|
|
@@ -5558,7 +5556,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5558
5556
|
|
|
5559
5557
|
if (this.logDebug) this.emit('debug', `Updated device: ${type}`, deviceData);
|
|
5560
5558
|
|
|
5561
|
-
// Update system
|
|
5559
|
+
// Update system control
|
|
5562
5560
|
if (type === 'Production' && deviceData.power) {
|
|
5563
5561
|
const powerLevel = this.functions.scaleValue(deviceData.power, 0, this.powerProductionSummary, 0, 100);
|
|
5564
5562
|
const powerState = powerLevel > 0;
|
|
@@ -5569,9 +5567,9 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5569
5567
|
this.emit('info', `Live Data, ${type}, power state: ${powerState ? 'On' : 'Off'}`);
|
|
5570
5568
|
}
|
|
5571
5569
|
|
|
5572
|
-
// Update system
|
|
5573
|
-
const
|
|
5574
|
-
const { characteristicType, characteristicType1 } =
|
|
5570
|
+
// Update system control
|
|
5571
|
+
const control = this.systemAccessory;
|
|
5572
|
+
const { characteristicType, characteristicType1 } = control;
|
|
5575
5573
|
|
|
5576
5574
|
// Create characteristics
|
|
5577
5575
|
const characteristics = [
|
|
@@ -5582,7 +5580,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5582
5580
|
// Update system services
|
|
5583
5581
|
for (const { type, value, valueKey } of characteristics) {
|
|
5584
5582
|
if (!this.functions.isValidValue(value)) continue;
|
|
5585
|
-
|
|
5583
|
+
control[valueKey] = value;
|
|
5586
5584
|
this.systemService?.updateCharacteristic(type, value);
|
|
5587
5585
|
};
|
|
5588
5586
|
}
|
|
@@ -5630,10 +5628,10 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5630
5628
|
}
|
|
5631
5629
|
}
|
|
5632
5630
|
|
|
5633
|
-
// Update acbs summary
|
|
5634
|
-
if (this.
|
|
5635
|
-
const
|
|
5636
|
-
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;
|
|
5637
5635
|
const isServiceBattery = displayType === 5;
|
|
5638
5636
|
const isAboveMinSoc = percentFullSumAcb > minSoc;
|
|
5639
5637
|
const backupLevel = isAboveMinSoc ? percentFullSumAcb : 0;
|
|
@@ -5648,7 +5646,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5648
5646
|
// Update storage summary services
|
|
5649
5647
|
for (const { type, value, valueKey } of characteristics) {
|
|
5650
5648
|
if (!this.functions.isValidValue(value)) continue;
|
|
5651
|
-
|
|
5649
|
+
control[valueKey] = value;
|
|
5652
5650
|
this.acbSummaryLevelAndStateService?.updateCharacteristic(type, value);
|
|
5653
5651
|
}
|
|
5654
5652
|
}
|
|
@@ -5677,10 +5675,10 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5677
5675
|
}
|
|
5678
5676
|
}
|
|
5679
5677
|
|
|
5680
|
-
// Update encharges summary
|
|
5681
|
-
if (this.
|
|
5682
|
-
const
|
|
5683
|
-
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;
|
|
5684
5682
|
const serviceBattery = displayType === 5;
|
|
5685
5683
|
const backupLevel = percentFullSumEnc > minSoc ? percentFullSumEnc : 0;
|
|
5686
5684
|
const state = serviceBattery ? backupLevel < minSoc : backupLevel > minSoc;
|
|
@@ -5694,29 +5692,27 @@ class EnvoyDevice extends EventEmitter {
|
|
|
5694
5692
|
// Update storage summary services
|
|
5695
5693
|
for (const { type, value, valueKey } of characteristics) {
|
|
5696
5694
|
if (!this.functions.isValidValue(value)) continue;
|
|
5697
|
-
|
|
5698
|
-
this.
|
|
5695
|
+
control[valueKey] = value;
|
|
5696
|
+
this.enchargeBackupLevelSummaryControlService?.updateCharacteristic(type, value);
|
|
5699
5697
|
}
|
|
5700
5698
|
}
|
|
5701
5699
|
|
|
5702
5700
|
// Update encharges summary backup level sensors
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
};
|
|
5719
|
-
}
|
|
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.enchargeBackupLevelSummarySensorServices?.[i]?.updateCharacteristic(type, value);
|
|
5715
|
+
};
|
|
5720
5716
|
}
|
|
5721
5717
|
}
|
|
5722
5718
|
}
|