From c8b9fb74e2b40b5c2de5568be7b11e37742899c0 Mon Sep 17 00:00:00 2001 From: DEV2DEV_DE Date: Tue, 28 Nov 2023 08:12:21 +0100 Subject: [PATCH] Fix session ID retrieval and add debug logs --- main.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index f7e37fb..5d7db56 100644 --- a/main.js +++ b/main.js @@ -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'] 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'); @@ -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));