homebridge-tauron-elicznik 0.0.3-beta.13 → 0.0.3-beta.14

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 +37 -39
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -172,48 +172,46 @@ class eLicznikDevice {
172
172
  async updateDeviceState() {
173
173
  this.log.debug('Device: %s %s, requesting Device state.', this.meterId, this.name);
174
174
 
175
- // Add login details & meter ID here:
176
- const payload = {
177
- 'username': this.user,
178
- 'password': this.passwd,
179
- 'service': 'https://elicznik.tauron-dystrybucja.pl'
180
- }
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
+ }
181
182
 
182
- this.axiosInstance.post(url, payload, { headers: headers })
183
- .then((response) => {
184
- const chart_year = {
185
- "dane[chartYear]": 2020,
186
- "dane[paramType]": "year",
187
- "dane[smartNr]": this.meterId,
188
- "dane[checkOZE]": "on"
189
- };
190
- return this.axiosInstance.post(charturl, chart_year, { headers: headers });
191
- })
192
- .then((response) => {
193
- this.log('Device: %s, update Device state: %s', this.name, response.data);
194
-
195
- const energyImport = 0;
196
- const energyExport = 0;
197
- if (this.tauroneLicznikEnergyService) {
198
- this.tauroneLicznikEnergyService
199
- .updateCharacteristic(Characteristic.tauroneLicznikEnergyImport, energyImport)
200
- .updateCharacteristic(Characteristic.tauroneLicznikEnergyExport, energyExport);
201
- }
202
- this.energyImport = energyImport;
203
- 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;
204
203
 
205
- this.checkDeviceState = true;
204
+ this.checkDeviceState = true;
206
205
 
207
- //start prepare accessory
208
- if (this.startPrepareAccessory) {
209
- //this.prepareAccessory();
210
- }
211
- })
212
- .catch((error) => {
213
- this.log.error('Device: %s, update Device state error: %s', this.name, error);
214
- this.checkDeviceState = false;
215
- this.checkDeviceInfo = true;
216
- });
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
+ };
217
215
  }
218
216
 
219
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.13",
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",