Skip to content

Commit

Permalink
2.0.1 - Bug fixes
Browse files Browse the repository at this point in the history
- Fixed bug where crypto not defined
- Fixed incorrect spa heater state
- Optimised speed when loading all characteristics
  • Loading branch information
BlaT2512 committed Nov 4, 2023
1 parent f2b47c8 commit 2c497a5
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 48 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"displayName": "Homebridge SpaNET",
"name": "homebridge-spanet",
"version": "2.0.0",
"version": "2.0.1",
"description": "Homebridge plugin to control Australian SpaNET spa's with the WiFi SpaLINK plugin module",
"license": "Apache-2.0",
"repository": {
Expand Down
21 changes: 14 additions & 7 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class SpaNETHomebridgePlatform implements DynamicPlatformPlugin {

this.api.on('didFinishLaunching', () => {
log.debug('Executed didFinishLaunching callback');
this.userdeviceid = crypto.randomUUID();
this.userdeviceid = this.uuid();
// Check if the spa is linked and register it's accessories
this.registerDevices();
});
Expand All @@ -39,9 +39,9 @@ export class SpaNETHomebridgePlatform implements DynamicPlatformPlugin {

spanetapi = setupCache(axiosRateLimit(this.baseapi, { maxRPS: 3 }), {
headerInterpreter: () => {
return 1;
return 6;
},
storage: buildMemoryStorage ( false, 1000, false ),
storage: buildMemoryStorage ( false, 6000, false ),
});

accessToken = '';
Expand Down Expand Up @@ -69,7 +69,7 @@ export class SpaNETHomebridgePlatform implements DynamicPlatformPlugin {
// Parse through user config and check that the user and selected spa are valid
if (this.config.email !== '' && this.config.password !== '' && this.config.spaName !== '') {

// First, login to API with their username and encrypted password key to see if the user exists, otherwise cancel registration
// First, login to API with their email and password to see if the user exists, otherwise cancel registration
this.spanetapi.post('/Login/Authenticate', {
'email': this.config.email,
'password': this.config.password,
Expand Down Expand Up @@ -137,18 +137,18 @@ export class SpaNETHomebridgePlatform implements DynamicPlatformPlugin {
this.log.info('Logged in successfully, fetch data for ' + this.config.spaName + '...');

// Request spa pumps and blower details
this.spanetapi.get('/PumpsAndBlower/Get/' + this.spaId)
this.spanetapi.get('/PumpsAndBlower/Get/' + this.spaId, { id: 'PumpsAndBlower' })
.then((response) => {
const blowerId = response.data.pumpAndBlower.blower.id;
const pumps = response.data.pumpAndBlower.pumps;

// Request spa lights details
this.spanetapi.get('/Lights/GetLightDetails/' + this.spaId)
this.spanetapi.get('/Lights/GetLightDetails/' + this.spaId, { id: 'LightDetails' })
.then((response) => {
const lightId = response.data.lightId;

// Request spa sleep timers details
this.spanetapi.get('/SleepTimers/' + this.spaId)
this.spanetapi.get('/SleepTimers/' + this.spaId, { id: 'SleepTimers' })
.then((response) => {
const sleepTimers = response.data;

Expand Down Expand Up @@ -276,4 +276,11 @@ export class SpaNETHomebridgePlatform implements DynamicPlatformPlugin {
const exp = decoded.exp;
return exp;
}

uuid(): string {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
const r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
}
Loading

0 comments on commit 2c497a5

Please sign in to comment.