Skip to content

Commit

Permalink
release 9.5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
grzegorz914 committed Nov 28, 2024
1 parent 808eafc commit 1c12faa
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 19 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [9.5.2] - (28.11.2024)

## Changes

- fix display duplicate credentials in UI
- better handle cookie and token
- bump dependencies
- config schema updated
- cleanup

## [9.5.1] - (20.11.2024)

## Changes

- fix reference error before initialization

## [9.5.0] - (19.11.2024)

## Changes
Expand Down
4 changes: 2 additions & 2 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2626,11 +2626,11 @@
"items": [
"devices[].envoyFirmware7xxTokenGenerationMode",
{
"key": "devices[].enlightenPasswd",
"key": "devices[].envoyPasswd",
"type": "password"
},
{
"key": "devices[].envoyPasswd",
"key": "devices[].envoyToken",
"type": "password"
},
{
Expand Down
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": false,
"displayName": "Enphase Envoy",
"name": "homebridge-enphase-envoy",
"version": "9.5.1",
"version": "9.5.2",
"description": "Homebridge plugin for Photovoltaic Energy System manufactured by Enphase.",
"license": "MIT",
"author": "grzegorz914",
Expand Down Expand Up @@ -33,7 +33,7 @@
},
"dependencies": {
"async-mqtt": "^2.6.3",
"axios": "^1.7.7",
"axios": "^1.7.8",
"express": "^4.21.1",
"fast-xml-parser": "^4.5.0"
},
Expand Down
15 changes: 10 additions & 5 deletions src/envoydevice.js
Original file line number Diff line number Diff line change
Expand Up @@ -1081,17 +1081,22 @@ class EnvoyDevice extends EventEmitter {
parsedData.token ? parsedData : null;
const tokenValid = parsedData && parsedData.expires_at >= Math.floor(Date.now() / 1000) + 60;
const cookieValid = this.cookie === this.oldCookie;
const debug = this.enableDebugMode ? this.emit('warn', `JWT Token valid: ${tokenValid}, cookie valid: ${cookieValid}`) : false;
const debug = this.enableDebugMode ? this.emit('warn', `JWT Token: ${tokenValid ? 'Valid' : 'Not valid'}, cookie: ${cookieValid ? 'Valid' : 'Not valid'}`) : false;

if (tokenValid && cookieValid) {
this.checkJwtTokenRunning = false;
return true;
}

//JWT token
const emit = !tokenValid ? this.emit('warn', `JWT Token expired, refreshing.`) : false;
const wait = !tokenValid ? await new Promise(resolve => setTimeout(resolve, 30000)) : false;
const getToken = await this.getJwtToken();
const validateToken = getToken ? await this.validateJwtToken() : false;

//Cookie
const wait1 = !cookieValid ? await new Promise(resolve => setTimeout(resolve, 2000)) : false;
const emit1 = !cookieValid ? this.emit('warn', `Cookie not valid, refreshing.`) : false;
const validateToken = getToken || !cookieValid ? await this.validateJwtToken() : false;

this.checkJwtTokenRunning = false;
return validateToken;
Expand Down Expand Up @@ -1158,7 +1163,7 @@ class EnvoyDevice extends EventEmitter {
keepAlive: false,
rejectUnauthorized: false
}),
timeout: 20000
timeout: 25000
};

const response = await axios(CONSTANTS.ApiUrls.CheckJwt, options);
Expand All @@ -1178,11 +1183,11 @@ class EnvoyDevice extends EventEmitter {
keepAlive: false,
rejectUnauthorized: false
}),
timeout: 20000
timeout: 25000
});

this.oldCookie = this.cookie;
this.emit('success', `JWT Token valid: ${new Date(this.jwtToken.expires_at * 1000).toLocaleString()}`);
this.emit('success', `Cookie refresh success.`);

return true;
} catch (error) {
Expand Down
1 change: 1 addition & 0 deletions src/envoytoken.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class EnvoyToken extends EventEmitter {

//emit success
this.emit('success', `JWT Token refresh success.`);
this.emit('success', `JWT Token valid: ${new Date(tokenData.expires_at * 1000).toLocaleString()}`);

return tokenData;
} catch (error) {
Expand Down

0 comments on commit 1c12faa

Please sign in to comment.