homebridge-enphase-envoy 9.7.0 → 9.7.2

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/index.js CHANGED
@@ -117,7 +117,7 @@ class EnvoyPlatform {
117
117
  const emitLog = !enableDebugMode ? false : log.info(`Device: ${host} ${deviceName}, debug: ${debug}.`);
118
118
  })
119
119
  .on('warn', (warn) => {
120
- const lemitLogog = disableLogWarn ? false : log.warn(`Device: ${host} ${deviceName}, ${warn}.`);
120
+ const emitLog = disableLogWarn ? false : log.warn(`Device: ${host} ${deviceName}, ${warn}.`);
121
121
  })
122
122
  .on('error', (error) => {
123
123
  const emitLog = disableLogError ? false : log.error(`Device: ${host} ${deviceName}, ${error}.`);
@@ -128,7 +128,7 @@ class EnvoyPlatform {
128
128
  impulseGenerator.on('start', async () => {
129
129
  try {
130
130
  const startDone = await envoyDevice.start();
131
- const stopImpulseGenerator = startDone ? impulseGenerator.stop() : false;
131
+ const stopImpulseGenerator = startDone ? await impulseGenerator.stop() : false;
132
132
  } catch (error) {
133
133
  const emitLog = disableLogError ? false : log.error(`Device: ${host} ${deviceName}, ${error}, trying again.`);
134
134
  };
@@ -137,7 +137,7 @@ class EnvoyPlatform {
137
137
  });
138
138
 
139
139
  //start impulse generator
140
- impulseGenerator.start([{ name: 'start', sampling: 45000 }]);
140
+ await impulseGenerator.start([{ name: 'start', sampling: 45000 }]);
141
141
  } catch (error) {
142
142
  throw new Error(`Device: ${host} ${deviceName}, Did finish launching error: ${error}.`);
143
143
  };
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.7.0",
5
+ "version": "9.7.2",
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.6.0 || ^2.0.0-beta.0",
34
+ "homebridge": "^1.8.5 || ^2.0.0-beta.0",
35
35
  "node": "^18.20.4 || ^20.15.1 || ^22.7.0 || ^23.2.0"
36
36
  },
37
37
  "dependencies": {
@@ -974,85 +974,6 @@ class EnvoyDevice extends EventEmitter {
974
974
  const emitError = tokenNotValid ? false : this.emit('error', `Impulse generator: ${error}`);
975
975
  };
976
976
 
977
- async start() {
978
- const debug = this.enableDebugMode ? this.emit('debug', `Start`) : false;
979
-
980
- try {
981
- //get and validate jwt token
982
- const tokenValid = this.envoyFirmware7xx ? await this.checkJwtToken() : false;
983
-
984
- //update grid profile
985
- const updateGridProfile = tokenValid ? await this.updateGridProfile() : false;
986
-
987
- //get envoy dev id
988
- const envoyDevIdExist = this.supportPowerProductionState ? await this.getEnvoyBackboneApp() : false;
989
-
990
- //get envoy info
991
- const updateInfo = await this.updateInfo();
992
-
993
- //calculate envoy and installer passwords
994
- const calculateEnvoyPassword = !this.envoyFirmware7xx && updateInfo ? await this.calculateEnvoyPassword() : false;
995
- const calculateInstallerPassword = !this.envoyFirmware7xx && updateInfo ? await this.calculateInstallerPassword() : false;
996
-
997
- //get home and inventory
998
- const refreshHome = updateInfo ? await this.updateHome() : false;
999
- const updateInventory = refreshHome ? await this.updateInventory() : false;
1000
-
1001
- //get meters
1002
- const refreshMeters = this.feature.meters.supported ? await this.updateMeters() : false;
1003
- const updateMetersReading = refreshMeters ? await this.updateMetersReading() : false;
1004
-
1005
- //acces with envoy password
1006
- const refreshMicroinverters = tokenValid || calculateEnvoyPassword ? await this.updateMicroinvertersStatus() : false;
1007
-
1008
- //get production and production ct
1009
- const refreshProduction = await this.updateProduction();
1010
- const updateProductionCt = refreshProduction ? await this.updateProductionCt() : false;
1011
-
1012
- //access with installer password and envoy dev id
1013
- const updatePowerProductionState = envoyDevIdExist && ((this.jwtToken.installer && tokenValid) || calculateInstallerPassword) ? await this.updateProductionPowerState() : false;
1014
-
1015
- //get ensemble data only FW. >= 7.x.x.
1016
- const refreshEnsemble = tokenValid ? await this.updateEnsembleInventory() : false;
1017
- const updateEnsembleStatus = refreshEnsemble ? await this.updateEnsembleStatus() : false;
1018
- const updateEnchargeSettings = refreshEnsemble ? await this.updateEnchargesSettings() : false;
1019
- const updateTariffSettings = refreshEnsemble ? await this.updateTariff() : false;
1020
- const updateDryContacts = refreshEnsemble ? await this.updateDryContacts() : false;
1021
- const updateDryContactsSettings = updateDryContacts ? await this.updateDryContactsSettings() : false;
1022
- const updateGenerator = refreshEnsemble ? await this.updateGenerator() : false;
1023
- const updateGeneratorSettings = updateGenerator ? await this.updateGeneratorSettings() : false;
1024
-
1025
- //get plc communication level
1026
- const updateCommLevel = this.supportPlcLevel && ((this.jwtToken.installer && tokenValid) || calculateInstallerPassword) ? await this.updateCommLevel() : false;
1027
- const refreshLiveData = tokenValid ? await this.updateLiveData() : false;
1028
-
1029
- //connect to deice success
1030
- this.emit('success', `Connect Success`)
1031
-
1032
- //get device info
1033
- const logDeviceInfo = !this.disableLogDeviceInfo ? this.getDeviceInfo() : false;
1034
-
1035
- //prepare accessory
1036
- const accessory = this.startPrepareAccessory ? await this.prepareAccessory() : false;
1037
- const publishAccessory = this.startPrepareAccessory ? this.emit('publishAccessory', accessory) : false;
1038
- this.startPrepareAccessory = false;
1039
-
1040
- //create timers and start impulse generator
1041
- this.timers = [];
1042
- const pushTimer0 = refreshHome ? this.timers.push({ name: 'updateHome', sampling: 60000 }) : false;
1043
- const pushTimer1 = refreshMeters ? this.timers.push({ name: 'updateMeters', sampling: this.metersDataRefreshTime }) : false;
1044
- const pushTimer3 = refreshMicroinverters ? this.timers.push({ name: 'updateMicroinvertersStatus', sampling: 80000 }) : false;
1045
- const pushTimer2 = refreshProduction ? this.timers.push({ name: 'updateProduction', sampling: this.productionDataRefreshTime }) : false;
1046
- const pushTimer4 = refreshEnsemble ? this.timers.push({ name: 'updateEnsemble', sampling: this.ensembleDataRefreshTime }) : false;
1047
- const pushTimer5 = refreshLiveData ? this.timers.push({ name: 'updateLiveData', sampling: this.liveDataRefreshTime }) : false;
1048
- await this.impulseGenerator.start(this.timers);
1049
-
1050
- return true;
1051
- } catch (error) {
1052
- throw new Error(`Start error: ${error}`);
1053
- };
1054
- };
1055
-
1056
977
  async checkJwtToken() {
1057
978
  const debug = this.enableDebugMode ? this.emit('debug', `Requesting check JWT token`) : false;
1058
979
 
@@ -4424,7 +4345,7 @@ class EnvoyDevice extends EventEmitter {
4424
4345
  const displayLog11 = this.feature.ensembles.installed || this.feature.enpowers.installed || this.feature.encharges.installed || this.feature.dryContacts.installed || this.feature.wirelessConnections.installed || this.feature.generators.installed ? this.emit('devInfo', `--------------------------------`) : false;
4425
4346
  };
4426
4347
 
4427
- //Prepare accessory
4348
+ //prepare accessory
4428
4349
  async prepareAccessory() {
4429
4350
  try {
4430
4351
  //suppored feature
@@ -6724,5 +6645,85 @@ class EnvoyDevice extends EventEmitter {
6724
6645
  throw new Error(`Prepare accessory error: ${error}`)
6725
6646
  };
6726
6647
  };
6648
+
6649
+ //start
6650
+ async start() {
6651
+ const debug = this.enableDebugMode ? this.emit('debug', `Start`) : false;
6652
+
6653
+ try {
6654
+ //get and validate jwt token
6655
+ const tokenValid = this.envoyFirmware7xx ? await this.checkJwtToken() : false;
6656
+
6657
+ //update grid profile
6658
+ const updateGridProfile = tokenValid ? await this.updateGridProfile() : false;
6659
+
6660
+ //get envoy dev id
6661
+ const envoyDevIdExist = this.supportPowerProductionState ? await this.getEnvoyBackboneApp() : false;
6662
+
6663
+ //get envoy info
6664
+ const updateInfo = await this.updateInfo();
6665
+
6666
+ //calculate envoy and installer passwords
6667
+ const calculateEnvoyPassword = !this.envoyFirmware7xx && updateInfo ? await this.calculateEnvoyPassword() : false;
6668
+ const calculateInstallerPassword = !this.envoyFirmware7xx && updateInfo ? await this.calculateInstallerPassword() : false;
6669
+
6670
+ //get home and inventory
6671
+ const refreshHome = updateInfo ? await this.updateHome() : false;
6672
+ const updateInventory = refreshHome ? await this.updateInventory() : false;
6673
+
6674
+ //get meters
6675
+ const refreshMeters = this.feature.meters.supported ? await this.updateMeters() : false;
6676
+ const updateMetersReading = refreshMeters ? await this.updateMetersReading() : false;
6677
+
6678
+ //acces with envoy password
6679
+ const refreshMicroinverters = tokenValid || calculateEnvoyPassword ? await this.updateMicroinvertersStatus() : false;
6680
+
6681
+ //get production and production ct
6682
+ const refreshProduction = await this.updateProduction();
6683
+ const updateProductionCt = refreshProduction ? await this.updateProductionCt() : false;
6684
+
6685
+ //access with installer password and envoy dev id
6686
+ const updatePowerProductionState = envoyDevIdExist && ((this.jwtToken.installer && tokenValid) || calculateInstallerPassword) ? await this.updateProductionPowerState() : false;
6687
+
6688
+ //get ensemble data only FW. >= 7.x.x.
6689
+ const refreshEnsemble = tokenValid ? await this.updateEnsembleInventory() : false;
6690
+ const updateEnsembleStatus = refreshEnsemble ? await this.updateEnsembleStatus() : false;
6691
+ const updateEnchargeSettings = refreshEnsemble ? await this.updateEnchargesSettings() : false;
6692
+ const updateTariffSettings = refreshEnsemble ? await this.updateTariff() : false;
6693
+ const updateDryContacts = refreshEnsemble ? await this.updateDryContacts() : false;
6694
+ const updateDryContactsSettings = updateDryContacts ? await this.updateDryContactsSettings() : false;
6695
+ const updateGenerator = refreshEnsemble ? await this.updateGenerator() : false;
6696
+ const updateGeneratorSettings = updateGenerator ? await this.updateGeneratorSettings() : false;
6697
+
6698
+ //get plc communication level
6699
+ const updateCommLevel = this.supportPlcLevel && ((this.jwtToken.installer && tokenValid) || calculateInstallerPassword) ? await this.updateCommLevel() : false;
6700
+ const refreshLiveData = tokenValid ? await this.updateLiveData() : false;
6701
+
6702
+ //connect to deice success
6703
+ this.emit('success', `Connect Success`)
6704
+
6705
+ //get device info
6706
+ const logDeviceInfo = !this.disableLogDeviceInfo ? this.getDeviceInfo() : false;
6707
+
6708
+ //prepare accessory
6709
+ const accessory = this.startPrepareAccessory ? await this.prepareAccessory() : false;
6710
+ const publishAccessory = this.startPrepareAccessory ? this.emit('publishAccessory', accessory) : false;
6711
+ this.startPrepareAccessory = false;
6712
+
6713
+ //create timers and start impulse generator
6714
+ this.timers = [];
6715
+ const pushTimer0 = refreshHome ? this.timers.push({ name: 'updateHome', sampling: 60000 }) : false;
6716
+ const pushTimer1 = refreshMeters ? this.timers.push({ name: 'updateMeters', sampling: this.metersDataRefreshTime }) : false;
6717
+ const pushTimer3 = refreshMicroinverters ? this.timers.push({ name: 'updateMicroinvertersStatus', sampling: 80000 }) : false;
6718
+ const pushTimer2 = refreshProduction ? this.timers.push({ name: 'updateProduction', sampling: this.productionDataRefreshTime }) : false;
6719
+ const pushTimer4 = refreshEnsemble ? this.timers.push({ name: 'updateEnsemble', sampling: this.ensembleDataRefreshTime }) : false;
6720
+ const pushTimer5 = refreshLiveData ? this.timers.push({ name: 'updateLiveData', sampling: this.liveDataRefreshTime }) : false;
6721
+ await this.impulseGenerator.start(this.timers);
6722
+
6723
+ return true;
6724
+ } catch (error) {
6725
+ throw new Error(`Start error: ${error}`);
6726
+ };
6727
+ };
6727
6728
  }
6728
6729
  export default EnvoyDevice;