homebridge-tauron-elicznik 0.0.3-beta.12 → 0.0.3-beta.14
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +44 -50
- package/package.json +1 -1
package/index.js
CHANGED
@@ -10,7 +10,7 @@ const PLUGIN_NAME = 'homebridge-tauron-elicznik';
|
|
10
10
|
const PLATFORM_NAME = 'tauroneLicznik';
|
11
11
|
|
12
12
|
const url = 'https://logowanie.tauron-dystrybucja.pl/login';
|
13
|
-
const
|
13
|
+
const charturl = 'https://elicznik.tauron-dystrybucja.pl/index/charts';
|
14
14
|
const headers = { 'cache-control': 'no-cache' };
|
15
15
|
|
16
16
|
let Accessory, Characteristic, Service, Categories, UUID;
|
@@ -137,6 +137,12 @@ class eLicznikDevice {
|
|
137
137
|
fsPromises.mkdir(prefDir);
|
138
138
|
}
|
139
139
|
|
140
|
+
this.axiosInstance = axios.create({
|
141
|
+
httpsAgent: new https.Agent({
|
142
|
+
ciphers: 'DEFAULT@SECLEVEL=1'
|
143
|
+
})
|
144
|
+
});
|
145
|
+
|
140
146
|
//Check device state
|
141
147
|
setInterval(() => {
|
142
148
|
if (this.checkDeviceInfo) {
|
@@ -166,58 +172,46 @@ class eLicznikDevice {
|
|
166
172
|
async updateDeviceState() {
|
167
173
|
this.log.debug('Device: %s %s, requesting Device state.', this.meterId, this.name);
|
168
174
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
const url = 'https://logowanie.tauron-dystrybucja.pl/login';
|
177
|
-
const charturl = 'https://elicznik.tauron-dystrybucja.pl/index/charts';
|
178
|
-
const headers = { 'cache-control': 'no-cache' };
|
179
|
-
|
180
|
-
const axiosInstance = axios.create({
|
181
|
-
httpsAgent: new https.Agent({
|
182
|
-
ciphers: 'DEFAULT@SECLEVEL=1'
|
183
|
-
})
|
184
|
-
});
|
175
|
+
try {
|
176
|
+
// Add login details & meter ID here:
|
177
|
+
const payload = {
|
178
|
+
'username': this.user,
|
179
|
+
'password': this.passwd,
|
180
|
+
'service': 'https://elicznik.tauron-dystrybucja.pl'
|
181
|
+
}
|
185
182
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
this.energyImport = energyImport;
|
207
|
-
this.energyExport = energyExport;
|
183
|
+
const chart_year = {
|
184
|
+
"dane[chartYear]": 2020,
|
185
|
+
"dane[paramType]": "year",
|
186
|
+
"dane[smartNr]": this.meterId,
|
187
|
+
"dane[checkOZE]": "on"
|
188
|
+
};
|
189
|
+
|
190
|
+
const response = await this.axiosInstance.post(url, payload, { headers: headers });
|
191
|
+
const response1 = await this.axiosInstance.post(charturl, chart_year, { headers: headers });
|
192
|
+
this.log('Device: %s, update Device state: %s', this.name, response1.data);
|
193
|
+
|
194
|
+
const energyImport = 0;
|
195
|
+
const energyExport = 0;
|
196
|
+
if (this.tauroneLicznikEnergyService) {
|
197
|
+
this.tauroneLicznikEnergyService
|
198
|
+
.updateCharacteristic(Characteristic.tauroneLicznikEnergyImport, energyImport)
|
199
|
+
.updateCharacteristic(Characteristic.tauroneLicznikEnergyExport, energyExport);
|
200
|
+
}
|
201
|
+
this.energyImport = energyImport;
|
202
|
+
this.energyExport = energyExport;
|
208
203
|
|
209
|
-
|
204
|
+
this.checkDeviceState = true;
|
210
205
|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
.
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
});
|
206
|
+
//start prepare accessory
|
207
|
+
if (this.startPrepareAccessory) {
|
208
|
+
//this.prepareAccessory();
|
209
|
+
}
|
210
|
+
} catch (error) {
|
211
|
+
this.log.error('Device: %s %s, update Device state error: %s', this.meterId, this.name, error);
|
212
|
+
this.checkDeviceState = false;
|
213
|
+
this.checkDeviceInfo = true;
|
214
|
+
};
|
221
215
|
}
|
222
216
|
|
223
217
|
//Prepare accessory
|
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.14",
|
5
5
|
"description": "Homebridge plugin (https://github.com/homebridge/homebridge) to read data from Tauron eLicznik.",
|
6
6
|
"license": "MIT",
|
7
7
|
"author": "grzegorz914",
|