Skip to content

Commit

Permalink
add allowlist
Browse files Browse the repository at this point in the history
  • Loading branch information
TA2k committed Dec 7, 2023
1 parent 5ab88be commit 6133e52
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 150 deletions.
8 changes: 8 additions & 0 deletions admin/index_m.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@
</div>
</div>

<div class="row">
<div class="col s6 input-field">
<input type="text" class="value" id="devicelist" />
<label for="devicelist" class="translate"
>Allowlist of IDs which allow to update to prevent rate limit. Example: 0, HeatDemandControl
</label>
</div>
</div>
<div class="row">
<div class="col s6 input-field">
<input type="number" class="value" id="eventInterval" />
Expand Down
3 changes: 2 additions & 1 deletion io-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@
"client_id": "",
"interval": 5,
"eventInterval": 300,
"gatewayIndex": 1
"gatewayIndex": 1,
"devicelist": ""
},
"objects": [],
"instanceObjects": [
Expand Down
13 changes: 11 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,13 @@ class Viessmannapi extends utils.Adapter {
}

for (const device of installation['gateways'][this.config.gatewayIndex - 1]['devices']) {
if (this.config.devicelist) {
const deviceArray = this.config.devicelist.replace(/\s/g, '').split(',');
if (!deviceArray.includes(device.id.toString())) {
this.log.debug('ignore for update: ' + device.id);
continue;
}
}
for (const element of statusArray) {
let url = element.url.replace('$id', device.id);
url = url.replace('$installation', installation.id);
Expand Down Expand Up @@ -303,9 +310,11 @@ class Viessmannapi extends utils.Adapter {
if (error.response && error.response.status === 429) {
this.log.info('Rate limit reached. Will be reseted next day 02:00');
}
if (error.response && error.response.status === 500) {
if (error.response && error.response.status >= 500) {
this.log.info(
'Error 500. ViessmanAPI not available because of unstable server. Please contact Viessmann and ask them to improve their server',
'Error ' +
error.response.status +
'. ViessmanAPI not available because of unstable server. Please contact Viessmann and ask them to improve their server',
);
return;
}
Expand Down
Loading

0 comments on commit 6133e52

Please sign in to comment.