homebridge-tauron-elicznik 0.0.2-beta45 → 0.0.2-beta49
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 +29 -11
- 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,29 @@ 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
|
+
baseURL: LOGIN_URL,
|
147
|
+
data: data,
|
148
|
+
headers: headers,
|
149
|
+
httpsAgent: new https.Agent({
|
150
|
+
cert: fs.readFileSync('user.cert'),
|
151
|
+
key: fs.readFileSync('user.key'),
|
152
|
+
passphrase: 'secret',
|
153
|
+
rejectUnauthorized: false
|
154
|
+
}),
|
155
|
+
});
|
156
|
+
|
133
157
|
const prefDir = path.join(api.user.storagePath(), 'eLicznik');
|
134
158
|
|
135
159
|
//check if the directory exists, if not then create it
|
@@ -174,19 +198,13 @@ class eLicznikDevice {
|
|
174
198
|
|
175
199
|
async updateDeviceState() {
|
176
200
|
this.log.debug('Device: %s %s, requesting Device state.', this.meterId, this.name);
|
201
|
+
const url = CHARTS_URL + '?dane[chartYear]=2021&dane[paramType]=year&dane[checkOZE]=on&dane[smartNr]=' + this.meterId;
|
177
202
|
try {
|
178
|
-
const
|
179
|
-
|
180
|
-
|
181
|
-
service: SERVICE_URL
|
182
|
-
});
|
183
|
-
const headers = {
|
184
|
-
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
|
203
|
+
const options = {
|
204
|
+
method: 'GET',
|
205
|
+
url: url
|
185
206
|
};
|
186
|
-
const response = await
|
187
|
-
data,
|
188
|
-
headers
|
189
|
-
);
|
207
|
+
const response = await this.axiosInstance(options);
|
190
208
|
|
191
209
|
this.log(response)
|
192
210
|
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-
|
4
|
+
"version": "0.0.2-beta49",
|
5
5
|
"description": "Homebridge plugin (https://github.com/homebridge/homebridge) to read data from Tauron eLicznik.",
|
6
6
|
"license": "MIT",
|
7
7
|
"author": "grzegorz914",
|