homebridge-tauron-elicznik 0.0.2-beta52 → 0.0.2-beta56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -134,15 +134,18 @@ class eLicznikDevice {
134
134
  this.energyImport = 0;
135
135
  this.energyExport = 0;
136
136
 
137
- const authData = {
137
+ const options = {
138
+ method: 'POST',
139
+ baseURL: LOGIN_URL,
138
140
  username: this.user,
139
141
  password: this.passwd,
140
142
  service: SERVICE_URL
141
143
  };
142
144
 
145
+
143
146
  //digest auth installer
144
147
  this.tauronAuth = new axiosTauronAuth({
145
- data: authData
148
+ data: options
146
149
  });
147
150
 
148
151
  const prefDir = path.join(api.user.storagePath(), 'eLicznik');
@@ -191,16 +194,6 @@ class eLicznikDevice {
191
194
  this.log.debug('Device: %s %s, requesting Device state.', this.meterId, this.name);
192
195
  const url = CHARTS_URL + '?dane[chartYear]=2021&dane[paramType]=year&dane[checkOZE]=on&dane[smartNr]=' + this.meterId;
193
196
  try {
194
- this.axiosInstance = axios.create({
195
- method: 'POST',
196
- baseURL: LOGIN_URL,
197
- data: data,
198
- headers: HEADERS,
199
- httpsAgent: new https.Agent({
200
- rejectUnauthorized: false
201
- }),
202
- });
203
-
204
197
  const options = {
205
198
  method: 'POST',
206
199
  url: CHARTS_URL,
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-beta52",
4
+ "version": "0.0.2-beta56",
5
5
  "description": "Homebridge plugin (https://github.com/homebridge/homebridge) to read data from Tauron eLicznik.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
package/src/tauronAuth.js CHANGED
@@ -1,29 +1,29 @@
1
1
  "use strict";
2
2
  const axios = require('axios');
3
- const qs = require('qs');
4
- let count = 0;
5
3
 
6
4
  class axiosTauronAuth {
7
5
  constructor({
8
- username,
9
- password,
10
- service
6
+ options
11
7
  }) {
12
- this.username = username;
13
- this.password = password;
14
- this.service = service;
8
+ this.method = options.method;
9
+ this.baseUrl = options.baseURL;
10
+ this.username = options.username;
11
+ this.password = options.password;
12
+ this.service = options.service;
15
13
  }
16
14
 
17
15
  async request() {
18
16
  try {
19
- const authData = qs.stringify({
17
+ const options = {
18
+ method: this.method,
19
+ baseURL: this.baseUrl,
20
20
  username: this.username,
21
21
  password: this.password,
22
22
  service: this.service
23
- });
24
- const authUrl = await axios.request(authData);
25
- console.log(authUrl)
26
- return authUrl;
23
+ };
24
+ const response = await axios(options);
25
+ console.log(response)
26
+ return response;
27
27
  } catch (err) {}
28
28
  return err
29
29
  };