homebridge-tauron-elicznik 0.0.2-beta45 → 0.0.2-beta46

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.
Files changed (2) hide show
  1. package/index.js +22 -12
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  const path = require('path');
4
4
  const axios = require('axios');
5
+ const https = require('https');
5
6
  const qs = require('qs');
6
7
  const fs = require('fs');
7
8
  const fsPromises = require('fs').promises;
@@ -130,6 +131,25 @@ class eLicznikDevice {
130
131
  this.energyImport = 0;
131
132
  this.energyExport = 0;
132
133
 
134
+ const data = qs.stringify({
135
+ username: this.user,
136
+ password: this.passwd,
137
+ service: SERVICE_URL
138
+ });
139
+
140
+ const headers = {
141
+ 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
142
+ };
143
+
144
+ this.axiosInstance = axios.create({
145
+ method: 'POST',
146
+ data: data,
147
+ headers: headers,
148
+ httpsAgent: new https.Agent({
149
+ rejectUnauthorized: false
150
+ }),
151
+ });
152
+
133
153
  const prefDir = path.join(api.user.storagePath(), 'eLicznik');
134
154
 
135
155
  //check if the directory exists, if not then create it
@@ -175,18 +195,8 @@ class eLicznikDevice {
175
195
  async updateDeviceState() {
176
196
  this.log.debug('Device: %s %s, requesting Device state.', this.meterId, this.name);
177
197
  try {
178
- const data = qs.stringify({
179
- username: this.user,
180
- password: this.passwd,
181
- service: SERVICE_URL
182
- });
183
- const headers = {
184
- 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
185
- };
186
- const response = await axios.post(LOGIN_URL,
187
- data,
188
- headers
189
- );
198
+
199
+ const response = await this.axiosInstance(CHARTS_URL);
190
200
 
191
201
  this.log(response)
192
202
  const energyImport = 0;
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-beta45",
4
+ "version": "0.0.2-beta46",
5
5
  "description": "Homebridge plugin (https://github.com/homebridge/homebridge) to read data from Tauron eLicznik.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",