homebridge-enphase-envoy 9.3.2 → 9.3.4-beta.0

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 CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [9.3.3] - (23.08.2024)
9
+
10
+ ## Changes
11
+
12
+ - fix [#151](https://github.com/grzegorz914/homebridge-enphase-envoy/issues/151)
13
+
8
14
  ## [9.3.0] - (23.08.2024)
9
15
 
10
16
  ## Changes
package/index.js CHANGED
@@ -117,7 +117,6 @@ class EnvoyPlatform {
117
117
  const tokenNotValid = envoyFirmware7xx && match && match[1] === '401';
118
118
  const displayError = tokenNotValid ? log(`Device: ${host} ${deviceName}, JWT token not valid, refreshing.`) : log.error(`Device: ${host} ${deviceName}, ${error}, trying again in 20s.`);
119
119
 
120
- envoyDevice.impulseGenerator.stop();
121
120
  await new Promise(resolve => setTimeout(resolve, 20000));
122
121
  envoyDevice.start();
123
122
  })
@@ -125,7 +124,6 @@ class EnvoyPlatform {
125
124
  log.warn(`Device: ${host} ${deviceName}, JWT token expired, refreshing in 20s.`);
126
125
 
127
126
  //start read data
128
- envoyDevice.impulseGenerator.stop();
129
127
  await new Promise(resolve => setTimeout(resolve, 20000))
130
128
  envoyDevice.start();
131
129
  });
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.3.2",
5
+ "version": "9.3.4-beta.0",
6
6
  "description": "Homebridge plugin for Photovoltaic Energy System manufactured by Enphase.",
7
7
  "license": "MIT",
8
8
  "author": "grzegorz914",
@@ -862,6 +862,7 @@ class EnvoyDevice extends EventEmitter {
862
862
  const updateMeters = tokenExpired ? false : await this.updateMeters();
863
863
  const updateMetersReading = updateMeters ? await this.updateMetersReading() : false;
864
864
  } catch (error) {
865
+ this.impulseGenerator.stop();
865
866
  this.emit('error', error);
866
867
  };
867
868
  }).on('updateMicroinvertersStatus', async () => {
@@ -869,6 +870,7 @@ class EnvoyDevice extends EventEmitter {
869
870
  const tokenExpired = await this.checkJwtToken();
870
871
  const updateMicroinvertersStatus = tokenExpired ? false : await this.updateMicroinvertersStatus();
871
872
  } catch (error) {
873
+ this.impulseGenerator.stop();
872
874
  this.emit('error', error);
873
875
  };
874
876
  }).on('updateProduction', async () => {
@@ -877,6 +879,7 @@ class EnvoyDevice extends EventEmitter {
877
879
  const updateProduction = tokenExpired ? false : await this.updateProduction();
878
880
  const updateProductionCt = updateProduction ? await this.updateProductionCt() : false;
879
881
  } catch (error) {
882
+ this.impulseGenerator.stop();
880
883
  this.emit('error', error);
881
884
  };
882
885
  }).on('updateEnsemble', async () => {
@@ -891,6 +894,7 @@ class EnvoyDevice extends EventEmitter {
891
894
  const updateGenerator = updateEnsemble ? await this.updateGenerator() : false;
892
895
  const updateGeneratorSettings = updateGenerator ? await this.updateGeneratorSettings() : false;
893
896
  } catch (error) {
897
+ this.impulseGenerator.stop();
894
898
  this.emit('error', error);
895
899
  };
896
900
  }).on('updateLiveData', async () => {
@@ -898,6 +902,7 @@ class EnvoyDevice extends EventEmitter {
898
902
  const tokenExpired = await this.checkJwtToken();
899
903
  const updateLiveData = tokenExpired ? false : await this.updateLiveData();
900
904
  } catch (error) {
905
+ this.impulseGenerator.stop();
901
906
  this.emit('error', error);
902
907
  };
903
908
  }).on('state', (state) => {
@@ -1025,6 +1030,7 @@ class EnvoyDevice extends EventEmitter {
1025
1030
  try {
1026
1031
  const tokenExpired = this.envoyFirmware7xx ? this.envoyFirmware7xxTokenGenerationMode === 0 ? (Math.floor(new Date().getTime() / 1000) > this.jwtToken.expires_at) : false : false;
1027
1032
  const refreshToken = tokenExpired ? this.emit('tokenExpired') : false;
1033
+ const stopImpulseGenerator = tokenExpired ? this.impulseGenerator.stop() : false;
1028
1034
  return tokenExpired;
1029
1035
  } catch (error) {
1030
1036
  throw new Error(`Requesting check JWT token error: ${error}`);
@@ -2603,7 +2609,7 @@ class EnvoyDevice extends EventEmitter {
2603
2609
  this.ensemble.encharges = encharges;
2604
2610
 
2605
2611
  //calculate encharges percent full summ
2606
- this.ensemble.encharges.percentFullSum = (enchargesPercentFullSummary.reduce((total, num) => total + num, 0) / enchargesCount) ?? 0;
2612
+ this.ensemble.encharges.percentFullSum = (enchargesPercentFullSummary.reduce((total, num) => total + num, 0) / enchargesData.length) ?? 0;
2607
2613
  this.ensemble.encharges.energyState = this.ensemble.encharges.percentFullSum > 0;
2608
2614
 
2609
2615
  //update services