homebridge-tauron-elicznik 0.0.3-beta.7 → 0.0.3-beta.9
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +30 -24
- package/package.json +3 -3
package/index.js
CHANGED
@@ -3,18 +3,14 @@
|
|
3
3
|
const path = require('path');
|
4
4
|
const fs = require('fs');
|
5
5
|
const fsPromises = fs.promises;
|
6
|
-
const
|
7
|
-
const https = require('https');
|
6
|
+
const request = require('request-promise');
|
8
7
|
|
9
8
|
const PLUGIN_NAME = 'homebridge-tauron-elicznik';
|
10
9
|
const PLATFORM_NAME = 'tauroneLicznik';
|
11
10
|
|
12
|
-
const
|
13
|
-
const
|
14
|
-
const
|
15
|
-
const HEADERS = {
|
16
|
-
'content-type': 'application/x-www-form-urlencoded'
|
17
|
-
};
|
11
|
+
const url = 'https://logowanie.tauron-dystrybucja.pl/login';
|
12
|
+
const chartUrl = 'https://elicznik.tauron-dystrybucja.pl/index/charts';
|
13
|
+
const headers = { 'cache-control': 'no-cache' };
|
18
14
|
|
19
15
|
let Accessory, Characteristic, Service, Categories, UUID;
|
20
16
|
|
@@ -58,7 +54,7 @@ module.exports = (api) => {
|
|
58
54
|
Characteristic.tauroneLicznikEnergyExport = tauroneLicznikEnergyExport;
|
59
55
|
|
60
56
|
class tauroneLicznikEnergyService extends Service {
|
61
|
-
constructor(displayName, subtype,
|
57
|
+
constructor(displayName, subtype,) {
|
62
58
|
super(displayName, '00000001-000A-1000-8000-0026BB765291', subtype);
|
63
59
|
// Mandatory Characteristics
|
64
60
|
this.addCharacteristic(Characteristic.tauroneLicznikEnergyImport);
|
@@ -141,14 +137,14 @@ class eLicznikDevice {
|
|
141
137
|
}
|
142
138
|
|
143
139
|
//Check device state
|
144
|
-
setInterval(
|
140
|
+
setInterval(() => {
|
145
141
|
if (this.checkDeviceInfo) {
|
146
142
|
this.getDeviceInfo();
|
147
143
|
}
|
148
144
|
if (this.checkDeviceState) {
|
149
145
|
this.updateDeviceState();
|
150
146
|
}
|
151
|
-
}
|
147
|
+
}, 30000);
|
152
148
|
}
|
153
149
|
|
154
150
|
getDeviceInfo() {
|
@@ -168,22 +164,32 @@ class eLicznikDevice {
|
|
168
164
|
|
169
165
|
async updateDeviceState() {
|
170
166
|
this.log.debug('Device: %s %s, requesting Device state.', this.meterId, this.name);
|
167
|
+
|
171
168
|
try {
|
172
|
-
|
173
|
-
const
|
174
|
-
|
175
|
-
|
169
|
+
// Add login details & meter ID here:
|
170
|
+
const payload = {
|
171
|
+
username: this.user,
|
172
|
+
password: this.passwd,
|
173
|
+
service: 'https://elicznik.tauron-dystrybucja.pl'
|
176
174
|
};
|
177
175
|
|
178
|
-
const
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
}
|
184
|
-
|
185
|
-
//
|
186
|
-
|
176
|
+
const chartYear = {
|
177
|
+
'dane[chartYear]': 2021,
|
178
|
+
'dane[paramType]': 'year',
|
179
|
+
'dane[smartNr]': this.meterId,
|
180
|
+
'dane[checkOZE]': 'on'
|
181
|
+
};
|
182
|
+
|
183
|
+
// Log in to the TAURON eLicznik website
|
184
|
+
await request.post({ url, form: payload, headers });
|
185
|
+
await request.post({ url, form: payload, headers });
|
186
|
+
|
187
|
+
// Retrieve data for the specified meter ID
|
188
|
+
const response = await request.post({ url: chartUrl, form: chartYear, headers });
|
189
|
+
const jsonData = JSON.parse(response);
|
190
|
+
|
191
|
+
// Print the JSON data
|
192
|
+
this.log('Device: %s, update Device state: %s', this.name, jsonData);
|
187
193
|
|
188
194
|
const energyImport = 0;
|
189
195
|
const energyExport = 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.3-beta.
|
4
|
+
"version": "0.0.3-beta.9",
|
5
5
|
"description": "Homebridge plugin (https://github.com/homebridge/homebridge) to read data from Tauron eLicznik.",
|
6
6
|
"license": "MIT",
|
7
7
|
"author": "grzegorz914",
|
@@ -28,10 +28,10 @@
|
|
28
28
|
],
|
29
29
|
"engines": {
|
30
30
|
"node": ">=14.0.0",
|
31
|
-
"homebridge": ">=1.
|
31
|
+
"homebridge": ">=1.4.0"
|
32
32
|
},
|
33
33
|
"dependencies": {
|
34
|
-
"
|
34
|
+
"request-promise": ">=4.2.6"
|
35
35
|
},
|
36
36
|
"keywords": [
|
37
37
|
"homebridge",
|