homebridge-enphase-envoy 9.4.3 → 9.4.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/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ 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.4.3] - (18.11.2024)
9
+
10
+ ## Changes
11
+
12
+ - fix data refresh after error occured
13
+ - fix validate own token
14
+
8
15
  ## [9.4.3] - (17.11.2024)
9
16
 
10
17
  ## Changes
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.4.3",
5
+ "version": "9.4.4",
6
6
  "description": "Homebridge plugin for Photovoltaic Energy System manufactured by Enphase.",
7
7
  "license": "MIT",
8
8
  "author": "grzegorz914",
@@ -964,8 +964,7 @@ class EnvoyDevice extends EventEmitter {
964
964
  handleError(error) {
965
965
  const errorString = error.toString();
966
966
  const tokenNotValid = errorString.includes('status code 401');
967
- const emitError = tokenNotValid ? false : this.emit('error', `Impulse generator: ${error}`);
968
- this.checkJwtTokenRunning = !tokenNotValid;
967
+ const emitError = tokenNotValid ? this.checkJwtTokenRunning = false : this.emit('error', `Impulse generator: ${error}`);
969
968
  };
970
969
 
971
970
  async start() {
@@ -980,7 +979,7 @@ class EnvoyDevice extends EventEmitter {
980
979
  this.refreshLiveData = false;
981
980
 
982
981
  //get and validate jwt token
983
- const tokenValid = this.envoyFirmware7xx ? this.envoyFirmware7xxTokenGenerationMode === 0 ? await this.checkJwtToken() : true : false;
982
+ const tokenValid = this.envoyFirmware7xx ? await this.checkJwtToken() : false;
984
983
 
985
984
  //update grid profile
986
985
  const updateGridProfile = tokenValid ? await this.updateGridProfile() : false;
@@ -1057,10 +1056,19 @@ class EnvoyDevice extends EventEmitter {
1057
1056
  async checkJwtToken() {
1058
1057
  const debug = this.enableDebugMode ? this.emit('debug', `Requesting check JWT token.`) : false;
1059
1058
 
1060
- if (!this.envoyFirmware7xx || (this.envoyFirmware7xx && this.envoyFirmware7xxTokenGenerationMode === 1)) {
1059
+ if (!this.envoyFirmware7xx) {
1061
1060
  return true;
1062
1061
  };
1063
1062
 
1063
+ if (this.envoyFirmware7xxTokenGenerationMode === 1) {
1064
+ try {
1065
+ await this.validateJwtToken();
1066
+ return true;
1067
+ } catch (error) {
1068
+ throw new Error(`Check own JWT token error: ${error.message || error}`);
1069
+ };
1070
+ };
1071
+
1064
1072
  if (this.checkJwtTokenRunning) {
1065
1073
  return false;
1066
1074
  };
@@ -1090,7 +1098,7 @@ class EnvoyDevice extends EventEmitter {
1090
1098
  return validateToken;
1091
1099
  } catch (error) {
1092
1100
  this.checkJwtTokenRunning = false;
1093
- throw new Error(`Chack JWT token error: ${error.message || error}`);
1101
+ throw new Error(`Check JWT token error: ${error.message || error}`);
1094
1102
  };
1095
1103
  };
1096
1104