homebridge-enphase-envoy 9.3.3 → 9.3.4-beta.1

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
@@ -112,20 +112,20 @@ class EnvoyPlatform {
112
112
  log.warn(`Device: ${host} ${deviceName}, ${message}`);
113
113
  })
114
114
  .on('error', async (error) => {
115
+ envoyDevice.impulseGenerator.stop();
115
116
  const errorData = JSON.stringify(error);
116
117
  const match = errorData.match(STATUSCODEREGEX);
117
118
  const tokenNotValid = envoyFirmware7xx && match && match[1] === '401';
118
119
  const displayError = tokenNotValid ? log(`Device: ${host} ${deviceName}, JWT token not valid, refreshing.`) : log.error(`Device: ${host} ${deviceName}, ${error}, trying again in 20s.`);
119
120
 
120
- envoyDevice.impulseGenerator.stop();
121
121
  await new Promise(resolve => setTimeout(resolve, 20000));
122
122
  envoyDevice.start();
123
123
  })
124
124
  .on('tokenExpired', async () => {
125
+ envoyDevice.impulseGenerator.stop();
125
126
  log.warn(`Device: ${host} ${deviceName}, JWT token expired, refreshing in 20s.`);
126
127
 
127
128
  //start read data
128
- envoyDevice.impulseGenerator.stop();
129
129
  await new Promise(resolve => setTimeout(resolve, 20000))
130
130
  envoyDevice.start();
131
131
  });
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.3",
5
+ "version": "9.3.4-beta.1",
6
6
  "description": "Homebridge plugin for Photovoltaic Energy System manufactured by Enphase.",
7
7
  "license": "MIT",
8
8
  "author": "grzegorz914",
@@ -583,6 +583,7 @@ class EnvoyDevice extends EventEmitter {
583
583
  this.envoyIdFile = envoyIdFile;
584
584
  this.envoyTokenFile = envoyTokenFile;
585
585
  this.envoyInstallerPasswordFile = envoyInstallerPasswordFile;
586
+ this.startRunning = false;
586
587
  this.startPrepareAccessory = true;
587
588
 
588
589
  //envoy dev id
@@ -945,9 +946,13 @@ class EnvoyDevice extends EventEmitter {
945
946
  async start() {
946
947
  const debug = this.enableDebugMode ? this.emit('debug', `Start.`) : false;
947
948
 
949
+ if (this.startRunning) {
950
+ return;
951
+ }
952
+
948
953
  try {
949
- //create timers array
950
- this.timers = [];
954
+ //set start runing
955
+ this.startRuning = true;
951
956
 
952
957
  //get and validate jwt token
953
958
  const getJwtToken = this.envoyFirmware7xx ? this.envoyFirmware7xxTokenGenerationMode === 0 ? await this.getJwtToken() : true : false;
@@ -1007,6 +1012,7 @@ class EnvoyDevice extends EventEmitter {
1007
1012
  this.startPrepareAccessory = false;
1008
1013
 
1009
1014
  //create timers and start impulse generator
1015
+ this.timers = [];
1010
1016
  const pushTimer0 = updateHome ? this.timers.push({ name: 'updateHome', sampling: 60000 }) : false;
1011
1017
  const pushTimer1 = updateMeters ? this.timers.push({ name: 'updateMeters', sampling: this.metersDataRefreshTime }) : false;
1012
1018
  const pushTimer3 = updateMicroinvertersStatus ? this.timers.push({ name: 'updateMicroinvertersStatus', sampling: 80000 }) : false;
@@ -1014,7 +1020,9 @@ class EnvoyDevice extends EventEmitter {
1014
1020
  const pushTimer4 = updateEnsemble ? this.timers.push({ name: 'updateEnsemble', sampling: this.ensembleDataRefreshTime }) : false;
1015
1021
  const pushTimer5 = updateLiveData ? this.timers.push({ name: 'updateLiveData', sampling: this.liveDataRefreshTime }) : false;
1016
1022
  this.impulseGenerator.start(this.timers);
1023
+ this.startRunning = false;
1017
1024
  } catch (error) {
1025
+ this.startRunning = false;
1018
1026
  this.emit('error', error);
1019
1027
  };
1020
1028
  };