Skip to content

Commit

Permalink
* (Apollon77) Add safeguard for too high intervals
Browse files Browse the repository at this point in the history
* update deps
  • Loading branch information
Apollon77 committed Sep 7, 2022
1 parent e4bc6e2 commit 1ef8028
Show file tree
Hide file tree
Showing 6 changed files with 1,275 additions and 520 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

strategy:
matrix:
node-version: [12.x]
node-version: [16.x]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
node-version: [16.x]

steps:
- name: Checkout code
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,10 @@ If the Push connection is never established then you can try to use the followin
Then it should work again

## Changelog

### __WORK IN PROGRESS__
* (Apollon77) Add safeguard for too high intervals

### 3.19.7 (2022-08-19)
* (Apollon77) Fix doNotDisturb when using a time string

Expand Down
8 changes: 4 additions & 4 deletions admin/index_m.html
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
<p class="translate">interval_info</p>

<div class="input-field col s12 m6">
<input class="value validate" placeholder="300" id="updateStateInterval" type="number" min="0" max="1440">
<input class="value validate" placeholder="300" id="updateStateInterval" type="number" min="0" max="100000">
<label for="updateStateInterval" class="translate">updateStateInterval</label>
<span class="helper-text translate">s (0 = disabled)</span>
</div>
Expand All @@ -300,7 +300,7 @@
</div>
<div class="col s12">
<div class="input-field col s12 m6">
<input class="value validate" placeholder="300" id="updateHistoryInterval" type="number" min="0" max="1440">
<input class="value validate" placeholder="300" id="updateHistoryInterval" type="number" min="0" max="100000">
<label for="updateHistoryInterval" class="translate">updateHistoryInterval</label>
<span class="helper-text translate">s (0 = disabled)</span>
</div>
Expand All @@ -311,7 +311,7 @@
</div>
<div class="col s12">
<div class="input-field col s12 m6">
<input class="value validate" placeholder="300" id="updateSmartHomeDevicesInterval" type="number" min="0" max="1440">
<input class="value validate" placeholder="300" id="updateSmartHomeDevicesInterval" type="number" min="0" max="100000">
<label for="updateSmartHomeDevicesInterval" class="translate">updateSmartHomeDevicesInterval</label>
<span class="helper-text translate">s (0 = disabled)</span>
</div>
Expand All @@ -322,7 +322,7 @@
</div>
<div class="col s12">
<div class="input-field col s12 m6">
<input class="value validate" placeholder="300" id="updateConfigurationInterval" type="number" min="0" max="1440">
<input class="value validate" placeholder="300" id="updateConfigurationInterval" type="number" min="0" max="100000">
<label for="updateConfigurationInterval" class="translate">updateConfigurationInterval</label>
<span class="helper-text translate">s (0 = disabled)</span>
</div>
Expand Down
14 changes: 14 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ function deleteObject(id) {
adapter.log.info(`${adapterObjects[objId] ? adapterObjects[objId].type : '?'} ${objId} deleted${err}`);
if (!err) {
delete adapterObjects[objId];
delete stateChangeTrigger[objId];
}
});
} catch (err) {
Expand All @@ -362,6 +363,7 @@ function deleteObject(id) {
adapter.log.info(`${obj.type} ${id} deleted (${err})`);
if (!err) {
delete adapterObjects[id];
delete stateChangeTrigger[id];
}
});
} catch (err) {
Expand Down Expand Up @@ -4539,6 +4541,9 @@ function main() {
if (adapter.config.updateHistoryInterval !== 0) {
adapter.config.updateHistoryInterval = Math.max(adapter.config.updateHistoryInterval, 60);
}
if (adapter.config.updateHistoryInterval > 2147482) { // max 2147483647/1000 --> 2147482
adapter.config.updateHistoryInterval = 0;
}
adapter.log.debug(`Update History Interval: ${adapter.config.updateHistoryInterval !== 0 ? `${adapter.config.updateHistoryInterval}s` : 'disabled'}`);

adapter.config.updateStateInterval = parseInt(adapter.config.updateStateInterval, 10);
Expand All @@ -4554,6 +4559,9 @@ function main() {
if (adapter.config.updateStateInterval !== 0) {
adapter.config.updateStateInterval = Math.max(adapter.config.updateStateInterval, 300);
}
if (adapter.config.updateStateInterval > 2147482) { // max 2147483647/1000 --> 2147482
adapter.config.updateStateInterval = 0;
}
adapter.log.debug(`Update Device State Interval: ${adapter.config.updateStateInterval !== 0 ? `${adapter.config.updateStateInterval}s` : 'disabled'}`);

adapter.config.updateSmartHomeDevicesInterval = parseInt(adapter.config.updateSmartHomeDevicesInterval, 10);
Expand All @@ -4569,6 +4577,9 @@ function main() {
if (adapter.config.updateSmartHomeDevicesInterval !== 0) {
adapter.config.updateSmartHomeDevicesInterval = Math.max(adapter.config.updateSmartHomeDevicesInterval, 300);
}
if (adapter.config.updateSmartHomeDevicesInterval > 2147482) { // max 2147483647/1000 --> 2147482
adapter.config.updateSmartHomeDevicesInterval = 0;
}
adapter.log.debug(`Update SmartHome Devices Interval: ${adapter.config.updateSmartHomeDevicesInterval !== 0 ? `${adapter.config.updateSmartHomeDevicesInterval}s` : 'disabled'}`);

adapter.config.updateConfigurationInterval = parseInt(adapter.config.updateConfigurationInterval, 10);
Expand All @@ -4584,6 +4595,9 @@ function main() {
if (adapter.config.updateConfigurationInterval !== 0) {
adapter.config.updateConfigurationInterval = Math.max(adapter.config.updateConfigurationInterval, 300);
}
if (adapter.config.updateConfigurationInterval > 2147482) { // max 2147483647/1000 --> 2147482
adapter.config.updateConfigurationInterval = 0;
}
adapter.log.debug(`Update Devices Configuration Interval: ${adapter.config.updateConfigurationInterval !== 0 ? `${adapter.config.updateConfigurationInterval}s` : 'disabled'}`);

if (adapter.config.synchronizeLists === undefined) {
Expand Down
Loading

0 comments on commit 1ef8028

Please sign in to comment.