homebridge-enphase-envoy 10.8.3 → 10.8.5
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 +14 -0
- package/index.js +3 -1
- package/package.json +3 -3
- package/src/envoydata.js +21 -6
- package/src/envoydevice.js +1 -0
- package/src/mqtt.js +3 -0
- package/src/restful.js +16 -3
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
11
11
|
- For plugin >= v10.4.0 use Homebridge UI >= v5.13.0
|
|
12
12
|
- after update to v10.0.0 and above the accessory and bridge need to be removed from the homebridge / Home.app and added again
|
|
13
13
|
|
|
14
|
+
## [10.8.5] - (18.11.2026)
|
|
15
|
+
|
|
16
|
+
### Changes
|
|
17
|
+
|
|
18
|
+
- fixed: the RESTFul server tries again every 10 seconds when its port cannot be opened at the start of the plugin, a server that starts later is used by the running device
|
|
19
|
+
- fixed: MQTT does not queue the messages while the broker is not connected, the plugin stops to publish when the connection to the broker is lost and starts again after it is connected
|
|
20
|
+
- updated: dependencies, axios and fast-xml-parser to the latest versions
|
|
21
|
+
|
|
22
|
+
## [10.8.4] - (16.11.2026)
|
|
23
|
+
|
|
24
|
+
### Changes
|
|
25
|
+
|
|
26
|
+
- fixed: the power factor was above 1 (about 2.9) and the voltage about 710 V for a three phase installation after the update of the gateway to D8.3.6022, the gateway reports the sum of the phases, the power factor is now calculated as the active power to the apparent power, and the voltage of the production.json is divided by the number of the phases
|
|
27
|
+
|
|
14
28
|
## [10.8.3] - (04.11.2026)
|
|
15
29
|
|
|
16
30
|
### Changes
|
package/index.js
CHANGED
|
@@ -125,9 +125,11 @@ class EnvoyPlatform {
|
|
|
125
125
|
logWarn: logLevel.warn,
|
|
126
126
|
logDebug: logLevel.debug,
|
|
127
127
|
})
|
|
128
|
-
.
|
|
128
|
+
.on('connected', (msg) => {
|
|
129
129
|
clearTimeout(timer);
|
|
130
130
|
restFulConnected = true;
|
|
131
|
+
// The server can start later than the plugin, when the port was busy, the running device uses it from then
|
|
132
|
+
if (activeDevice) activeDevice.restFulConnected = true;
|
|
131
133
|
if (logLevel.success) log.success(`Device: ${host} ${deviceName}, ${msg}`);
|
|
132
134
|
resolve();
|
|
133
135
|
})
|
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.8.
|
|
5
|
+
"version": "10.8.5",
|
|
6
6
|
"description": "Homebridge plugin for Photovoltaic Energy System manufactured by Enphase.",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"author": "grzegorz914",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"mqtt": "^5.16.1",
|
|
39
|
-
"axios": "^1.21.
|
|
39
|
+
"axios": "^1.21.1",
|
|
40
40
|
"express": "^5.3.0",
|
|
41
|
-
"fast-xml-parser": "^5.12.
|
|
41
|
+
"fast-xml-parser": "^5.12.1",
|
|
42
42
|
"fakegato-history": "^0.6.7",
|
|
43
43
|
"node-cron": "^4.6.0"
|
|
44
44
|
},
|
package/src/envoydata.js
CHANGED
|
@@ -1212,6 +1212,21 @@ class EnvoyData extends EventEmitter {
|
|
|
1212
1212
|
}
|
|
1213
1213
|
}
|
|
1214
1214
|
|
|
1215
|
+
// The gateway reports the sum of the phase voltages in the production.json for a split and three phase installation
|
|
1216
|
+
countPhases(lines) {
|
|
1217
|
+
return (lines ?? []).filter(line => line.rmsVoltage > 0).length || 1;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
// For a three phase installation the gateway (firmware D8.3.6022 and newer) reports the sum of the phase power factors, so the value
|
|
1221
|
+
// is above 1, the power factor of the installation is the ratio of the active power to the apparent power
|
|
1222
|
+
calculatePowerFactor(pwrFactor, divide, phases, activePower, apparentPower) {
|
|
1223
|
+
if (phases >= 3 && apparentPower > 0) {
|
|
1224
|
+
const value = Math.round(activePower / apparentPower * 1000) / 1000;
|
|
1225
|
+
return Math.max(-1, Math.min(1, value));
|
|
1226
|
+
}
|
|
1227
|
+
return pwrFactor / divide;
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1215
1230
|
async updateMetersReading(start) {
|
|
1216
1231
|
if (this.logDebug) this.emit('debug', `Requesting meters reading`);
|
|
1217
1232
|
|
|
@@ -1237,7 +1252,7 @@ class EnvoyData extends EventEmitter {
|
|
|
1237
1252
|
apparentEnergy: meter.apparentEnergy,
|
|
1238
1253
|
current: meter.current,
|
|
1239
1254
|
voltage: meter.voltage / meterConfig.voltageDivide,
|
|
1240
|
-
pwrFactor: meter.pwrFactor
|
|
1255
|
+
pwrFactor: this.calculatePowerFactor(meter.pwrFactor, meterConfig.powerFactorDivide, meterConfig.phaseCount, meter.activePower, meter.apparentPower),
|
|
1241
1256
|
frequency: meter.freq,
|
|
1242
1257
|
channels: meter.channels ?? [],
|
|
1243
1258
|
};
|
|
@@ -1293,7 +1308,7 @@ class EnvoyData extends EventEmitter {
|
|
|
1293
1308
|
apparentEnergy: cumulative.vahCum,
|
|
1294
1309
|
current: cumulative.rmsCurrent,
|
|
1295
1310
|
voltage: cumulative.rmsVoltage / meterConfig.voltageDivide,
|
|
1296
|
-
pwrFactor: cumulative.pwrFactor
|
|
1311
|
+
pwrFactor: this.calculatePowerFactor(cumulative.pwrFactor, meterConfig.powerFactorDivide, meterConfig.phaseCount, cumulative.actPower, cumulative.apprntPwr),
|
|
1297
1312
|
frequency: cumulative.freqHz,
|
|
1298
1313
|
channels: meter.lines ?? [],
|
|
1299
1314
|
};
|
|
@@ -1686,8 +1701,8 @@ class EnvoyData extends EventEmitter {
|
|
|
1686
1701
|
reactivePower: productionEim.reactPwr,
|
|
1687
1702
|
apparentPower: productionEim.apprntPwr,
|
|
1688
1703
|
current: productionEim.rmsCurrent,
|
|
1689
|
-
voltage: productionEim.rmsVoltage,
|
|
1690
|
-
pwrFactor: productionEim.pwrFactor
|
|
1704
|
+
voltage: productionEim.rmsVoltage / this.countPhases(productionEim.lines),
|
|
1705
|
+
pwrFactor: this.calculatePowerFactor(productionEim.pwrFactor, 1, this.countPhases(productionEim.lines), productionEim.wNow, productionEim.apprntPwr)
|
|
1691
1706
|
};
|
|
1692
1707
|
this.pv.powerAndEnergy.production.eim = obj;
|
|
1693
1708
|
this.feature.productionCt.production.eim.supported = true;
|
|
@@ -1713,8 +1728,8 @@ class EnvoyData extends EventEmitter {
|
|
|
1713
1728
|
reactivePower: item.reactPwr,
|
|
1714
1729
|
apparentPower: item.apprntPwr,
|
|
1715
1730
|
current: item.rmsCurrent,
|
|
1716
|
-
voltage: item.rmsVoltage,
|
|
1717
|
-
pwrFactor: item.pwrFactor
|
|
1731
|
+
voltage: item.rmsVoltage / this.countPhases(item.lines),
|
|
1732
|
+
pwrFactor: this.calculatePowerFactor(item.pwrFactor, 1, this.countPhases(item.lines), item.wNow, item.apprntPwr)
|
|
1718
1733
|
};
|
|
1719
1734
|
Object.assign(this.pv.powerAndEnergy[key], obj);
|
|
1720
1735
|
this.feature.productionCt[key].supported = true;
|
package/src/envoydevice.js
CHANGED
|
@@ -126,6 +126,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
126
126
|
this.mqttConnected = mqttConnected;
|
|
127
127
|
// The broker may come online after the start or restart, the device then publishes again
|
|
128
128
|
this.mqtt1?.on('online', () => this.mqttOnline().catch((error) => this.emit('warn', `MQTT online error: ${error}`)));
|
|
129
|
+
this.mqtt1?.on('offline', () => { this.mqttConnected = false; });
|
|
129
130
|
|
|
130
131
|
//system accessory
|
|
131
132
|
this.systemAccessory = {
|
package/src/mqtt.js
CHANGED
|
@@ -94,7 +94,10 @@ class Mqtt extends EventEmitter {
|
|
|
94
94
|
if (config.logDebug) this.emit('debug', 'MQTT Reconnecting...');
|
|
95
95
|
})
|
|
96
96
|
.on('close', () => {
|
|
97
|
+
// The broker is gone, the plugin stops to publish until it is connected again, the client would only queue the messages
|
|
98
|
+
const wasConnected = this.connected;
|
|
97
99
|
this.connected = false;
|
|
100
|
+
if (wasConnected) this.emit('offline');
|
|
98
101
|
if (!hasConnected && !warnedStalled && Date.now() - startTime > 30000) {
|
|
99
102
|
warnedStalled = true;
|
|
100
103
|
this.emit('warn', `MQTT has not connected after 30s of retries using protocol v${protocolVersion}. Check broker address, credentials, and whether the broker supports this MQTT protocol version.`);
|
package/src/restful.js
CHANGED
|
@@ -162,14 +162,27 @@ class RestFul extends EventEmitter {
|
|
|
162
162
|
}
|
|
163
163
|
});
|
|
164
164
|
|
|
165
|
-
|
|
166
|
-
this.emit('connected', `RESTful started on port: ${this.port}`);
|
|
167
|
-
});
|
|
165
|
+
this.listen(app);
|
|
168
166
|
} catch (error) {
|
|
169
167
|
if (this.logWarn) this.emit('warn', `RESTful Connect error: ${error}`);
|
|
170
168
|
}
|
|
171
169
|
}
|
|
172
170
|
|
|
171
|
+
// When the port cannot be opened, for example it is still used after a restart, the server tries again until it starts
|
|
172
|
+
listen(app) {
|
|
173
|
+
const server = app.listen(this.port);
|
|
174
|
+
server.once('listening', () => {
|
|
175
|
+
this.listenWarned = false;
|
|
176
|
+
this.emit('connected', `RESTful started on port: ${this.port}`);
|
|
177
|
+
});
|
|
178
|
+
server.on('error', (error) => {
|
|
179
|
+
if (this.logWarn && !this.listenWarned) this.emit('warn', `RESTful cannot start on port: ${this.port}, ${error.code ?? error}, trying again every 10 seconds`);
|
|
180
|
+
this.listenWarned = true;
|
|
181
|
+
server.close();
|
|
182
|
+
setTimeout(() => this.listen(app), 10000).unref?.();
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
|
|
173
186
|
tokenValid(provided) {
|
|
174
187
|
// Compare fixed-length hashes so the check takes the same time regardless of token length or content
|
|
175
188
|
const a = createHash('sha256').update(provided).digest();
|