Skip to content

Commit

Permalink
Additional logging for #4
Browse files Browse the repository at this point in the history
  • Loading branch information
robertraaijmakers committed Feb 23, 2025
1 parent bb2a89c commit b26ba90
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .homeychangelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"1.0.3": {
"en": "New version, better error handling, supporting more capabilities and updating settings with flow cards."
},
"1.0.4": {
"1.0.5": {
"en": "Added possible fix for an issue that the login got stuck and the app crashes after a while."
}
}
2 changes: 1 addition & 1 deletion .homeycompose/app.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "com.alfen",
"version": "1.0.4",
"version": "1.0.5",
"compatibility": ">=12.0.0",
"sdk": 3,
"platforms": [
Expand Down
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"_comment": "This file is generated. Please edit .homeycompose/app.json instead.",
"id": "com.alfen",
"version": "1.0.4",
"version": "1.0.5",
"compatibility": ">=12.0.0",
"sdk": 3,
"platforms": [
Expand Down
15 changes: 12 additions & 3 deletions lib/AlfenApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,12 @@ export class AlfenApi {
const response = await this.#httpsPromise({ ...options, body });

// Handle the response
this.#log('Login successful:', response.body);
this.#log('Login successful:', response);
} catch (error) {
this.#agent = null;
this.#retrieving = 0;

this.#log('Login failed:', error);
throw new Error(`Login failed: ${error}`);
}
}
Expand Down Expand Up @@ -122,13 +126,18 @@ export class AlfenApi {
try {
// Make the HTTPS request using the httpsPromise method
const response = await this.#httpsPromise(options);
this.#log('Logout successful: ', response);

this.#agent?.destroy();
this.#agent = null;

// Handle the response
this.#log('Logout successful:', response.body);
this.#log('Agent destroyed');
} catch (error) {
this.#agent = null;
this.#log('Logout failed:', error);
this.#agent?.destroy();
} finally {
this.#agent = null;
}
}

Expand Down
2 changes: 2 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"compilerOptions": {
"allowJs": true,
"outDir": ".homeybuild/",
"target": "es6",
"lib": ["es6"],
"strict": true,
"esModuleInterop": true
}
Expand Down

0 comments on commit b26ba90

Please sign in to comment.