homebridge-tauron-elicznik 0.0.2-beta4 → 0.0.2-beta8

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 +19 -17
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -137,6 +137,22 @@ class eLicznikDevice {
137
137
  fsPromises.mkdir(prefDir);
138
138
  }
139
139
 
140
+ const data = qs.stringify({
141
+ 'username': this.user,
142
+ 'password': this.password,
143
+ 'service': CHARTS_URL
144
+ });
145
+
146
+ this.axiosInstance = axios.create({
147
+ method: 'POST',
148
+ baseURL: LOGIN_URL,
149
+ headers: {
150
+ 'content-type': 'application/x-www-form-urlencoded'
151
+ },
152
+ data: data,
153
+ timeout: 5000,
154
+ });
155
+
140
156
  //Check device state
141
157
  setInterval(function () {
142
158
  if (this.checkDeviceInfo) {
@@ -179,28 +195,14 @@ class eLicznikDevice {
179
195
  'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0'
180
196
  };
181
197
 
198
+ const CHART_DATA_URL = 'https://elicznik.tauron-dystrybucja.pl/index/charts?dane[chartYear]=2020&dane[paramType]=year&dane[smartNr]=' + this.meterId + '&dane[checkOZE]=on';
199
+
182
200
  const options = qs.stringify({
183
201
  'username': this.user,
184
202
  'password': this.password,
185
- 'service': SERVICE_URL
203
+ 'service': CHART_DATA_URL
186
204
  });
187
205
 
188
- this.axiosInstance = axios.create({
189
- method: 'POST',
190
- baseURL: LOGIN_URL,
191
- headers: {
192
- 'content-type': 'application/x-www-form-urlencoded'
193
- },
194
- timeout: 5000,
195
- });
196
-
197
- const chart = {
198
- "dane[chartYear]": 2020,
199
- "dane[paramType]": "year",
200
- "dane[smartNr]": this.meterId,
201
- "dane[checkOZE]": "on"
202
- }
203
-
204
206
  const response = await this.axiosInstance(options);
205
207
  this.log.debug('Device: %s %s, debug response: %s', this.meterId, this.name, response.data);
206
208
  const energyImport = response.data;
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-beta4",
4
+ "version": "0.0.2-beta8",
5
5
  "description": "Homebridge plugin (https://github.com/homebridge/homebridge) to read data from Tauron eLicznik.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",