homebridge-tauron-elicznik 0.0.2-beta48 → 0.0.2-beta51

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 -10
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -13,6 +13,9 @@ const PLATFORM_NAME = 'tauroneLicznik';
13
13
  const SERVICE_URL = 'https://elicznik.tauron-dystrybucja.pl';
14
14
  const LOGIN_URL = 'https://logowanie.tauron-dystrybucja.pl/login?service=https://elicznik.tauron-dystrybucja.pl';
15
15
  const CHARTS_URL = 'https://elicznik.tauron-dystrybucja.pl/index/charts';
16
+ const HEADERS = {
17
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0'
18
+ };
16
19
 
17
20
  let Accessory, Characteristic, Service, Categories, UUID;
18
21
 
@@ -132,20 +135,16 @@ class eLicznikDevice {
132
135
  this.energyExport = 0;
133
136
 
134
137
  const data = qs.stringify({
135
- username: this.user,
136
- password: this.passwd,
137
- service: SERVICE_URL
138
+ 'username': this.user,
139
+ 'password': this.passwd,
140
+ 'service': SERVICE_URL
138
141
  });
139
142
 
140
- const headers = {
141
- 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
142
- };
143
-
144
143
  this.axiosInstance = axios.create({
145
144
  method: 'POST',
146
145
  baseURL: LOGIN_URL,
147
146
  data: data,
148
- headers: headers,
147
+ headers: HEADERS,
149
148
  httpsAgent: new https.Agent({
150
149
  rejectUnauthorized: false
151
150
  }),
@@ -198,8 +197,15 @@ class eLicznikDevice {
198
197
  const url = CHARTS_URL + '?dane[chartYear]=2021&dane[paramType]=year&dane[checkOZE]=on&dane[smartNr]=' + this.meterId;
199
198
  try {
200
199
  const options = {
201
- method: 'GET',
202
- url: url
200
+ method: 'POST',
201
+ url: CHARTS_URL,
202
+ headers: HEADERS,
203
+ data: {
204
+ "dane[chartYear]": '2021',
205
+ "dane[paramType]": 'year',
206
+ "dane[smartNr]": this.meterId,
207
+ "dane[checkOZE]": 'on'
208
+ }
203
209
  };
204
210
  const response = await this.axiosInstance(options);
205
211
 
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-beta48",
4
+ "version": "0.0.2-beta51",
5
5
  "description": "Homebridge plugin (https://github.com/homebridge/homebridge) to read data from Tauron eLicznik.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",