Skip to content

Commit

Permalink
Fix session ID retrieval and add debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
DEV2DEV-DE committed Nov 28, 2023
1 parent da9bb03 commit c8b9fb7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ class Jablotron extends utils.Adapter {
const cookie = response.headers['set-cookie'];
if (cookie) {
const sessionId = cookie.toString().split(';')[0];
const serviceId = response.data['data']['service-data']['service-detail']['service-id']

Check failure on line 93 in main.js

View workflow job for this annotation

GitHub Actions / check-and-lint

Missing semicolon
this.log.debug('Session-ID: ' + sessionId);
await this.parseResponse(response.data['data']['service-data']);
// if (firstStart) await this.getExtendedData(headers, response.data['data']['service-data']['service-id']);
if (firstStart) await this.getExtendedData(headers, sessionId, serviceId);
return sessionId;
} else {
this.log.error('No session id found');
Expand All @@ -107,14 +108,16 @@ class Jablotron extends utils.Adapter {
}
}

async getExtendedData(headers, serviceId) {
async getExtendedData(headers, cookie, serviceId) {
this.log.debug('Fetching extended data with serviceID: ' + serviceId);
let payload = {
'connect-device': true,
'list-type': 'FULL',
'service-id': serviceId,
'service-states': true
};
headers['Cookie'] = this.sessionId;
headers['Cookie'] = cookie;
this.log.debug('Headers: ' + JSON.stringify(headers));
let url = `${baseUrl}/JA100/sectionsGet.json`;
let response = await axios.post(url, payload, { headers });
this.log.debug('sectionsGet: ' + JSON.stringify(response.data));
Expand Down

0 comments on commit c8b9fb7

Please sign in to comment.