homebridge-enphase-envoy 9.3.4-beta.2 → 9.3.4-beta.4

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
@@ -114,17 +114,12 @@ class EnvoyPlatform {
114
114
  .on('error', async (error) => {
115
115
  envoyDevice.impulseGenerator.stop();
116
116
  const tokenNotValid = envoyFirmware7xx && error.includes('status code 401');
117
- const displayError = tokenNotValid ? log.warn(`Device: ${host} ${deviceName}, JWT token not valid, refreshing.`) : log.error(`Device: ${host} ${deviceName}, ${error}, trying again in 20s.`);
117
+ const tokenExpired = envoyFirmware7xx && error.includes('JWT token expired');
118
+ const displayError = tokenNotValid ? log.warn(`Device: ${host} ${deviceName}, JWT token not valid, refreshing.`) : tokenExpired ? log.warn(`Device: ${host} ${deviceName}, ${error}, refreshing.`) : log.error(`Device: ${host} ${deviceName}, ${error}, trying again.`);
118
119
 
119
- await new Promise(resolve => setTimeout(resolve, 20000));
120
- envoyDevice.start();
121
- })
122
- .on('tokenExpired', async () => {
123
- envoyDevice.impulseGenerator.stop();
124
- log.warn(`Device: ${host} ${deviceName}, JWT token expired, refreshing in 20s.`);
125
120
 
126
- //start read data
127
- await new Promise(resolve => setTimeout(resolve, 20000))
121
+ //wait 20s and try again
122
+ await new Promise(resolve => setTimeout(resolve, 20000));
128
123
  envoyDevice.start();
129
124
  });
130
125
  }
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.4-beta.2",
5
+ "version": "9.3.4-beta.4",
6
6
  "description": "Homebridge plugin for Photovoltaic Energy System manufactured by Enphase.",
7
7
  "license": "MIT",
8
8
  "author": "grzegorz914",
@@ -1032,7 +1032,7 @@ class EnvoyDevice extends EventEmitter {
1032
1032
 
1033
1033
  try {
1034
1034
  const tokenExpired = this.envoyFirmware7xx ? this.envoyFirmware7xxTokenGenerationMode === 0 ? (Math.floor(new Date().getTime() / 1000) > this.jwtToken.expires_at) : false : false;
1035
- const refreshToken = tokenExpired ? this.emit('tokenExpired') : false;
1035
+ const refreshToken = tokenExpired ? this.emit('error', 'JWT token expired') : false;
1036
1036
  return tokenExpired;
1037
1037
  } catch (error) {
1038
1038
  throw new Error(`Requesting check JWT token error: ${error}`);
package/src/restful.js CHANGED
@@ -30,7 +30,7 @@ class RestFul extends EventEmitter {
30
30
  microinverters: 'This data is not available in your system.',
31
31
  powerMode: 'This data is not available in your system.',
32
32
  plcLevel: 'This data is not available in your system.',
33
- datasampling: 'This data is not available in your system.'
33
+ dataSampling: 'This data is not available in your system.'
34
34
  };
35
35
 
36
36
  this.connect();