homebridge-tauron-elicznik 0.0.2-beta1 → 0.0.2-beta10

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 +18 -28
  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
+ "pointId": this.meterId,
142
+ 'username': this.user,
143
+ 'password': this.password,
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) {
@@ -175,35 +191,9 @@ class eLicznikDevice {
175
191
  async updateDeviceState() {
176
192
  this.log.debug('Device: %s %s, requesting Device state.', this.meterId, this.name);
177
193
  try {
178
- const headers = {
179
- 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0'
180
- };
181
-
182
- const options = qs.stringify({
183
- 'username': this.user,
184
- 'password': this.password,
185
- "pointId": this.meterId,
186
- //'service': 'https://elicznik.tauron-dystrybucja.pl'
187
- });
188
-
189
- this.axiosInstance = axios.create({
190
- method: 'POST',
191
- baseURL: LOGIN_URL,
192
- headers: {
193
- 'content-type': 'application/x-www-form-urlencoded'
194
- },
195
- data: options,
196
- timeout: 5000,
197
- });
198
-
199
- const chart = {
200
- "dane[chartYear]": 2020,
201
- "dane[paramType]": "year",
202
- "dane[smartNr]": this.meterId,
203
- "dane[checkOZE]": "on"
204
- }
194
+ const CHART_DATA_URL = 'https://elicznik.tauron-dystrybucja.pl/index/charts?dane[chartYear]=2020&dane[paramType]=year&dane[smartNr]=' + this.meterId + '&dane[checkOZE]=on';
205
195
 
206
- const response = await this.axiosInstance(CHARTS_URL);
196
+ const response = await this.axiosInstance(CHART_DATA_URL);
207
197
  this.log.debug('Device: %s %s, debug response: %s', this.meterId, this.name, response.data);
208
198
  const energyImport = response.data;
209
199
  this.log(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-beta1",
4
+ "version": "0.0.2-beta10",
5
5
  "description": "Homebridge plugin (https://github.com/homebridge/homebridge) to read data from Tauron eLicznik.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",