homebridge-tauron-elicznik 0.0.3-beta.4 → 0.0.3-beta.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/index.js +21 -22
  2. 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,41 +151,39 @@ class eLicznikDevice {
150
151
  }.bind(this), this.refreshInterval * 1000);
151
152
  }
152
153
 
153
- async getDeviceInfo() {
154
+ getDeviceInfo() {
154
155
  this.log.debug('Device: %s %s, requesting Device Info.', this.meterId, this.name);
155
- try {
156
- this.log('-------- %s --------', this.name);
157
- this.log('Manufacturer: %s', this.manufacturer);
158
- this.log('Model: %s', this.modelName);
159
- this.log('Meter Id: %s', this.meterId);
160
- this.log('Serialnr: %s', this.serialNumber);
161
- this.log('Firmware: %s', this.firmwareRevision);
162
- this.log('----------------------------------');
163
-
164
- this.checkDeviceInfo = false;
165
- this.updateDeviceState();
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]=2021&dane[paramType]=year&dane[checkOZE]=on&dane[smartNr]=${this.meterId}`;
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
 
178
+ const token = Buffer.from(`${this.user}:${this.passwd}`, 'utf8').toString('base64')
181
179
  const login = await axios.post(LOGIN_URL, {
182
- username: this.user,
183
- password: this.passwd,
180
+ headers: {
181
+ 'Authorization': `Basic ${token}`
182
+ }
184
183
  });
185
184
  this.log('hhhhhhhh', login)
186
- const data = await axios(options);
187
- this.log('gggggggg', data.data)
185
+ //const data = await axios(options);
186
+ //this.log('gggggggg', data.data)
188
187
 
189
188
  const energyImport = 0;
190
189
  const energyExport = 0;
@@ -203,7 +202,7 @@ class eLicznikDevice {
203
202
  //this.prepareAccessory();
204
203
  }
205
204
  } catch (error) {
206
- this.log.error('Device: %s %s, update Device state error: %s', this.meterId, this.name, error);
205
+ this.log.error('Device: %s, update Device state error: %s', this.name, error);
207
206
  this.checkDeviceState = false;
208
207
  this.checkDeviceInfo = true;
209
208
  }
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",
4
+ "version": "0.0.3-beta.7",
5
5
  "description": "Homebridge plugin (https://github.com/homebridge/homebridge) to read data from Tauron eLicznik.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",