homebridge-tauron-elicznik 0.0.3-beta.0 → 0.0.3-beta.3

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 +16 -14
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -148,11 +148,6 @@ class eLicznikDevice {
148
148
  this.updateDeviceState();
149
149
  }
150
150
  }.bind(this), this.refreshInterval * 1000);
151
-
152
- //start prepare accessory
153
- if (this.startPrepareAccessory) {
154
- this.prepareAccessory();
155
- }
156
151
  }
157
152
 
158
153
  async getDeviceInfo() {
@@ -177,18 +172,20 @@ class eLicznikDevice {
177
172
  async updateDeviceState() {
178
173
  this.log.debug('Device: %s %s, requesting Device state.', this.meterId, this.name);
179
174
  try {
180
- const url = CHARTS_URL + '?dane[chartYear]=2021&dane[paramType]=year&dane[checkOZE]=on&dane[smartNr]=' + this.meterId;
181
- const payload = {
182
- username: this.user,
183
- password: this.passwd,
184
- service: SERVICE_URL
185
- };
175
+ const url = `${CHARTS_URL}?dane[chartYear]=2021&dane[paramType]=year&dane[checkOZE]=on&dane[smartNr]=${this.meterId}`;
186
176
  const options = {
187
177
  method: 'POST',
188
- data: payload,
189
- headers: HEADERS
178
+ url: url
190
179
  };
191
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
+
192
189
  const energyImport = 0;
193
190
  const energyExport = 0;
194
191
  if (this.tauroneLicznikEnergyService) {
@@ -200,6 +197,11 @@ class eLicznikDevice {
200
197
  this.energyExport = energyExport;
201
198
 
202
199
  this.checkDeviceState = true;
200
+
201
+ //start prepare accessory
202
+ if (this.startPrepareAccessory) {
203
+ //this.prepareAccessory();
204
+ }
203
205
  } catch (error) {
204
206
  this.log.error('Device: %s %s, update Device state error: %s', this.meterId, this.name, error);
205
207
  this.checkDeviceState = false;
@@ -236,7 +238,7 @@ class eLicznikDevice {
236
238
  //Prepare service
237
239
  this.log.debug('prepareTauroneLicznikService');
238
240
  //power and energy
239
- this.tauroneLicznikEnergyService = new Service.tauroneLicznikEnergyService('Meter ' + this.meterId, 'tauroneLicznikEnergyService');
241
+ this.tauroneLicznikEnergyService = new Service.tauroneLicznikEnergyService(`Meter ${this.meterId}`, 'tauroneLicznikEnergyService');
240
242
  this.tauroneLicznikEnergyService.getCharacteristic(Characteristic.tauroneLicznikEnergyImport)
241
243
  .onGet(async () => {
242
244
  const value = this.energyImport;
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.0",
4
+ "version": "0.0.3-beta.3",
5
5
  "description": "Homebridge plugin (https://github.com/homebridge/homebridge) to read data from Tauron eLicznik.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",