Skip to content

Commit

Permalink
add checkbox to save quotas
Browse files Browse the repository at this point in the history
  • Loading branch information
TA2k committed Nov 21, 2024
1 parent c2a43d3 commit 738209a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 20 deletions.
13 changes: 12 additions & 1 deletion admin/index_m.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,18 @@
<label for="brand" class="translate">Brand</label>
</div>
</div>

<div class="row">
<div class="col s6 input-field">
<input type="checkbox" class="value" id="fetchChargeStats" />
<label for="fetchChargeStats" class="translate">Fetching Charging Statistics (Disable to save quota)</label>
</div>
</div>
<div class="row">
<div class="col s6 input-field">
<input type="checkbox" class="value" id="fetchChargeSessions" />
<label for="fetchChargeSessions" class="translate">Fetching Charging Sessions (Disable to save quota)</label>
</div>
</div>
<div class="row">
<div class="col s2 input-field">
<input type="number" class="value" id="interval" />
Expand Down
4 changes: 3 additions & 1 deletion io-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@
"interval": 5,
"brand": "bmw",
"ignorelist": "",
"captcha": ""
"captcha": "",
"fetchChargeStats": true,
"fetchChargeSessions": true
},
"objects": [],
"instanceObjects": [
Expand Down
39 changes: 21 additions & 18 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -702,24 +702,27 @@ class Bmw extends utils.Adapter {
const fullDate = new Date(new Date().getTime() - new Date().getTimezoneOffset() * 60000).toISOString().replace('Z', '000');

const urlArray = [];
urlArray.push({
url:
'https://cocoapi.bmwgroup.com/eadrax-chs/v2/charging-sessions?vin=' +
vin +
'&next_token&date=' +
dateFormatted +
'-01T00%3A00%3A00.000Z&maxResults=' +
maxResults +
'&include_date_picker=true',
path: '.chargingSessions.',
name: 'chargingSessions',
});

urlArray.push({
url: 'https://cocoapi.bmwgroup.com/eadrax-chs/v2/charging-statistics?vin=' + vin + '&currentDate=' + fullDate,
path: '.charging-statistics.',
name: 'charging statistics',
});
if (this.config.fetchChargeSessions) {
urlArray.push({
url:
'https://cocoapi.bmwgroup.com/eadrax-chs/v2/charging-sessions?vin=' +
vin +
'&next_token&date=' +
dateFormatted +
'-01T00%3A00%3A00.000Z&maxResults=' +
maxResults +
'&include_date_picker=true',
path: '.chargingSessions.',
name: 'chargingSessions',
});
}
if (this.config.fetchChargeStats) {
urlArray.push({
url: 'https://cocoapi.bmwgroup.com/eadrax-chs/v2/charging-statistics?vin=' + vin + '&currentDate=' + fullDate,
path: '.charging-statistics.',
name: 'charging statistics',
});
}
for (const element of urlArray) {
await this.sleep(10000);
this.log.debug('update ' + vin + element.path);
Expand Down

0 comments on commit 738209a

Please sign in to comment.