homebridge-tauron-elicznik 0.0.2-beta92 → 0.0.3-beta.1
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 +16 -19
- package/package.json +3 -3
package/index.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
3
|
const path = require('path');
|
4
|
-
const urllib = require('urllib');
|
5
4
|
const fs = require('fs');
|
6
5
|
const fsPromises = fs.promises;
|
6
|
+
const axios = require('axios');
|
7
7
|
|
8
8
|
const PLUGIN_NAME = 'homebridge-tauron-elicznik';
|
9
9
|
const PLATFORM_NAME = 'tauroneLicznik';
|
@@ -148,11 +148,6 @@ class eLicznikDevice {
|
|
148
148
|
this.updateDeviceState();
|
149
149
|
}
|
150
150
|
}.bind(this), this.refreshInterval * 1000);
|
151
|
-
|
152
|
-
//start prepare accessory
|
153
|
-
if (this.startPrepareAccessory) {
|
154
|
-
this.prepareAccessory();
|
155
|
-
}
|
156
151
|
}
|
157
152
|
|
158
153
|
async getDeviceInfo() {
|
@@ -177,23 +172,20 @@ class eLicznikDevice {
|
|
177
172
|
async updateDeviceState() {
|
178
173
|
this.log.debug('Device: %s %s, requesting Device state.', this.meterId, this.name);
|
179
174
|
try {
|
180
|
-
const url = CHARTS_URL
|
181
|
-
|
182
|
-
const token = Buffer.from(`${this.user}:${this.passwd}`, 'utf8').toString('base64')
|
183
|
-
|
184
|
-
const payload = {
|
185
|
-
username: this.user,
|
186
|
-
password: this.passwd,
|
187
|
-
service: SERVICE_URL
|
188
|
-
};
|
175
|
+
const url = `${CHARTS_URL}?dane[chartYear]=2021&dane[paramType]=year&dane[checkOZE]=on&dane[smartNr]=${this.meterId}`;
|
189
176
|
const options = {
|
190
177
|
method: 'POST',
|
191
|
-
|
192
|
-
headers: HEADERS
|
178
|
+
url: url
|
193
179
|
};
|
194
|
-
const response = urllib.request(LOGIN_URL, options);
|
195
180
|
|
196
|
-
|
181
|
+
const login = await axios.post(LOGIN_URL, {
|
182
|
+
username: this.user,
|
183
|
+
password: this.passwd,
|
184
|
+
});
|
185
|
+
this.log('hhhhhhhh', login)
|
186
|
+
const data = await axios.post(options);
|
187
|
+
this.log('gggggggg', data.data)
|
188
|
+
|
197
189
|
const energyImport = 0;
|
198
190
|
const energyExport = 0;
|
199
191
|
if (this.tauroneLicznikEnergyService) {
|
@@ -205,6 +197,11 @@ class eLicznikDevice {
|
|
205
197
|
this.energyExport = energyExport;
|
206
198
|
|
207
199
|
this.checkDeviceState = true;
|
200
|
+
|
201
|
+
//start prepare accessory
|
202
|
+
if (this.startPrepareAccessory) {
|
203
|
+
//this.prepareAccessory();
|
204
|
+
}
|
208
205
|
} catch (error) {
|
209
206
|
this.log.error('Device: %s %s, update Device state error: %s', this.meterId, this.name, error);
|
210
207
|
this.checkDeviceState = false;
|
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.
|
4
|
+
"version": "0.0.3-beta.1",
|
5
5
|
"description": "Homebridge plugin (https://github.com/homebridge/homebridge) to read data from Tauron eLicznik.",
|
6
6
|
"license": "MIT",
|
7
7
|
"author": "grzegorz914",
|
@@ -27,11 +27,11 @@
|
|
27
27
|
"LICENSE"
|
28
28
|
],
|
29
29
|
"engines": {
|
30
|
-
"node": ">=
|
30
|
+
"node": ">=14.0.0",
|
31
31
|
"homebridge": ">=1.3.0"
|
32
32
|
},
|
33
33
|
"dependencies": {
|
34
|
-
"
|
34
|
+
"axios": ">=0.25.0"
|
35
35
|
},
|
36
36
|
"keywords": [
|
37
37
|
"homebridge",
|