homebridge-tauron-elicznik 0.0.2-beta93 → 0.0.3-beta.2

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.
Files changed (2) hide show
  1. package/index.js +19 -16
  2. package/package.json +3 -2
package/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  const path = require('path');
4
4
  const fs = require('fs');
5
5
  const fsPromises = fs.promises;
6
+ const axios = require('axios');
6
7
 
7
8
  const PLUGIN_NAME = 'homebridge-tauron-elicznik';
8
9
  const PLATFORM_NAME = 'tauroneLicznik';
@@ -147,11 +148,6 @@ class eLicznikDevice {
147
148
  this.updateDeviceState();
148
149
  }
149
150
  }.bind(this), this.refreshInterval * 1000);
150
-
151
- //start prepare accessory
152
- if (this.startPrepareAccessory) {
153
- this.prepareAccessory();
154
- }
155
151
  }
156
152
 
157
153
  async getDeviceInfo() {
@@ -176,18 +172,20 @@ class eLicznikDevice {
176
172
  async updateDeviceState() {
177
173
  this.log.debug('Device: %s %s, requesting Device state.', this.meterId, this.name);
178
174
  try {
179
- const url = CHARTS_URL + '?dane[chartYear]=2021&dane[paramType]=year&dane[checkOZE]=on&dane[smartNr]=' + this.meterId;
180
- const payload = {
181
- username: this.user,
182
- password: this.passwd,
183
- service: SERVICE_URL
184
- };
175
+ const url = `${CHARTS_URL}?dane[chartYear]=2021&dane[paramType]=year&dane[checkOZE]=on&dane[smartNr]=${this.meterId}`;
185
176
  const options = {
186
177
  method: 'POST',
187
- data: payload,
188
- headers: HEADERS
178
+ url: url
189
179
  };
190
180
 
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
+
191
189
  const energyImport = 0;
192
190
  const energyExport = 0;
193
191
  if (this.tauroneLicznikEnergyService) {
@@ -199,6 +197,11 @@ class eLicznikDevice {
199
197
  this.energyExport = energyExport;
200
198
 
201
199
  this.checkDeviceState = true;
200
+
201
+ //start prepare accessory
202
+ if (this.startPrepareAccessory) {
203
+ //this.prepareAccessory();
204
+ }
202
205
  } catch (error) {
203
206
  this.log.error('Device: %s %s, update Device state error: %s', this.meterId, this.name, error);
204
207
  this.checkDeviceState = false;
@@ -235,8 +238,8 @@ class eLicznikDevice {
235
238
  //Prepare service
236
239
  this.log.debug('prepareTauroneLicznikService');
237
240
  //power and energy
238
- this.tauroneLicznikEnergyService = new Service.tauroneLicznikEnergyService('Meter ' + this.meterId, 'tauroneLicznikEnergyService');
239
- this.tauroneLicznikEnergyService.getCharacteristic(Characteristic.tauroneLicznikEnergyImport)
241
+ this.tauroneLicznikService = new Service.tauroneLicznikEnergyService(`Meter ${this.meterId}`, 'tauroneLicznikEnergyService');
242
+ this.tauroneLicznikService.getCharacteristic(Characteristic.tauroneLicznikEnergyImport)
240
243
  .onGet(async () => {
241
244
  const value = this.energyImport;
242
245
  if (!this.disableLogInfo) {
@@ -244,7 +247,7 @@ class eLicznikDevice {
244
247
  }
245
248
  return value;
246
249
  });
247
- this.tauroneLicznikEnergyService.getCharacteristic(Characteristic.tauroneLicznikEnergyExport)
250
+ this.tauroneLicznikService.getCharacteristic(Characteristic.tauroneLicznikEnergyExport)
248
251
  .onGet(async () => {
249
252
  const value = this.energyExport;
250
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.2-beta93",
4
+ "version": "0.0.3-beta.2",
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,10 +27,11 @@
27
27
  "LICENSE"
28
28
  ],
29
29
  "engines": {
30
- "node": ">=12.0.0",
30
+ "node": ">=14.0.0",
31
31
  "homebridge": ">=1.3.0"
32
32
  },
33
33
  "dependencies": {
34
+ "axios": ">=0.25.0"
34
35
  },
35
36
  "keywords": [
36
37
  "homebridge",