homebridge-enphase-envoy 9.3.4-beta.2 → 9.3.4-beta.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/index.js CHANGED
@@ -114,18 +114,11 @@ 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 in 20s.`);
118
119
 
119
120
  await new Promise(resolve => setTimeout(resolve, 20000));
120
121
  envoyDevice.start();
121
- })
122
- .on('tokenExpired', async () => {
123
- envoyDevice.impulseGenerator.stop();
124
- log.warn(`Device: ${host} ${deviceName}, JWT token expired, refreshing in 20s.`);
125
-
126
- //start read data
127
- await new Promise(resolve => setTimeout(resolve, 20000))
128
- envoyDevice.start();
129
122
  });
130
123
  }
131
124
  });
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.3",
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}`);