homebridge-tauron-elicznik 0.0.2-beta12 → 0.0.2-beta16
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 +26 -18
- package/package.json +1 -1
package/index.js
CHANGED
@@ -5,6 +5,7 @@ const axios = require('axios');
|
|
5
5
|
const fs = require('fs');
|
6
6
|
const fsPromises = require('fs').promises;
|
7
7
|
const qs = require('qs')
|
8
|
+
const https = require('https');
|
8
9
|
|
9
10
|
const PLUGIN_NAME = 'homebridge-tauron-elicznik';
|
10
11
|
const PLATFORM_NAME = 'tauroneLicznik';
|
@@ -137,22 +138,6 @@ class eLicznikDevice {
|
|
137
138
|
fsPromises.mkdir(prefDir);
|
138
139
|
}
|
139
140
|
|
140
|
-
const data = qs.stringify({
|
141
|
-
'username': this.user,
|
142
|
-
'password': this.password,
|
143
|
-
"service": SERVICE_URL
|
144
|
-
});
|
145
|
-
|
146
|
-
this.axiosInstance = axios.create({
|
147
|
-
method: 'POST',
|
148
|
-
baseURL: LOGIN_URL,
|
149
|
-
headers: {
|
150
|
-
"cache-control": "no-cache"
|
151
|
-
},
|
152
|
-
data: data,
|
153
|
-
timeout: 5000,
|
154
|
-
});
|
155
|
-
|
156
141
|
//Check device state
|
157
142
|
setInterval(function () {
|
158
143
|
if (this.checkDeviceInfo) {
|
@@ -193,7 +178,30 @@ class eLicznikDevice {
|
|
193
178
|
try {
|
194
179
|
const CHART_DATA_URL = CHARTS_URL + '?dane[chartYear]=2020&dane[paramType]=year&dane[smartNr]=' + this.meterId + '&dane[checkOZE]=on';
|
195
180
|
|
196
|
-
const
|
181
|
+
const headers = {
|
182
|
+
"cache-control": "no-cache"
|
183
|
+
}
|
184
|
+
|
185
|
+
const data = qs.stringify({
|
186
|
+
'username': this.user,
|
187
|
+
'password': this.password,
|
188
|
+
"service": SERVICE_URL
|
189
|
+
});
|
190
|
+
|
191
|
+
const response1 = await axios.request({
|
192
|
+
method: 'POST',
|
193
|
+
baseURL: LOGIN_URL,
|
194
|
+
data: data,
|
195
|
+
headers: headers,
|
196
|
+
httpsAgent: new https.Agent({ rejectUnauthorized: false }),
|
197
|
+
});
|
198
|
+
this.log(response1.data)
|
199
|
+
|
200
|
+
const response = await axios.requeste({
|
201
|
+
method: 'POST',
|
202
|
+
baseURL: CHART_DATA_URL,
|
203
|
+
headers: headers
|
204
|
+
});
|
197
205
|
this.log.debug('Device: %s %s, debug response: %s', this.meterId, this.name, response.data);
|
198
206
|
const energyImport = response.data;
|
199
207
|
this.log(response.data)
|
@@ -201,7 +209,7 @@ class eLicznikDevice {
|
|
201
209
|
if (this.tauroneLicznikEnergyService) {
|
202
210
|
this.tauroneLicznikEnergyService
|
203
211
|
.updateCharacteristic(Characteristic.tauroneLicznikEnergyImport, energyImport)
|
204
|
-
.updateCharacteristic(Characteristic.
|
212
|
+
.updateCharacteristic(Characteristic.tauroneLicznikEnergyExport, energyExport);
|
205
213
|
}
|
206
214
|
this.energyImport = energyImport;
|
207
215
|
this.energyExport = energyExport;
|
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-
|
4
|
+
"version": "0.0.2-beta16",
|
5
5
|
"description": "Homebridge plugin (https://github.com/homebridge/homebridge) to read data from Tauron eLicznik.",
|
6
6
|
"license": "MIT",
|
7
7
|
"author": "grzegorz914",
|