homebridge-tauron-elicznik 0.0.3-beta.2 → 0.0.3-beta.5
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +22 -22
- package/package.json +1 -1
package/index.js
CHANGED
@@ -4,6 +4,7 @@ const path = require('path');
|
|
4
4
|
const fs = require('fs');
|
5
5
|
const fsPromises = fs.promises;
|
6
6
|
const axios = require('axios');
|
7
|
+
const https = require('https');
|
7
8
|
|
8
9
|
const PLUGIN_NAME = 'homebridge-tauron-elicznik';
|
9
10
|
const PLATFORM_NAME = 'tauroneLicznik';
|
@@ -150,40 +151,39 @@ class eLicznikDevice {
|
|
150
151
|
}.bind(this), this.refreshInterval * 1000);
|
151
152
|
}
|
152
153
|
|
153
|
-
|
154
|
+
getDeviceInfo() {
|
154
155
|
this.log.debug('Device: %s %s, requesting Device Info.', this.meterId, this.name);
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
} catch (error) {
|
167
|
-
this.log.error('Device: %s %s, Device Info eror: %s, state: Offline, trying to reconnect', this.meterId, this.name, error);
|
168
|
-
this.checkDeviceInfo = true;
|
169
|
-
}
|
156
|
+
|
157
|
+
this.log('-------- %s --------', this.name);
|
158
|
+
this.log('Manufacturer: %s', this.manufacturer);
|
159
|
+
this.log('Model: %s', this.modelName);
|
160
|
+
this.log('Meter Id: %s', this.meterId);
|
161
|
+
this.log('Serialnr: %s', this.serialNumber);
|
162
|
+
this.log('Firmware: %s', this.firmwareRevision);
|
163
|
+
this.log('----------------------------------');
|
164
|
+
|
165
|
+
this.checkDeviceInfo = false;
|
166
|
+
this.updateDeviceState();
|
170
167
|
}
|
171
168
|
|
172
169
|
async updateDeviceState() {
|
173
170
|
this.log.debug('Device: %s %s, requesting Device state.', this.meterId, this.name);
|
174
171
|
try {
|
175
|
-
const url = `${CHARTS_URL}?dane[chartYear]=
|
172
|
+
const url = `${CHARTS_URL}?dane[chartYear]=2022&dane[paramType]=year&dane[checkOZE]=on&dane[smartNr]=${this.meterId}`;
|
176
173
|
const options = {
|
177
174
|
method: 'POST',
|
178
175
|
url: url
|
179
176
|
};
|
180
177
|
|
181
178
|
const login = await axios.post(LOGIN_URL, {
|
179
|
+
httpsAgent: new https.Agent({
|
180
|
+
rejectUnauthorized: false
|
181
|
+
}),
|
182
182
|
username: this.user,
|
183
183
|
password: this.passwd,
|
184
184
|
});
|
185
185
|
this.log('hhhhhhhh', login)
|
186
|
-
const data = await axios
|
186
|
+
const data = await axios(options);
|
187
187
|
this.log('gggggggg', data.data)
|
188
188
|
|
189
189
|
const energyImport = 0;
|
@@ -203,7 +203,7 @@ class eLicznikDevice {
|
|
203
203
|
//this.prepareAccessory();
|
204
204
|
}
|
205
205
|
} catch (error) {
|
206
|
-
this.log.error('Device: %s
|
206
|
+
this.log.error('Device: %s, update Device state error: %s', this.name, error);
|
207
207
|
this.checkDeviceState = false;
|
208
208
|
this.checkDeviceInfo = true;
|
209
209
|
}
|
@@ -238,8 +238,8 @@ class eLicznikDevice {
|
|
238
238
|
//Prepare service
|
239
239
|
this.log.debug('prepareTauroneLicznikService');
|
240
240
|
//power and energy
|
241
|
-
this.
|
242
|
-
this.
|
241
|
+
this.tauroneLicznikEnergyService = new Service.tauroneLicznikEnergyService(`Meter ${this.meterId}`, 'tauroneLicznikEnergyService');
|
242
|
+
this.tauroneLicznikEnergyService.getCharacteristic(Characteristic.tauroneLicznikEnergyImport)
|
243
243
|
.onGet(async () => {
|
244
244
|
const value = this.energyImport;
|
245
245
|
if (!this.disableLogInfo) {
|
@@ -247,7 +247,7 @@ class eLicznikDevice {
|
|
247
247
|
}
|
248
248
|
return value;
|
249
249
|
});
|
250
|
-
this.
|
250
|
+
this.tauroneLicznikEnergyService.getCharacteristic(Characteristic.tauroneLicznikEnergyExport)
|
251
251
|
.onGet(async () => {
|
252
252
|
const value = this.energyExport;
|
253
253
|
if (!this.disableLogInfo) {
|
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.5",
|
5
5
|
"description": "Homebridge plugin (https://github.com/homebridge/homebridge) to read data from Tauron eLicznik.",
|
6
6
|
"license": "MIT",
|
7
7
|
"author": "grzegorz914",
|