homebridge-enphase-envoy 9.12.2 → 9.12.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/README.md +4 -2
- package/config.schema.json +2 -2
- package/package.json +2 -2
- package/src/envoydevice.js +155 -150
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ The `homebridge-enphase-envoy` plugin integrates Enphase Envoy solar energy moni
|
|
|
45
45
|
### Monitoring Sensors
|
|
46
46
|
|
|
47
47
|
* System `Data Refresh`
|
|
48
|
-
* Production `Power State`, `Power Level`, `Energy State`, `Energy Level`
|
|
48
|
+
* Production `State`, `Power State`, `Power Level`, `Energy State`, `Energy Level`
|
|
49
49
|
* Consumption `Power State`, `Power Level`, `Energy State`, `Energy Level`
|
|
50
50
|
* Q-Relay `State`
|
|
51
51
|
* Enpower `Grid State`
|
|
@@ -57,11 +57,12 @@ The `homebridge-enphase-envoy` plugin integrates Enphase Envoy solar energy moni
|
|
|
57
57
|
* Encharge `Grid On`, `Grid Off`, `Multimode Grid On`, `Multimode Grid Off`, `Grid Tied`, `Grid Forming`
|
|
58
58
|
* Solar `Grid On`, `Grid Off`, `Multimode Grid On`, `Multimode Grid Off`, `Grid Tied`, `Grid Forming`
|
|
59
59
|
* Generator `State`, `Mode`
|
|
60
|
+
* PLC Level `State`
|
|
60
61
|
|
|
61
62
|
### Control Switches, Outlets, Lightbulbs
|
|
62
63
|
|
|
63
64
|
* System `Data Refresh`
|
|
64
|
-
* Production `
|
|
65
|
+
* Production `State`, `Power Mode`, `Power State`, `Power Level`
|
|
65
66
|
* AC Battery `Energy State`, `Backup Level Summary`, `Backup Level`
|
|
66
67
|
* Enpower `Grid State`, `Dry Contacts`
|
|
67
68
|
* Encharge `Energy State Summary`, `Backup Level Summary`, `Energy State`, `Backup Level`
|
|
@@ -71,6 +72,7 @@ The `homebridge-enphase-envoy` plugin integrates Enphase Envoy solar energy moni
|
|
|
71
72
|
* Economy `Activate`, `Set Reserve`
|
|
72
73
|
* Full Backup `Activate`
|
|
73
74
|
* Generator `State`, `Mode`
|
|
75
|
+
* PLC Level `State`
|
|
74
76
|
|
|
75
77
|
## Notes
|
|
76
78
|
|
package/config.schema.json
CHANGED
|
@@ -3308,7 +3308,7 @@
|
|
|
3308
3308
|
"key": "devices[].productionStateControl",
|
|
3309
3309
|
"type": "section",
|
|
3310
3310
|
"title": "Production State Control",
|
|
3311
|
-
"description": "Section enabling additional accessory for
|
|
3311
|
+
"description": "Section enabling additional accessory for production state control (firmware 7+ requires installer credentials)",
|
|
3312
3312
|
"expandable": true,
|
|
3313
3313
|
"expanded": false,
|
|
3314
3314
|
"items": [
|
|
@@ -3321,7 +3321,7 @@
|
|
|
3321
3321
|
"key": "devices[].productionStateSensor",
|
|
3322
3322
|
"type": "section",
|
|
3323
3323
|
"title": "Production State Sensor",
|
|
3324
|
-
"description": "Section enabling additional accessory for
|
|
3324
|
+
"description": "Section enabling additional accessory for production state monitoring (firmware 7+ requires installer credentials)",
|
|
3325
3325
|
"expandable": true,
|
|
3326
3326
|
"expanded": false,
|
|
3327
3327
|
"items": [
|
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": "9.12.
|
|
5
|
+
"version": "9.12.3",
|
|
6
6
|
"description": "Homebridge plugin for Photovoltaic Energy System manufactured by Enphase.",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"author": "grzegorz914",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"LICENSE"
|
|
32
32
|
],
|
|
33
33
|
"engines": {
|
|
34
|
-
"homebridge": "^1.9.0 || ^2.0.0 || ^2.0.0-beta.
|
|
34
|
+
"homebridge": "^1.9.0 || ^2.0.0 || ^2.0.0-beta.27 || ^2.0.0-alpha.37",
|
|
35
35
|
"node": "^18.20.4 || ^20.15.1 || ^22.7.0 || ^23.2.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
package/src/envoydevice.js
CHANGED
|
@@ -776,13 +776,13 @@ class EnvoyDevice extends EventEmitter {
|
|
|
776
776
|
liveData: {
|
|
777
777
|
supported: false
|
|
778
778
|
},
|
|
779
|
-
|
|
779
|
+
arfProfile: {
|
|
780
780
|
supported: false
|
|
781
781
|
},
|
|
782
782
|
productionState: {
|
|
783
783
|
supported: false
|
|
784
784
|
},
|
|
785
|
-
|
|
785
|
+
plcLevel: {
|
|
786
786
|
supported: false
|
|
787
787
|
},
|
|
788
788
|
dataSampling: false
|
|
@@ -827,6 +827,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
827
827
|
liveData: {},
|
|
828
828
|
arfProfile: {},
|
|
829
829
|
productionState: false,
|
|
830
|
+
plcLevelState: false,
|
|
830
831
|
powerState: false,
|
|
831
832
|
powerLevel: 0,
|
|
832
833
|
productionPowerPeak: 0,
|
|
@@ -921,6 +922,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
921
922
|
};
|
|
922
923
|
}).on('state', (state) => {
|
|
923
924
|
const emitState = state ? this.emit('success', `Impulse generator started`) : this.emit('warn', `Impulse generator stopped`);
|
|
925
|
+
this.feature.dataSampling = state;
|
|
924
926
|
|
|
925
927
|
if (this.dataRefreshActiveControl) {
|
|
926
928
|
this.dataRefreshActiveControl.state = state;
|
|
@@ -946,7 +948,6 @@ class EnvoyDevice extends EventEmitter {
|
|
|
946
948
|
this.envoyService
|
|
947
949
|
.updateCharacteristic(Characteristic.EnphaseEnvoyDataRefresh, state)
|
|
948
950
|
}
|
|
949
|
-
this.feature.dataSampling = state;
|
|
950
951
|
|
|
951
952
|
//restFul
|
|
952
953
|
const restFul = this.restFulConnected ? this.restFul1.update('datasampling', { state: state }) : false;
|
|
@@ -3897,114 +3898,6 @@ class EnvoyDevice extends EventEmitter {
|
|
|
3897
3898
|
};
|
|
3898
3899
|
};
|
|
3899
3900
|
|
|
3900
|
-
async updateCommLevel() {
|
|
3901
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Requesting plc level`) : false;
|
|
3902
|
-
try {
|
|
3903
|
-
const options = {
|
|
3904
|
-
method: 'GET',
|
|
3905
|
-
baseURL: this.url,
|
|
3906
|
-
headers: {
|
|
3907
|
-
Accept: 'application/json'
|
|
3908
|
-
}
|
|
3909
|
-
}
|
|
3910
|
-
|
|
3911
|
-
const response = this.pv.envoy.firmware7xx ? await this.axiosInstance(ApiUrls.InverterComm) : await this.digestAuthInstaller.request(ApiUrls.InverterComm, options);
|
|
3912
|
-
const plcLevel = response.data;
|
|
3913
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Plc level:`, plcLevel) : false;
|
|
3914
|
-
|
|
3915
|
-
// get comm level data
|
|
3916
|
-
if (this.feature.microinverters.installed) {
|
|
3917
|
-
this.pv.microinverters.forEach((microinverter, index) => {
|
|
3918
|
-
const key = `${microinverter.serialNumber}`;
|
|
3919
|
-
const value = (plcLevel[key] ?? 0) * 20 ?? 0;
|
|
3920
|
-
|
|
3921
|
-
//add microinverters comm level to microinverters and pv object
|
|
3922
|
-
this.pv.microinverters[index].commLevel = value;
|
|
3923
|
-
|
|
3924
|
-
if (this.microinvertersServices) {
|
|
3925
|
-
this.microinvertersServices[index]
|
|
3926
|
-
.updateCharacteristic(Characteristic.EnphaseMicroinverterCommLevel, value)
|
|
3927
|
-
};
|
|
3928
|
-
});
|
|
3929
|
-
}
|
|
3930
|
-
|
|
3931
|
-
if (this.feature.acBatteries.installed) {
|
|
3932
|
-
this.pv.acBatteries.devices.forEach((acBatterie, index) => {
|
|
3933
|
-
const key = `${acBatterie.serialNumber}`;
|
|
3934
|
-
const value = (plcLevel[key] ?? 0) * 20 ?? 0;
|
|
3935
|
-
|
|
3936
|
-
//add ac batteries comm level to ac batteries and pv object
|
|
3937
|
-
this.pv.acBatteries.devices[index].commLevel = value;
|
|
3938
|
-
|
|
3939
|
-
if (this.acBatteriesServices) {
|
|
3940
|
-
this.acBatteriesServices[index]
|
|
3941
|
-
.updateCharacteristic(Characteristic.EnphaseAcBatterieCommLevel, value)
|
|
3942
|
-
};
|
|
3943
|
-
});
|
|
3944
|
-
}
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
if (this.feature.qRelays.installed) {
|
|
3948
|
-
this.pv.qRelays.forEach((qRelay, index) => {
|
|
3949
|
-
const key = `${qRelay.serialNumber}`;
|
|
3950
|
-
const value = (plcLevel[key] ?? 0) * 20 ?? 0;
|
|
3951
|
-
|
|
3952
|
-
//add qrelays comm level to qrelays and pv object
|
|
3953
|
-
this.pv.qRelays[index].commLevel = value;
|
|
3954
|
-
|
|
3955
|
-
if (this.qRelaysServices) {
|
|
3956
|
-
this.qRelaysServices[index]
|
|
3957
|
-
.updateCharacteristic(Characteristic.EnphaseQrelayCommLevel, value)
|
|
3958
|
-
};
|
|
3959
|
-
});
|
|
3960
|
-
}
|
|
3961
|
-
|
|
3962
|
-
if (this.feature.encharges.installed) {
|
|
3963
|
-
this.ensemble.encharges.devices.forEach((encharge, index) => {
|
|
3964
|
-
const key = `${encharge.serialNumber}`;
|
|
3965
|
-
const value = (plcLevel[key] ?? 0) * 20 ?? 0;
|
|
3966
|
-
|
|
3967
|
-
//add encharges comm level to ensemble and encharges object
|
|
3968
|
-
this.ensemble.encharges.devices[index].commLevel = value;
|
|
3969
|
-
|
|
3970
|
-
if (this.enchargesServices) {
|
|
3971
|
-
this.enchargesServices[index]
|
|
3972
|
-
.updateCharacteristic(Characteristic.EnphaseEnchargeCommLevel, value)
|
|
3973
|
-
}
|
|
3974
|
-
});
|
|
3975
|
-
}
|
|
3976
|
-
|
|
3977
|
-
//update plc level control state
|
|
3978
|
-
if (this.envoyService) {
|
|
3979
|
-
this.envoyService
|
|
3980
|
-
.updateCharacteristic(Characteristic.EnphaseEnvoyCheckCommLevel, false);
|
|
3981
|
-
}
|
|
3982
|
-
|
|
3983
|
-
if (this.plcLevelActiveControl) {
|
|
3984
|
-
this.plcLevelActiveControl.state = false;
|
|
3985
|
-
|
|
3986
|
-
if (this.plcLevelControlService) {
|
|
3987
|
-
const characteristicType = this.plcLevelActiveControl.characteristicType;
|
|
3988
|
-
this.plcLevelControlService
|
|
3989
|
-
.updateCharacteristic(characteristicType, false)
|
|
3990
|
-
}
|
|
3991
|
-
}
|
|
3992
|
-
|
|
3993
|
-
//comm level supported
|
|
3994
|
-
this.feature.plcLevel.supported = true;
|
|
3995
|
-
|
|
3996
|
-
//restFul
|
|
3997
|
-
const restFul = this.restFulConnected ? this.restFul1.update('plclevel', plcLevel) : false;
|
|
3998
|
-
|
|
3999
|
-
//mqtt
|
|
4000
|
-
const mqtt = this.mqttConnected ? this.mqtt1.emit('publish', 'PLC Level', plcLevel) : false;
|
|
4001
|
-
return true;
|
|
4002
|
-
} catch (error) {
|
|
4003
|
-
throw new Error(`Update plc level error: ${error}`);
|
|
4004
|
-
this.emit('warn', `Update plc level error: ${error}, dont worry all working correct, only the plc level control will not be displayed`);
|
|
4005
|
-
};
|
|
4006
|
-
};
|
|
4007
|
-
|
|
4008
3901
|
async updateLiveData() {
|
|
4009
3902
|
const debug = this.enableDebugMode ? this.emit('debug', `Requesting live data`) : false;
|
|
4010
3903
|
try {
|
|
@@ -4167,6 +4060,117 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4167
4060
|
};
|
|
4168
4061
|
};
|
|
4169
4062
|
|
|
4063
|
+
async updatePlcLevel() {
|
|
4064
|
+
const debug = this.enableDebugMode ? this.emit('debug', `Requesting plc level`) : false;
|
|
4065
|
+
try {
|
|
4066
|
+
const options = {
|
|
4067
|
+
method: 'GET',
|
|
4068
|
+
baseURL: this.url,
|
|
4069
|
+
headers: {
|
|
4070
|
+
Accept: 'application/json'
|
|
4071
|
+
}
|
|
4072
|
+
}
|
|
4073
|
+
|
|
4074
|
+
const response = this.pv.envoy.firmware7xx ? await this.axiosInstance(ApiUrls.InverterComm) : await this.digestAuthInstaller.request(ApiUrls.InverterComm, options);
|
|
4075
|
+
const plcLevel = response.data;
|
|
4076
|
+
const debug = this.enableDebugMode ? this.emit('debug', `Plc level:`, plcLevel) : false;
|
|
4077
|
+
|
|
4078
|
+
// get comm level data
|
|
4079
|
+
if (this.feature.microinverters.installed) {
|
|
4080
|
+
this.pv.microinverters.forEach((microinverter, index) => {
|
|
4081
|
+
const key = `${microinverter.serialNumber}`;
|
|
4082
|
+
const value = (plcLevel[key] ?? 0) * 20 ?? 0;
|
|
4083
|
+
|
|
4084
|
+
//add microinverters comm level to microinverters and pv object
|
|
4085
|
+
this.pv.microinverters[index].commLevel = value;
|
|
4086
|
+
|
|
4087
|
+
if (this.microinvertersServices) {
|
|
4088
|
+
this.microinvertersServices[index]
|
|
4089
|
+
.updateCharacteristic(Characteristic.EnphaseMicroinverterCommLevel, value)
|
|
4090
|
+
};
|
|
4091
|
+
});
|
|
4092
|
+
}
|
|
4093
|
+
|
|
4094
|
+
if (this.feature.acBatteries.installed) {
|
|
4095
|
+
this.pv.acBatteries.devices.forEach((acBatterie, index) => {
|
|
4096
|
+
const key = `${acBatterie.serialNumber}`;
|
|
4097
|
+
const value = (plcLevel[key] ?? 0) * 20 ?? 0;
|
|
4098
|
+
|
|
4099
|
+
//add ac batteries comm level to ac batteries and pv object
|
|
4100
|
+
this.pv.acBatteries.devices[index].commLevel = value;
|
|
4101
|
+
|
|
4102
|
+
if (this.acBatteriesServices) {
|
|
4103
|
+
this.acBatteriesServices[index]
|
|
4104
|
+
.updateCharacteristic(Characteristic.EnphaseAcBatterieCommLevel, value)
|
|
4105
|
+
};
|
|
4106
|
+
});
|
|
4107
|
+
}
|
|
4108
|
+
|
|
4109
|
+
|
|
4110
|
+
if (this.feature.qRelays.installed) {
|
|
4111
|
+
this.pv.qRelays.forEach((qRelay, index) => {
|
|
4112
|
+
const key = `${qRelay.serialNumber}`;
|
|
4113
|
+
const value = (plcLevel[key] ?? 0) * 20 ?? 0;
|
|
4114
|
+
|
|
4115
|
+
//add qrelays comm level to qrelays and pv object
|
|
4116
|
+
this.pv.qRelays[index].commLevel = value;
|
|
4117
|
+
|
|
4118
|
+
if (this.qRelaysServices) {
|
|
4119
|
+
this.qRelaysServices[index]
|
|
4120
|
+
.updateCharacteristic(Characteristic.EnphaseQrelayCommLevel, value)
|
|
4121
|
+
};
|
|
4122
|
+
});
|
|
4123
|
+
}
|
|
4124
|
+
|
|
4125
|
+
if (this.feature.encharges.installed) {
|
|
4126
|
+
this.ensemble.encharges.devices.forEach((encharge, index) => {
|
|
4127
|
+
const key = `${encharge.serialNumber}`;
|
|
4128
|
+
const value = (plcLevel[key] ?? 0) * 20 ?? 0;
|
|
4129
|
+
|
|
4130
|
+
//add encharges comm level to ensemble and encharges object
|
|
4131
|
+
this.ensemble.encharges.devices[index].commLevel = value;
|
|
4132
|
+
|
|
4133
|
+
if (this.enchargesServices) {
|
|
4134
|
+
this.enchargesServices[index]
|
|
4135
|
+
.updateCharacteristic(Characteristic.EnphaseEnchargeCommLevel, value)
|
|
4136
|
+
}
|
|
4137
|
+
});
|
|
4138
|
+
}
|
|
4139
|
+
|
|
4140
|
+
//update plc level control state
|
|
4141
|
+
if (this.envoyService) {
|
|
4142
|
+
this.envoyService
|
|
4143
|
+
.updateCharacteristic(Characteristic.EnphaseEnvoyCheckCommLevel, false);
|
|
4144
|
+
}
|
|
4145
|
+
|
|
4146
|
+
if (this.plcLevelActiveControl) {
|
|
4147
|
+
this.plcLevelActiveControl.state = false;
|
|
4148
|
+
|
|
4149
|
+
if (this.plcLevelControlService) {
|
|
4150
|
+
const characteristicType = this.plcLevelActiveControl.characteristicType;
|
|
4151
|
+
this.plcLevelControlService
|
|
4152
|
+
.updateCharacteristic(characteristicType, false)
|
|
4153
|
+
}
|
|
4154
|
+
}
|
|
4155
|
+
|
|
4156
|
+
//update plc level state
|
|
4157
|
+
this.pv.plcLevelState = false;
|
|
4158
|
+
|
|
4159
|
+
//comm level supported
|
|
4160
|
+
this.feature.plcLevel.supported = true;
|
|
4161
|
+
|
|
4162
|
+
//restFul
|
|
4163
|
+
const restFul = this.restFulConnected ? this.restFul1.update('plclevel', plcLevel) : false;
|
|
4164
|
+
|
|
4165
|
+
//mqtt
|
|
4166
|
+
const mqtt = this.mqttConnected ? this.mqtt1.emit('publish', 'PLC Level', plcLevel) : false;
|
|
4167
|
+
return true;
|
|
4168
|
+
} catch (error) {
|
|
4169
|
+
throw new Error(`Update plc level error: ${error}`);
|
|
4170
|
+
this.emit('warn', `Update plc level error: ${error}, dont worry all working correct, only the plc level control will not be displayed`);
|
|
4171
|
+
};
|
|
4172
|
+
};
|
|
4173
|
+
|
|
4170
4174
|
async setProductionPowerState(state) {
|
|
4171
4175
|
const debug = this.enableDebugMode ? this.emit('debug', `Set production power mode`) : false;
|
|
4172
4176
|
try {
|
|
@@ -4523,7 +4527,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4523
4527
|
set = this.feature.productionState.supported ? await this.setDat(value) : false;
|
|
4524
4528
|
break;
|
|
4525
4529
|
case 'PlcLevel':
|
|
4526
|
-
set = this.feature.plcLevel.supported ? await this.
|
|
4530
|
+
set = this.feature.plcLevel.supported ? await this.updatePlcLevel(value) : false;
|
|
4527
4531
|
break;
|
|
4528
4532
|
case 'EnchargeProfile':
|
|
4529
4533
|
set = this.feature.encharges.tariff.supported ? await this.setEnchargeProfile(value, this.ensemble.tariff.storageSettings.reservedSoc, this.ensemble.tariff.storageSettings.chargeFromGrid) : false;
|
|
@@ -4727,7 +4731,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4727
4731
|
};
|
|
4728
4732
|
|
|
4729
4733
|
//plc level control service
|
|
4730
|
-
if (plcLevelSupported) {
|
|
4734
|
+
if (this.plcLevelActiveControl && plcLevelSupported) {
|
|
4731
4735
|
const debug = this.enableDebugMode ? this.emit('debug', `Prepare Plc Level Control Service`) : false;
|
|
4732
4736
|
const serviceName = this.plcLevelActiveControl.namePrefix ? `${accessoryName} ${this.plcLevelActiveControl.name}` : this.plcLevelActiveControl.name;
|
|
4733
4737
|
const serviceType = this.plcLevelActiveControl.serviceType;
|
|
@@ -4744,7 +4748,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4744
4748
|
.onSet(async (state) => {
|
|
4745
4749
|
try {
|
|
4746
4750
|
const tokenValid = await this.checkJwtToken();
|
|
4747
|
-
const setState = tokenValid && state ? await this.
|
|
4751
|
+
const setState = tokenValid && state ? await this.updatePlcLevel() : false;
|
|
4748
4752
|
const info = this.disableLogInfo || !tokenValid ? false : this.emit('info', `Set plc level control state to: ${setState ? `ON` : `OFF`}`);
|
|
4749
4753
|
} catch (error) {
|
|
4750
4754
|
this.emit('warn', `Set plc level control state error: ${error}`);
|
|
@@ -4871,15 +4875,7 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4871
4875
|
const info = this.disableLogInfo ? false : this.emit('info', `Envoy: ${envoySerialNumber}, last report to enlighten: ${value}`);
|
|
4872
4876
|
return value;
|
|
4873
4877
|
});
|
|
4874
|
-
if (
|
|
4875
|
-
envoyService.getCharacteristic(Characteristic.EnphaseEnvoyGridProfile)
|
|
4876
|
-
.onGet(async () => {
|
|
4877
|
-
const value = this.pv.arfProfile.name;
|
|
4878
|
-
const info = this.disableLogInfo ? false : this.emit('info', `Envoy: ${envoySerialNumber}, grid profile: ${value}`);
|
|
4879
|
-
return value;
|
|
4880
|
-
});
|
|
4881
|
-
}
|
|
4882
|
-
if (this.productionStateActiveControl && productionStateSupported) {
|
|
4878
|
+
if (productionStateSupported) {
|
|
4883
4879
|
envoyService.getCharacteristic(Characteristic.EnphaseEnvoyProductionPowerMode)
|
|
4884
4880
|
.onGet(async () => {
|
|
4885
4881
|
const state = this.pv.productionState;
|
|
@@ -4900,20 +4896,28 @@ class EnvoyDevice extends EventEmitter {
|
|
|
4900
4896
|
if (plcLevelSupported) {
|
|
4901
4897
|
envoyService.getCharacteristic(Characteristic.EnphaseEnvoyCheckCommLevel)
|
|
4902
4898
|
.onGet(async () => {
|
|
4903
|
-
const state =
|
|
4899
|
+
const state = this.pv.plcLevelState;
|
|
4904
4900
|
const info = this.disableLogInfo ? false : this.emit('info', `Envoy: ${envoySerialNumber}, checking plc level: ${state ? `Yes` : `No`}`);
|
|
4905
4901
|
return state;
|
|
4906
4902
|
})
|
|
4907
4903
|
.onSet(async (state) => {
|
|
4908
4904
|
try {
|
|
4909
4905
|
const tokenValid = await this.checkJwtToken();
|
|
4910
|
-
const setStatet = tokenValid && state ? await this.
|
|
4906
|
+
const setStatet = tokenValid && state ? await this.updatePlcLevel() : false;
|
|
4911
4907
|
const info = this.disableLogInfo || !tokenValid ? false : this.emit('info', `Envoy: ${envoySerialNumber}, check plc level: ${setStatet ? `Yes` : `No`}`);
|
|
4912
4908
|
} catch (error) {
|
|
4913
4909
|
this.emit('warn', `Envoy: ${envoySerialNumber}, check plc level error: ${error}`);
|
|
4914
4910
|
};
|
|
4915
4911
|
});
|
|
4916
4912
|
}
|
|
4913
|
+
if (arfProfileSupported) {
|
|
4914
|
+
envoyService.getCharacteristic(Characteristic.EnphaseEnvoyGridProfile)
|
|
4915
|
+
.onGet(async () => {
|
|
4916
|
+
const value = this.pv.arfProfile.name;
|
|
4917
|
+
const info = this.disableLogInfo ? false : this.emit('info', `Envoy: ${envoySerialNumber}, grid profile: ${value}`);
|
|
4918
|
+
return value;
|
|
4919
|
+
});
|
|
4920
|
+
}
|
|
4917
4921
|
if (enpowersInstalled) {
|
|
4918
4922
|
envoyService.getCharacteristic(Characteristic.EnphaseEnvoyEnpowerGridMode)
|
|
4919
4923
|
.onGet(async () => {
|
|
@@ -6987,15 +6991,17 @@ class EnvoyDevice extends EventEmitter {
|
|
|
6987
6991
|
//create array for timmers
|
|
6988
6992
|
this.timers = [];
|
|
6989
6993
|
|
|
6990
|
-
//
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6994
|
+
//read envoy dev from file
|
|
6995
|
+
try {
|
|
6996
|
+
const response = await this.readData(this.envoyIdFile);
|
|
6997
|
+
const debug = this.enableDebugMode ? this.emit('debug', `Envoy dev Id from file: ${response.toString().length === 9 ? 'Exist' : 'Missing'}`) : false;
|
|
6998
|
+
this.pv.envoy.devId = response.toString().length === 9 ? response.toString() : this.pv.envoy.devId;
|
|
6999
|
+
} catch (error) {
|
|
7000
|
+
this.emit('warn', `Read envoy dev Id from file error: ${error}`)
|
|
7001
|
+
};
|
|
6996
7002
|
|
|
6997
7003
|
//read JWT token from file
|
|
6998
|
-
if (this.
|
|
7004
|
+
if (this.envoyFirmware7xxTokenGenerationMode === 1) {
|
|
6999
7005
|
try {
|
|
7000
7006
|
const data = await this.readData(this.envoyTokenFile);
|
|
7001
7007
|
const parsedData = JSON.parse(data);
|
|
@@ -7006,12 +7012,22 @@ class EnvoyDevice extends EventEmitter {
|
|
|
7006
7012
|
};
|
|
7007
7013
|
};
|
|
7008
7014
|
|
|
7015
|
+
//get envoy info
|
|
7016
|
+
const updateInfo = await this.updateInfo();
|
|
7017
|
+
|
|
7018
|
+
//calculate envoy and installer passwords
|
|
7019
|
+
const digestAuthorizationEnvoy = this.pv.envoy.firmware < 700 && updateInfo ? await this.digestAuthorizationEnvoy() : false;
|
|
7020
|
+
const digestAuthorizationInstaller = this.pv.envoy.firmware < 700 && updateInfo ? await this.digestAuthorizationInstaller() : false;
|
|
7021
|
+
|
|
7009
7022
|
//get and validate jwt token
|
|
7010
7023
|
const tokenValid = this.pv.envoy.firmware >= 700 ? await this.checkJwtToken() : false;
|
|
7011
7024
|
if (this.pv.envoy.firmware >= 700 && !tokenValid) {
|
|
7012
7025
|
return null;
|
|
7013
7026
|
};
|
|
7014
7027
|
|
|
7028
|
+
//read envoy dev id from app
|
|
7029
|
+
const envoyDevIdValid = this.pv.envoy.devId.length === 9 && updateInfo ? true : await this.getEnvoyBackboneApp();
|
|
7030
|
+
|
|
7015
7031
|
//update grid profile
|
|
7016
7032
|
const updateGridProfile = tokenValid ? await this.updateGridProfile() : false;
|
|
7017
7033
|
|
|
@@ -7033,22 +7049,9 @@ class EnvoyDevice extends EventEmitter {
|
|
|
7033
7049
|
//get production all ab D8.2.4391
|
|
7034
7050
|
const refreshProductionAll = tokenValid && this.pv.envoy.firmware >= 824 ? await this.updateProductionAll() : false;
|
|
7035
7051
|
|
|
7036
|
-
//
|
|
7037
|
-
|
|
7038
|
-
|
|
7039
|
-
//check if the envoy ID is stored
|
|
7040
|
-
const response = await this.readData(this.envoyIdFile);
|
|
7041
|
-
const debug = this.enableDebugMode ? this.emit('debug', `Envoy dev Id from file: ${response.toString().length === 9 ? 'Exist' : 'Missing'}`) : false;
|
|
7042
|
-
this.pv.envoy.devId = response.toString().length === 9 ? response.toString() : this.pv.envoy.devId;
|
|
7043
|
-
} catch (error) {
|
|
7044
|
-
this.emit('warn', `Read envoy dev Id from file error: ${error}`)
|
|
7045
|
-
};
|
|
7046
|
-
|
|
7047
|
-
//read envoy dev id from app
|
|
7048
|
-
const envoyDevIdValid = this.pv.envoy.devId.length === 9 && updateInfo ? true : await this.getEnvoyBackboneApp();
|
|
7049
|
-
const refreshProductionState = envoyDevIdValid && ((this.pv.envoy.jwtToken.installer && tokenValid) || digestAuthorizationInstaller) ? await this.updateProductionState() : false;
|
|
7050
|
-
const pushTimer = refreshProductionState ? this.timers.push({ name: 'updateProductionState', sampling: 10000 }) : false;
|
|
7051
|
-
};
|
|
7052
|
+
//get production state
|
|
7053
|
+
const refreshProductionState = envoyDevIdValid && ((this.pv.envoy.jwtToken.installer && tokenValid) || digestAuthorizationInstaller) ? await this.updateProductionState() : false;
|
|
7054
|
+
const pushTimer = refreshProductionState ? this.timers.push({ name: 'updateProductionState', sampling: 10000 }) : false;
|
|
7052
7055
|
|
|
7053
7056
|
//get ensemble data only FW. >= 7.x.x.
|
|
7054
7057
|
const refreshEnsemble = tokenValid ? await this.updateEnsembleInventory() : false;
|
|
@@ -7060,10 +7063,12 @@ class EnvoyDevice extends EventEmitter {
|
|
|
7060
7063
|
const updateGenerator = refreshEnsemble ? await this.updateGenerator() : false;
|
|
7061
7064
|
const updateGeneratorSettings = updateGenerator ? await this.updateGeneratorSettings() : false;
|
|
7062
7065
|
|
|
7063
|
-
//get
|
|
7064
|
-
const updateCommLevel = this.plcLevelActiveControl && ((this.pv.envoy.jwtToken.installer && tokenValid) || digestAuthorizationInstaller) ? await this.updateCommLevel() : false;
|
|
7066
|
+
//get live data
|
|
7065
7067
|
const refreshLiveData = tokenValid ? await this.updateLiveData() : false;
|
|
7066
7068
|
|
|
7069
|
+
//get plc communication level
|
|
7070
|
+
const updatePlcLevel = (this.pv.envoy.jwtToken.installer && tokenValid) || digestAuthorizationInstaller ? await this.updatePlcLevel() : false;
|
|
7071
|
+
|
|
7067
7072
|
//connect to deice success
|
|
7068
7073
|
this.emit('success', `Connect Success`)
|
|
7069
7074
|
|