homebridge-tauron-elicznik 0.0.2-beta80 → 0.0.2-beta84

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/index.js +16 -7
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -4,6 +4,7 @@ const path = require('path');
4
4
  const axios = require('axios');
5
5
  const axiosTauronAuth = require('./src/tauronAuth.js');
6
6
  const https = require('https');
7
+ const qs = require('qs');
7
8
  const fs = require('fs');
8
9
  const fsPromises = fs.promises;
9
10
 
@@ -11,10 +12,10 @@ const PLUGIN_NAME = 'homebridge-tauron-elicznik';
11
12
  const PLATFORM_NAME = 'tauroneLicznik';
12
13
 
13
14
  const SERVICE_URL = 'https://elicznik.tauron-dystrybucja.pl';
14
- const LOGIN_URL = 'https://logowanie.tauron-dystrybucja.pl/login?service=https://elicznik.tauron-dystrybucja.pl';
15
+ const LOGIN_URL = 'https://logowanie.tauron-dystrybucja.pl/login';
15
16
  const CHARTS_URL = 'https://elicznik.tauron-dystrybucja.pl/index/charts';
16
17
  const HEADERS = {
17
- 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0'
18
+ 'content-type': 'application/x-www-form-urlencoded'
18
19
  };
19
20
 
20
21
  let Accessory, Characteristic, Service, Categories, UUID;
@@ -134,7 +135,7 @@ class eLicznikDevice {
134
135
  this.energyImport = 0;
135
136
  this.energyExport = 0;
136
137
 
137
- const data = {
138
+ const payload = {
138
139
  username: this.user,
139
140
  password: this.passwd,
140
141
  service: SERVICE_URL
@@ -142,7 +143,7 @@ class eLicznikDevice {
142
143
 
143
144
  //auth
144
145
  this.tauronAuth = new axiosTauronAuth({
145
- data: data
146
+ data: payload
146
147
  });
147
148
 
148
149
  const prefDir = path.join(api.user.storagePath(), 'eLicznik');
@@ -192,15 +193,23 @@ class eLicznikDevice {
192
193
  try {
193
194
  const url = CHARTS_URL + '?dane[chartYear]=2021&dane[paramType]=year&dane[checkOZE]=on&dane[smartNr]=' + this.meterId;
194
195
 
195
- const data = {
196
+ const agent = new https.Agent({
197
+ rejectUnauthorized: false
198
+ });
199
+
200
+ const payload = {
196
201
  username: this.username,
197
202
  password: this.password,
198
203
  service: SERVICE_URL
199
204
  };
200
205
  const options = {
201
- data: data
206
+ method: 'POST',
207
+ headers: HEADERS,
208
+ data: qs.stringify(payload),
209
+ httpsAgent: agent,
210
+ url: LOGIN_URL
202
211
  };
203
- const response = await axios.post(LOGIN_URL, options);
212
+ const response = await axios(options);
204
213
 
205
214
  //const response = await this.tauronAuth.request(url);
206
215
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Tauron eLicznik",
3
3
  "name": "homebridge-tauron-elicznik",
4
- "version": "0.0.2-beta80",
4
+ "version": "0.0.2-beta84",
5
5
  "description": "Homebridge plugin (https://github.com/homebridge/homebridge) to read data from Tauron eLicznik.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",